public void remove(JetspeedPrincipal from, JetspeedPrincipal to) throws SecurityException { if (from.getType().equals(associationType.getFromPrincipalType()) && to.getType().equals(associationType.getToPrincipalType())) { jpasm.removeAssociation(from, to, associationType.getAssociationName()); } }
if (userAssociationType.getFromPrincipalType().getName().equals(JetspeedPrincipalType.USER)) if (userAssociationType.getFromPrincipalType() != principalType) if (iat.getFromPrincipalType() != principalType && iat.getToPrincipalType() != principalType)
public BaseJetspeedPrincipalAssociationHandler(JetspeedPrincipalAssociationType associationType, JetspeedPrincipalManagerSPI from, JetspeedPrincipalManagerSPI to, JetspeedPrincipalAssociationStorageManager jpasm) { this.associationType = associationType; this.from = from; this.to = to; this.jpasm = jpasm; if (!associationType.getFromPrincipalType().getName().equals(from.getPrincipalType().getName()) || !associationType.getToPrincipalType().getName().equals(to.getPrincipalType().getName())) { throw new IllegalArgumentException("Provided ManagerFrom or ManagerTo PrincipalType do not correspond with the AssociationType"); } from.addAssociationHandler(this); if (from != to) { to.addAssociationHandler(this); } }
public void addAssociationHandler(JetspeedPrincipalAssociationHandler jpah) { if (jpah.getAssociationType().getFromPrincipalType().getName().equals(principalType.getName()) || jpah.getAssociationType().getToPrincipalType().getName().equals(principalType.getName())) { AssociationHandlerKey key = new AssociationHandlerKey(jpah); if (assHandlers.containsKey(key)) { throw new IllegalStateException("An AssociationHandler for " + jpah.getAssociationType().getAssociationName() + " already defined"); } assHandlers.put(key, jpah); associationTypes.add(jpah.getAssociationType()); if (jpah.getAssociationType().isRequired() && jpah.getAssociationType().getFromPrincipalType().getName().equals(principalType.getName())) { reqAssociations.put(key,jpah.getAssociationType()); } } else { throw new IllegalArgumentException("AssociationHandler is not handling a " + principalType.getName() + " JetspeedPrincipal"); } }
public AssociationHandlerKey(JetspeedPrincipalAssociationHandler jpah) { this(jpah.getAssociationType().getAssociationName(), jpah.getAssociationType().getFromPrincipalType() .getName(), jpah.getAssociationType() .getToPrincipalType().getName()); }
public void removePrincipal(JetspeedPrincipal principal) throws SecurityException { validatePrincipal(principal); for (JetspeedPrincipalAssociationHandler jpah : assHandlers.values()) { if (jpah.getAssociationType().getFromPrincipalType().getName().equals(principalType.getName())) { jpah.beforeRemoveFrom(principal); } if (jpah.getAssociationType().getToPrincipalType().getName().equals(principalType.getName())) { jpah.beforeRemoveTo(principal); } } jpsm.removePrincipal(principal); notifyRemovedPrincipal(principal); }
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); }
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); } } } }
throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_REQUIRED.createScoped(assType.getFromPrincipalType().getName(), assType.getAssociationName(), assType.getToPrincipalType().getName()));
@SuppressWarnings("unchecked") public void beforeRemoveTo(JetspeedPrincipal to) throws SecurityException { if (associationType.isDependent()) { List<JetspeedPrincipal> fromList = (List<JetspeedPrincipal>)getManagerTo().getAssociatedTo(to.getName(), to.getType(), associationType.getAssociationName()); for (JetspeedPrincipal from : fromList) { getManagerFrom().removePrincipal(from); } } else if (associationType.isRequired() && !isSynchronizing()) { if (!getManagerTo().getAssociatedTo(to.getName(), to.getType(), associationType.getAssociationName()).isEmpty()) { throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_REQUIRED.createScoped(to.getType().getName(), to.getName(), associationType.getFromPrincipalType().getName(), associationType.getAssociationName())); } } }
public void add(JetspeedPrincipal from, JetspeedPrincipal to) throws SecurityException if (from.getType().equals(associationType.getFromPrincipalType()) && to.getType().equals(associationType.getToPrincipalType()))
throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_REQUIRED.createScoped(assType.getFromPrincipalType().getName(), assType.getAssociationName(), assType.getToPrincipalType().getName()));