public JetspeedPrincipalAssociationTypeImpl(String associationName, JetspeedPrincipalType fromType, JetspeedPrincipalType toType, boolean required, boolean dependent, boolean singular, boolean dominant) { this.associationName = associationName; this.fromType = fromType; this.toType = toType; this.required = required; this.dependent = dependent; this.singular = singular; this.dominant = dominant; this.mixedTypes = !fromType.getName().equals(toType.getName()); }
public SecurityAttributeTypes getSecurityAttributeTypes() { return jp.getType().getAttributeTypes(); }
public JetspeedPrincipalManagerProviderImpl(Set<JetspeedPrincipalManager> managers) { nameMap = new HashMap<String, JetspeedPrincipalType>(); classNameMap = new HashMap<String, JetspeedPrincipalType>(); managersMap = new HashMap<String, JetspeedPrincipalManager>(); for (JetspeedPrincipalManager m : managers) { JetspeedPrincipalType type = m.getPrincipalType(); if (nameMap.containsKey(type.getName())) { throw new IllegalArgumentException("Duplicate JetspeedPrincipalType.name "+type.getName()); } if (classNameMap.containsKey(type.getClassName())) { throw new IllegalArgumentException("Duplicate JetspeedPrincipalType.className "+type.getClassName()); } nameMap.put(type.getName(), type); classNameMap.put(type.getClassName(), type); managersMap.put(type.getName(), m); } this.nameMap = Collections.unmodifiableMap(nameMap); }
String result = jpmp.getPrincipalType((String)tmp).getClassName(); result = result != null ? result.trim() : null; if (result == null || result.length() == 0)
public JetspeedPrincipalManager getManager(JetspeedPrincipalType type) { return managersMap.get(type.getName()); }
public boolean isDefinedAttribute(String name) { return jp.getType().getAttributeTypes().getAttributeTypeMap().containsKey(name); }
protected final void validatePrincipal(JetspeedPrincipal principal) { if (!principal.getType().getName().equals(principalType.getName())) { throw new IllegalArgumentException("Principal is not of type "+principalType.getName()); } if (principal.isTransient()) { throw new IllegalArgumentException("Principal is transient"); } }
@SuppressWarnings("unchecked") public SecurityAttributesImpl(JetspeedPrincipal jp, Collection avColl, boolean readOnly, boolean extendable) { this.jp = jp; this.avColl = avColl; this.persistent = true; this.readOnly = jp.getType().getAttributeTypes().isReadOnly() ? true : readOnly; this.extendable = jp.getType().getAttributeTypes().isExtendable() ? true : extendable; Map<String, SecurityAttributeType> stMap = jp.getType().getAttributeTypes().getAttributeTypeMap(); for (Object avObj : avColl) { SecurityAttributeValue av = (SecurityAttributeValue)avObj; SecurityAttributeType sat = stMap.get(av.getName()); saMap.put(av.getName(), new SecurityAttributeImpl(sat != null ? sat : new SecurityAttributeTypeImpl(av.getName()), av, true)); } }
public final List<? extends JetspeedPrincipal> getAssociatedFrom(String principalFromName, JetspeedPrincipalType from, String associationName) { if ( !assHandlers.containsKey(new AssociationHandlerKey(associationName, from.getName(), principalType.getName()))) { return Collections.emptyList(); } return jpam.getAssociatedFrom(principalFromName, from, principalType, associationName); }
public final List<String> getAssociatedNamesTo(String principalToName, JetspeedPrincipalType to, String associationName) { if ( !assHandlers.containsKey(new AssociationHandlerKey(associationName, principalType.getName(), to.getName()))) { return Collections.emptyList(); } return jpam.getAssociatedNamesTo(principalToName, principalType, to, associationName); }
public final List<String> getAssociatedNamesFrom(String principalFromName, JetspeedPrincipalType from, String associationName) { if ( !assHandlers.containsKey(new AssociationHandlerKey(associationName, from.getName(), principalType.getName()))) { return Collections.emptyList(); } return jpam.getAssociatedNamesFrom(principalFromName, from, principalType, associationName); }
public final List<? extends JetspeedPrincipal> getAssociatedTo(String principalToName, JetspeedPrincipalType to, String associationName) { if ( !assHandlers.containsKey(new AssociationHandlerKey(associationName, principalType.getName(), to.getName()))) { return Collections.emptyList(); } return jpam.getAssociatedTo(principalToName, principalType, to, associationName); }
protected TransientJetspeedPrincipal() { type = jpmp.getPrincipalTypeByClassName(getClass().getName()).getName(); }
public void addSubjectPrincipalsResolver(UserSubjectPrincipalsResolver resolver) { this.usprMap.put(resolver.getPrincipalType().getName(), resolver); } }
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); } }
/** * <p> * Given a subject, finds all principals of the given JetspeedPrincipalType(JPT) for that subject. If no principals * of the given class is not found, null is returned. * </p> * * @param subject The subject supplying the principals. * @param jptName the name of the Jetspeed Principal Type * @return A List of all principals of type JetspeedPrincipal matching a JPT name parameter. */ public static List<JetspeedPrincipal> getPrincipals(Subject subject, String jptName) { List<JetspeedPrincipal> result = new LinkedList<JetspeedPrincipal>(); Iterator<Principal> principals = subject.getPrincipals().iterator(); while (principals.hasNext()) { Principal p = principals.next(); if (p instanceof JetspeedPrincipal) { JetspeedPrincipal jp = (JetspeedPrincipal)p; if (jp.getType().getName().equals(jptName)) { result.add(jp); } } } return result; } /**
protected void processFound(List<JetspeedPrincipal> found, User user, Set<Long> resolvedIds, Set<Principal> principals, Map<String, UserSubjectPrincipalsResolver> resolvers) { for (int i = found.size() -1; i > -1; i--) { JetspeedPrincipal p = found.get(i); if (!p.isEnabled() || !resolvers.containsKey(p.getType().getName()) || !resolvedIds.add(p.getId())) { found.remove(i); } } for (JetspeedPrincipal p : found) { resolvers.get(p.getType().getName()).processPrincipal(p, user, resolvedIds, principals, resolvers); } }
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 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); }