Java Code Examples for org.apache.shiro.authc.SimpleAccount#addRole()
The following examples show how to use
org.apache.shiro.authc.SimpleAccount#addRole() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KnoxJwtRealm.java From zeppelin with Apache License 2.0 | 5 votes |
@Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) { JWTAuthenticationToken upToken = (JWTAuthenticationToken) token; if (validateToken(upToken.getToken())) { try { SimpleAccount account = new SimpleAccount(getName(upToken), upToken.getToken(), getName()); account.addRole(mapGroupPrincipals(getName(upToken))); return account; } catch (ParseException e) { LOGGER.error("ParseException in doGetAuthenticationInfo", e); } } return null; }
Example 2
Source File: KerberosRealm.java From zeppelin with Apache License 2.0 | 5 votes |
/** * This is called when Kerberos authentication is done and a {@link KerberosToken} has * been acquired. * This function returns a Shiro {@link SimpleAccount} based on the {@link KerberosToken} * provided. Null otherwise. */ @Override protected AuthenticationInfo doGetAuthenticationInfo( org.apache.shiro.authc.AuthenticationToken authenticationToken) throws org.apache.shiro.authc.AuthenticationException { if (null != authenticationToken) { KerberosToken kerberosToken = (KerberosToken) authenticationToken; SimpleAccount account = new SimpleAccount(kerberosToken.getPrincipal(), kerberosToken.getCredentials(), kerberosToken.getClass().getName()); account.addRole(mapGroupPrincipals((String)kerberosToken.getPrincipal())); return account; } return null; }
Example 3
Source File: FormRealm.java From shiro-jwt with MIT License | 5 votes |
@Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) { UsernamePasswordToken upToken = (UsernamePasswordToken) token; UserDefault user = userRepository.findByUserId(upToken.getUsername()); if (user != null) { SimpleAccount account = new SimpleAccount(user, user.getCredentials(), getName()); account.addRole(user.getRoles()); return account; } return null; }
Example 4
Source File: JWTRealm.java From shiro-jwt with MIT License | 5 votes |
@Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) { JWTAuthenticationToken upToken = (JWTAuthenticationToken) token; UserDefault user = userRepository.findById(upToken.getUserId()); if (user != null && userRepository.validateToken(upToken.getToken())) { SimpleAccount account = new SimpleAccount(user, upToken.getToken(), getName()); account.addRole(user.getRoles()); return account; } return null; }