use of org.apache.shiro.authc.SimpleAuthenticationInfo in project qi4j-sdk by Qi4j.
the class PasswordRealmMixin method doGetAuthenticationInfo.
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
UnitOfWork uow = module.newUnitOfWork();
try {
String username = ((UsernamePasswordToken) token).getUsername();
PasswordSecurable account = findPasswordSecurable(uow, username);
if (account == null) {
LOG.debug("Unknown subject identifier: {}" + username);
return null;
}
LOG.debug("Found account for {}: {}", username, account);
return new SimpleAuthenticationInfo(account.subjectIdentifier().get(), account.password().get(), getName());
} finally {
uow.discard();
}
}
use of org.apache.shiro.authc.SimpleAuthenticationInfo in project ddf by codice.
the class GuestRealm method doGetAuthenticationInfo.
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
BaseAuthenticationToken baseAuthenticationToken = (BaseAuthenticationToken) authenticationToken;
SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo();
SimplePrincipalCollection principals = createPrincipalFromToken(baseAuthenticationToken);
simpleAuthenticationInfo.setPrincipals(principals);
simpleAuthenticationInfo.setCredentials(authenticationToken.getCredentials());
securityLogger.audit("Guest assertion generated for IP address: " + baseAuthenticationToken.getIpAddress());
return simpleAuthenticationInfo;
}
use of org.apache.shiro.authc.SimpleAuthenticationInfo in project ddf by codice.
the class PKIRealm method doGetAuthenticationInfo.
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
X500Principal principal = (X500Principal) token.getPrincipal();
X509Certificate[] certs = (X509Certificate[]) token.getCredentials();
SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo();
SimplePrincipalCollection principalCollection = createPrincipalCollectionFromCertificate(principal);
simpleAuthenticationInfo.setPrincipals(principalCollection);
simpleAuthenticationInfo.setCredentials(certs);
return simpleAuthenticationInfo;
}
use of org.apache.shiro.authc.SimpleAuthenticationInfo in project xmall by Exrick.
the class MyRealm method doGetAuthenticationInfo.
/**
* 先执行登录验证
* @param token
* @return
* @throws AuthenticationException
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
// 获取用户名密码
String username = token.getPrincipal().toString();
TbUser tbUser = userService.getUserByUsername(username);
if (tbUser != null) {
// 得到用户账号和密码存放到authenticationInfo中用于Controller层的权限判断 第三个参数随意不能为null
AuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(tbUser.getUsername(), tbUser.getPassword(), tbUser.getUsername());
return authenticationInfo;
} else {
return null;
}
}
Aggregations