/* ------------------------------------------------------------ */ public boolean validate(UserIdentity user) { if (_users.containsKey(user.getUserPrincipal().getName())) return true; if (loadUser(user.getUserPrincipal().getName()) != null) return true; return false; }
/** @see org.eclipse.jetty.security.LoginService#login(java.lang.String, java.lang.Object) */ public UserIdentity login(String username, Object credentials) { UserIdentity user = _users.get(username); if (user == null) user = loadUser(username); if (user != null) { UserPrincipal principal = (UserPrincipal) user.getUserPrincipal(); if (principal.authenticate(credentials)) return user; } return null; }
@Override public boolean isUserInRole(Scope scope, String role) { String roleToTest = null; if (scope != null && scope.getRoleRefMap() != null) roleToTest = scope.getRoleRefMap().get(role); if (roleToTest == null) roleToTest = role; // Servlet Spec 3.1 pg 125 if testing special role ** if ("**".equals(roleToTest.trim())) { // if ** is NOT a declared role name, the we return true // as the user is authenticated. If ** HAS been declared as a // role name, then we have to check if the user has that role if (!declaredRolesContains("**")) return true; else return _userIdentity.isUserInRole(role, scope); } return _userIdentity.isUserInRole(role, scope); }
/* ------------------------------------------------------------ */ public void logout(UserIdentity user) { Set<JAASUserPrincipal> userPrincipals = user.getSubject().getPrincipals(JAASUserPrincipal.class); LoginContext loginContext = userPrincipals.iterator().next().getLoginContext(); try { loginContext.logout(); } catch (LoginException e) { LOG.warn(e); } }
public void logout(UserIdentity identity) { Log.debug("logout {}", identity); identities.remove(identity.getUserPrincipal().getName()); }