public void resolve(User user, Set<Long> resolvedIds, Set<Principal> principals, Map<String, UserSubjectPrincipalsResolver> resolvers) { checkInitialized(); if (user.getId() == null || !user.isEnabled()) { // sanity check return; } List<JetspeedPrincipal> found = null; if (fromUser) { found = accessManager.getAssociatedFrom(user.getId(), uat.getFromPrincipalType(), uat.getToPrincipalType(), uat.getAssociationName()); } else { found = accessManager.getAssociatedTo(user.getId(), uat.getFromPrincipalType(), uat.getToPrincipalType(), uat.getAssociationName()); } processFound(found, user, resolvedIds, principals, resolvers); }
@SuppressWarnings("unchecked") public List<PasswordCredential> getHistoricPasswordCredentials(User user, Long securityDomain) { Criteria criteria = new Criteria(); criteria.addEqualTo("principalId", user.getId()); criteria.addEqualTo("type", PasswordCredential.TYPE_HISTORICAL); // check cache String cacheKey = "getHistoricPasswordCredentials:"+criteria; List<PasswordCredential> passwordCredentials = (List<PasswordCredential>) jspmCache.getPasswordCredentialQuery(cacheKey); if (passwordCredentials != null) { return new ArrayList<PasswordCredential>(passwordCredentials); } // perform query Query query = QueryFactory.newQuery(PasswordCredentialImpl.class,criteria); passwordCredentials = (List<PasswordCredential>)getPersistenceBrokerTemplate().execute(new ManagedListByQueryCallback(query)); for (PasswordCredential passwordCredential : passwordCredentials) { // store the user by hand as its configured as auto-retrieve="false" ((PasswordCredentialImpl)passwordCredential).setUser(user); } // put result in cache jspmCache.putPasswordCredentialQuery(cacheKey, user.getId(), user.getDomainId(), new ArrayList<PasswordCredential>(passwordCredentials)); // return result return passwordCredentials; }
public void storePasswordCredential(PasswordCredential credential) throws SecurityException { if (credential.getUser() == null) { loadPasswordCredentialUser(credential); } if (credential.isNewPasswordSet()) { if (credential.getNewPassword() != null) { credential.setPassword(credential.getNewPassword(), false); } } getPersistenceBrokerTemplate().store(credential); // evict user principal from cache to notify jspmCache.evictPrincipal(credential.getUser().getId()); }
public void processPrincipal(JetspeedPrincipal principal, User user, Set<Long> resolvedIds, Set<Principal> principals, Map<String, UserSubjectPrincipalsResolver> resolvers) { checkInitialized(); if (user.getId() == null || !user.isEnabled() || principal.getId() == null || !principal.isEnabled() || principal.getType() != principalType) { // sanity check return; } principals.add(principal); if (iatList != null) { for (JetspeedPrincipalAssociationType iat : iatList) { List <JetspeedPrincipal> found = null; if ((!iat.isMixedTypes() && !iat.isSingular()) || !iat.getFromPrincipalType().getName().equals(getPrincipalType().getName())) { found = accessManager.getAssociatedTo(principal.getId(), iat.getFromPrincipalType(), iat.getToPrincipalType(), iat.getAssociationName()); } else { found = accessManager.getAssociatedFrom(principal.getId(), iat.getFromPrincipalType(), iat.getToPrincipalType(), iat.getAssociationName()); } processFound(found, user, resolvedIds, principals, resolvers); } } } }