我通过本教程使用 Vaadin 7 制作了一个登录表单: https ://vaadin.com/wiki/-/wiki/Main/Creating%20a%20simple%20login%20view 。我必须使用 shiro 验证我的 LDAP (openDJ) 用户。我已将其放入我的 clickEvent 方法中:
Factory<org.apache.shiro.mgt.SecurityManager> ldapFactory = new IniSecurityManagerFactory("classpath:active.ini");
org.apache.shiro.mgt.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();
我在记录器上有错误,我不知道这是否可行?我有一个 active.ini 文件,它看起来像这样:
'ldapRealm = org.apache.shiro.realm.activedirectory.ActiveDirectoryRealm
ldapRealm.url = C:\Users\User\OpenDJ'
我搜索了教程或示例,但没有 vaadin shiro 和 ldap (openDJ)。