I integrated Apache Shiro with a dummy user and it works just fine! But this framework has no tutorials online?! It's very hard to get into it as a beginner.
Can somebody help me integrating a ldap integration. I have only found information that it is not that difficult :-/
I started with configuring the realm:
[main]
myRealm = org.apache.shiro.realm.ldap.AbstractLdapRealm
But what to do next? How to configure it?
Thank's for any help
The AbstractLdapRealm is abstract - you can't instantiate it directly or declare it as your realm. You will have to subclass this one and implement the necessary abstract methods.
You won't need to do this upon the next Shiro release - there is currently an issue open (https://issues.apache.org/jira/browse/SHIRO-127) to have a concrete implementation that can be used out of the box so 95% of end-users won't have to subclass the AbstractLdapRealm.
This could be of little help. Check for the whole tutorial it covers simple and LDAP authentication. http://www.ibm.com/developerworks/web/library/wa-apacheshiro/
Here is working example.
active.ini
ldapRealm = org.apache.shiro.realm.activedirectory.ActiveDirectoryRealm
ldapRealm.url = ldap://ldapserver:389
Code:
Factory<SecurityManager> ldapFactory = new IniSecurityManagerFactory("classpath:active.ini");
SecurityManager sManager = ldapFactory.getInstance();
SecurityUtils.setSecurityManager(sManager);
Subject currentUser = SecurityUtils.getSubject();
if (!currentUser.isAuthenticated()) {
UsernamePasswordToken token = new UsernamePasswordToken("user", "password");
try {
currentUser.login(token);
} catch (UnknownAccountException ex) {
logger.info("Unknown user");
} catch (IncorrectCredentialsException ex) {
logger.info("Incorrect credentials");
} catch (LockedAccountException ex) {
logger.info("Account is Locked");
} catch (AuthenticationException ex) {
logger.info("Authentication Exception");
}
}
logger.info("User [" + currentUser.getPrincipal() +"] logged succesfully");
currentUser.logout();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With