Class LdapAgent
java.lang.Object
org.summerboot.jexpress.integration.ldap.LdapAgent
- All Implemented Interfaces:
Closeable,AutoCloseable
- Author:
- Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final Propertiesstatic final Stringprotected final booleanprotected static final org.apache.logging.log4j.Loggerprotected LdapContextstatic Stringprotected static final intprotected final Stringprotected String -
Constructor Summary
ConstructorsConstructorDescriptionLdapAgent(Properties cfg, String baseDN, boolean isAD, String tenantGroupName) -
Method Summary
Modifier and TypeMethodDescriptionintaddEntryAttrs(String entryDn, Map<String, String> attributes) voidauthenticate(String dn, String currentPassword) authenticateUser(String username, String password, AuthenticatorListener listener) static LdapAgentbuild()static PropertiesbuildCfg(String host, int port, boolean isSSLEnabled, String ldapSSLConnectionFactoryClassName, String sslProtocol, String bindingUserDN, String bindingPassword) voidchangePassword(String uid, String newPassword, String algorithm) voidclose()protected voidconnect()createUser(String uid, String pwd, String algorithm, String company, String org, Map<String, String> profile) voiddeleteEntry(String dn) voiddeleteUser(String uid) protected static Stringprotected static StringescapeQuery(String value) static StringgenerateSSHA(String password) static StringgenerateSSHA(String _password, String algorithm) getAttr(Attributes attrs, String id) getUserRoleGroups(String userDN) static StringhashMD5Password(String password, String algorithm) static StringparseAddedAndRemoved(List<Attributes> currentGroup, String[] newGroup) queryOrganizationUnit(String o, String ou) queryPerson(String key, String value) String[]queryPersonDN(String key, String username) static Stringstatic StringvoidintupdateEntryAttrs(String entryDn, Map<String, String> attributes) voidupdateUserGroups(String userDN, String... newGroupDnList)
-
Field Details
-
log
protected static final org.apache.logging.log4j.Logger log -
DN
- See Also:
-
cfg
-
baseDN
-
isAD
protected final boolean isAD -
tenantGroupName
-
m_ctx
-
uidKey
-
SALT_LENGTH
protected static final int SALT_LENGTH- See Also:
-
PASSWORD_ALGORITHM
-
-
Constructor Details
-
LdapAgent
public LdapAgent(Properties cfg, String baseDN, boolean isAD, String tenantGroupName) throws NamingException - Throws:
NamingException
-
-
Method Details
-
escape
-
escapeQuery
-
replaceO
-
replaceOU
-
build
- Throws:
NamingException
-
buildCfg
-
getLdapContext
-
getUidKey
-
setUidKey
-
getBaseDN
-
getTenantGroupName
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
connect
- Throws:
NamingException
-
getDN
- Throws:
NamingException
-
queryPersonDN
- Throws:
NamingException
-
queryPerson
- Throws:
NamingException
-
getUserRoleGroups
- Throws:
NamingException
-
query
- Throws:
NamingException
-
getAttr
- Throws:
NamingException
-
parseAddedAndRemoved
protected List<String>[] parseAddedAndRemoved(List<Attributes> currentGroup, String[] newGroup) throws NamingException - Throws:
NamingException
-
hashMD5Password
public static String hashMD5Password(String password, String algorithm) throws NoSuchAlgorithmException - Parameters:
password-algorithm- MD5, SHA-1, SHA-256 or SHA3-256 see https://en.wikipedia.org/wiki/SHA-3 (section Comparison of SHA functions)- Returns:
- Throws:
NoSuchAlgorithmException
-
generateSSHA
- Throws:
NoSuchAlgorithmException
-
generateSSHA
public static String generateSSHA(String _password, String algorithm) throws NoSuchAlgorithmException - Parameters:
_password-algorithm- MD5, SHA-1, SHA-256 or SHA3-256 see https://en.wikipedia.org/wiki/SHA-3 (section Comparison of SHA functions)- Returns:
- Throws:
NoSuchAlgorithmException
-
authenticate
- Throws:
NamingException
-
authenticateUser
public User authenticateUser(String username, String password, AuthenticatorListener listener) throws NamingException - Throws:
NamingException
-
changePassword
public void changePassword(String uid, String newPassword, String algorithm) throws NamingException, NoSuchAlgorithmException -
n2q
-
createUser
-
createEntry
public String createEntry(String dn, Set<String> objectClasses, Map<String, String> attributes) throws NamingException- Throws:
NamingException
-
addEntryAttrs
- Throws:
NamingException
-
updateEntryAttrs
- Throws:
NamingException
-
deleteUser
- Throws:
NamingException
-
deleteEntry
- Throws:
NamingException
-
updateUserGroups
- Throws:
NamingException
-
queryOrganization
- Throws:
NamingException
-
queryOrganizationUnit
- Throws:
NamingException
-
queryOrganizationUnitUsers
- Throws:
NamingException
-
queryGroupUsers
- Throws:
NamingException
-