private Property resolveProperty( Class<? extends IdentityType> identityType, StereotypeProperty.Property stereotypeProperty) { List<Property<Object>> properties = PropertyQueries.createQuery(identityType) .addCriteria(new AnnotatedPropertyCriteria(StereotypeProperty.class)) .getResultList(); if (properties.isEmpty()) { throw new IdentityManagementException( "IdentityType [" + identityType + "] does not have any property mapped with " + StereotypeProperty.class + "."); } for (Property property : properties) { StereotypeProperty propertyStereotypeProperty = property.getAnnotatedElement().getAnnotation(StereotypeProperty.class); if (stereotypeProperty.equals(propertyStereotypeProperty.value())) { return property; } } throw new IdentityManagementException( "Could not resolve property in type [" + identityType + " for StereotypeProperty [" + stereotypeProperty + "."); }
private <I extends IdentityType> I extractIdentityTypeFromToken( JWSToken token, Class<I> identityType, StereotypeProperty.Property stereotypeProperty, Object identifier) { if (hasIdentityType(token, stereotypeProperty, identifier)) { try { I identityTypeInstance = Reflections.newInstance(identityType); Property property = resolveProperty(identityType, stereotypeProperty); property.setValue(identityTypeInstance, identifier); if (Account.class.isAssignableFrom(identityType)) { Property userNameProperty = resolveProperty(identityType, StereotypeProperty.Property.IDENTITY_ID); userNameProperty.setValue(identityTypeInstance, extractSubject(token)); } return identityTypeInstance; } catch (Exception e) { throw new IdentityManagementException( "Could not extract IdentityType [" + identityType + "] from Token [" + token + "].", e); } } return null; }
public Set<Partition> getRelationshipPartitions(Relationship relationship) { Set<Partition> partitions = new HashSet<Partition>(); for (Property<? extends IdentityType> prop : getRelationshipIdentityProperties(relationship.getClass())) { IdentityType identity = prop.getValue(relationship); if (!partitions.contains(identity.getPartition())) { partitions.add(identity.getPartition()); } } return partitions; }