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 Propertiesprotected final booleanprotected LdapContextprotected final String -
Constructor Summary
ConstructorsConstructorDescriptionLdapAgent(Properties cfg, String baseDN, boolean isAD, String tenantGroupName) -
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticate(String dn, String currentPassword) static PropertiesbuildCfg(String host, int port, boolean isSSL, String ldapSSLConnectionFactoryClassName, String sslProtocol, String bindingUserDN, String bindingPassword) voidchangePassword(String uid, String currentPassword, String newPassword) voidclose()voiddeleteEntry(String dn) voiddeleteUser(String uid) 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 StringqueryOrganizationUnit(String o, String ou) queryPerson(String key, String value) String[]queryPersonDN(String key, String username) voidupdateEntryAttrs(String userDN, Map<String, String> attributes) voidupdateUserGroups(String userDN, String... newGroupDnList)
-
Field Details
-
cfg
-
baseDN
-
isAD
protected final boolean isAD -
tenantGroupName
-
m_ctx
-
-
Constructor Details
-
LdapAgent
public LdapAgent(Properties cfg, String baseDN, boolean isAD, String tenantGroupName) throws NamingException, IOException - Throws:
NamingExceptionIOException
-
-
Method Details
-
buildCfg
-
getBaseDN
-
getTenantGroupName
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getDN
- Throws:
NamingException
-
queryPersonDN
- Throws:
NamingException
-
queryPerson
- Throws:
NamingException
-
getUserRoleGroups
- Throws:
NamingException
-
query
- Throws:
NamingException
-
getAttr
- Throws:
NamingException
-
hashMD5Password
public static String hashMD5Password(String password, String algorithm) throws GeneralSecurityException - 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:
GeneralSecurityException
-
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
-
changePassword
public void changePassword(String uid, String currentPassword, String newPassword) throws NamingException, GeneralSecurityException -
n2q
-
createUser
public String createUser(String uid, String pwd, String company, String org, Map<String, String> profile) throws NamingException, GeneralSecurityException -
createEntry
public String createEntry(String dn, Set<String> objectClasses, Map<String, String> attributes) throws NamingException- Throws:
NamingException
-
updateEntryAttrs
public void updateEntryAttrs(String userDN, Map<String, String> attributes) throws GeneralSecurityException, NamingException -
deleteUser
-
deleteEntry
-
updateUserGroups
public void updateUserGroups(String userDN, String... newGroupDnList) throws GeneralSecurityException, NamingException -
queryOrganization
- Throws:
NamingException
-
queryOrganizationUnit
- Throws:
NamingException
-
queryOrganizationUnitUsers
- Throws:
NamingException
-
queryGroupUsers
- Throws:
NamingException
-