@Override protected KnownUser loadUserInfo(String userName) { UserIdentity id = _propertyUserStore.getUserIdentity(userName); if (id != null) { return (KnownUser)id.getUserPrincipal(); } return null; }
@Override protected String[] loadRoleInfo(KnownUser user) { UserIdentity id = _propertyUserStore.getUserIdentity(user.getName()); if (id == null) return null; Set<RolePrincipal> roles = id.getSubject().getPrincipals(RolePrincipal.class); if (roles == null) return null; List<String> list = new ArrayList<>(); for (RolePrincipal r:roles) list.add(r.getName()); return list.toArray(new String[roles.size()]); }
/** * Don't implement this as we want to pre-fetch all of the users. * * @param userName * @throws Exception */ public UserInfo getUserInfo(String userName) throws Exception { PropertyUserStore propertyUserStore = _propertyUserStores.get(_filename); if (propertyUserStore == null) throw new IllegalStateException("PropertyUserStore should never be null here!"); LOG.debug("Checking PropertyUserStore "+_filename+" for "+userName); UserIdentity userIdentity = propertyUserStore.getUserIdentity(userName); if (userIdentity==null) return null; Set<Principal> principals = userIdentity.getSubject().getPrincipals(); List<String> roles = new ArrayList<String>(); for ( Principal principal : principals ) { roles.add( principal.getName() ); } Credential credential = (Credential)userIdentity.getSubject().getPrivateCredentials().iterator().next(); LOG.debug("Found: " + userName + " in PropertyUserStore "+_filename); return new UserInfo(userName, credential, roles); }
/** * Don't implement this as we want to pre-fetch all of the users. * * @param userName * @throws Exception */ public UserInfo getUserInfo(String userName) throws Exception { PropertyUserStore propertyUserStore = _propertyUserStores.get(_filename); if (propertyUserStore == null) throw new IllegalStateException("PropertyUserStore should never be null here!"); LOG.debug("Checking PropertyUserStore "+_filename+" for "+userName); UserIdentity userIdentity = propertyUserStore.getUserIdentity(userName); if (userIdentity==null) return null; Set<Principal> principals = userIdentity.getSubject().getPrincipals(); List<String> roles = new ArrayList<String>(); for ( Principal principal : principals ) { roles.add( principal.getName() ); } Credential credential = (Credential)userIdentity.getSubject().getPrivateCredentials().iterator().next(); LOG.debug("Found: " + userName + " in PropertyUserStore "+_filename); return new UserInfo(userName, credential, roles); }