Refine search
void addUser(String username, String password) { principals.put(username, new GenericPrincipal(username, password, Collections.singletonList(AUTH_ROLE))); }
@Override protected String getPassword(String username) { GenericPrincipal principal = principals.get(username); return principal == null ? null : principal.getPassword(); }
/** * Return the Principal associated with the specified username and * credentials, if there is one; otherwise return <code>null</code>. * * @param username Username of the Principal to look up * @param credentials Password or other credentials to use in * authenticating this username */ @Override public Principal authenticate(String username, String credentials) { GenericPrincipal principal = principals.get(username); boolean validated = compareCredentials(credentials, principal.getPassword()); if (validated) { if (log.isDebugEnabled()) log.debug(sm.getString("memoryRealm.authenticateSuccess", username)); return (principal); } else { if (log.isDebugEnabled()) log.debug(sm.getString("memoryRealm.authenticateFailure", username)); return (null); } }
if (log.isDebugEnabled()) { log.debug("commit " + principal); String roles[] = ((GenericPrincipal) principal).getRoles(); for (int i = 0; i < roles.length; i++) { subject.getPrincipals().add(new GenericPrincipal(roles[i], null, null));
authStatus = state.serverAuthContext.validateRequest(state.messageInfo, client, null); } catch (AuthException e) { log.debug(sm.getString("authenticator.loginFail"), e); return false; if (log.isDebugEnabled()) { log.debug("Authenticated user: " + principal); !principal.getUserPrincipal().equals(request.getUserPrincipal())) {
public static GenericPrincipal readPrincipal(ObjectInput in) throws IOException, ClassNotFoundException { String name = in.readUTF(); boolean hasPwd = in.readBoolean(); String pwd = null; if ( hasPwd ) pwd = in.readUTF(); int size = in.readInt(); String[] roles = new String[size]; for ( int i=0; i<size; i++ ) roles[i] = in.readUTF(); Principal userPrincipal = null; boolean hasUserPrincipal = in.readBoolean(); if (hasUserPrincipal) { try { userPrincipal = (Principal) in.readObject(); } catch (ClassNotFoundException e) { log.error(sm.getString( "serializablePrincipal.readPrincipal.cnfe"), e); throw e; } } return new GenericPrincipal(name,pwd,Arrays.asList(roles), userPrincipal); }
log.debug("commit " + principal); String roles[] = ((GenericPrincipal) principal).getRoles(); for (int i = 0; i < roles.length; i++) { subject.getPrincipals().add( new GenericPrincipal(null, roles[i], null));
if (containerLog.isTraceEnabled()) containerLog.trace( sm.getString("dataSourceRealm.authenticateSuccess", username)); } else { if (containerLog.isTraceEnabled()) containerLog.trace( sm.getString("dataSourceRealm.authenticateFailure", username)); return (null); return new GenericPrincipal(username, credentials, list);
public static SerializablePrincipal createPrincipal(GenericPrincipal principal) { if ( principal==null) return null; return new SerializablePrincipal(principal.getName(), principal.getPassword(), principal.getRoles()!=null?Arrays.asList(principal.getRoles()):null, principal.getUserPrincipal()!=principal?principal.getUserPrincipal():null); }
@Override public String[] getRoles(Principal principal) { if (principal instanceof GenericPrincipal) { return ((GenericPrincipal) principal).getRoles(); } String className = principal.getClass().getSimpleName(); throw new IllegalStateException(sm.getString("realmBase.cannotGetRoles", className)); } }
@Override public boolean commit() throws LoginException { if (!subject.getPrincipals().contains(principal)) { subject.getPrincipals().add(principal); if (GenericPrincipal.class.isInstance(principal)) { final String roles[] = GenericPrincipal.class.cast(principal).getRoles(); for (final String role : roles) { subject.getPrincipals().add(new GenericPrincipal(role, null, null)); } } } return true; }
private String[] getRolePrincipal() { final GenericPrincipal genericPrincipal = (GenericPrincipal) getUserPrincipal(); return genericPrincipal.getRoles(); }
public SecuritySubject authenticate(AuthenticationToken<?, ?> token) throws AuthenticationException { if (delegate != null) { // if a security extension is installed, delegate to it return delegate.authenticate(token); } if (realm != null) { if (token instanceof UsernamePasswordToken) { UsernamePasswordToken usernamePassword = (UsernamePasswordToken) token; String username = usernamePassword.getPrincipal(); String password = usernamePassword.getCredentials(); Principal principal = realm.authenticate(username, password); if (principal instanceof GenericPrincipal) { GenericPrincipal generic = (GenericPrincipal) principal; Set<Role> roles = new HashSet<Role>(); for (String name : generic.getRoles()) { roles.add(new Role(name)); } return new BasicSecuritySubject(generic.getName(), generic.getPassword(), roles); } else { return new BasicSecuritySubject(username, password, Collections.<Role>emptySet()); } } } throw new AuthenticationException("Unable to authenticate because a Tomcat Realm or Fabric3 Security extension has not been configured"); } }
else if (samlSession.getPrincipal().getName().equals(principal.getName())){ if (!principal.getUserPrincipal().getName().equals(samlSession.getPrincipal().getName())) { throw new RuntimeException("Unknown State"); for (String role : principal.getRoles()) { log.debug("principal role: " + role);
/** * Return the principal that has been authenticated for this Request. */ @Override public Principal getUserPrincipal() { if (userPrincipal instanceof GenericPrincipal) { return ((GenericPrincipal) userPrincipal).getUserPrincipal(); } return userPrincipal; }
String userPrincipalName = genPrincipal.getUserPrincipal().getName(); if (!genPrincipal.getName().equals(userPrincipalName)) log.trace("GenericPrincipal name: " + genPrincipal.getName() + " will be changed to name: " + userPrincipalName);