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; }
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; }
private PermissionManager getPermissionManager(IdentityType recipient) { return partitionManager.createPermissionManager(recipient.getPartition()); }
private PermissionManager getPermissionManager(IdentityType recipient) { return partitionManager.createPermissionManager(recipient.getPartition()); }
private Set<IdentityStore<?>> getStores() { Set<Partition> partitions = new HashSet<Partition>(); for (Object param : parameters.values()) { if (IdentityType.class.isInstance(param)) { partitions.add(((IdentityType) param).getPartition()); } } try { return getStoreSelector().getStoresForRelationshipQuery(context, relationshipClass, partitions); } catch (OperationNotSupportedException onse) { return Collections.EMPTY_SET; } }
/** * <p>Return a formatted string representing the reference to the given {@link org.picketlink.idm.model.IdentityType}.</p> * * @param identityType * * @return */ public static String formatId(final IdentityType identityType) { return identityType.getClass().getName() + ID_SEPARATOR + identityType.getPartition().getId() + ID_SEPARATOR + identityType.getId(); }
private Set<IdentityStore<?>> getStores() { Set<Partition> partitions = new HashSet<Partition>(); for (Object param : parameters.values()) { if (IdentityType.class.isInstance(param)) { partitions.add(((IdentityType) param).getPartition()); } } try { return getStoreSelector().getStoresForRelationshipQuery(context, relationshipClass, partitions); } catch (OperationNotSupportedException onse) { return Collections.EMPTY_SET; } }
/** * <p>Return a formatted string representing the reference to the given {@link org.picketlink.idm.model.IdentityType}.</p> * * @param identityType * * @return */ public static String formatId(final IdentityType identityType) { return identityType.getClass().getName() + ID_SEPARATOR + identityType.getPartition().getId() + ID_SEPARATOR + identityType.getId(); }
@Override protected void doPopulateProperties(Map<String, Serializable> properties) throws Exception { super.doPopulateProperties(properties); IdentityType identityType = getEntry(); if (identityType.getPartition() == null) { throw new IllegalStateException("Partition Null"); } if (identityType.getPartition().getId() == null) { throw new IllegalStateException("Partition ID Null"); } properties.put("partitionId", identityType.getPartition().getId()); properties.put("partitionType", identityType.getPartition().getClass().getName()); properties.put("createdDate", identityType.getCreatedDate()); if (identityType.getExpirationDate() != null) { properties.put("expirationDate", identityType.getExpirationDate()); } properties.put("enabled", identityType.isEnabled()); } }
@Override protected void doPopulateProperties(Map<String, Serializable> properties) throws Exception { super.doPopulateProperties(properties); IdentityType identityType = getEntry(); if (identityType.getPartition() == null) { throw new IllegalStateException("Partition Null"); } if (identityType.getPartition().getId() == null) { throw new IllegalStateException("Partition ID Null"); } properties.put("partitionId", identityType.getPartition().getId()); properties.put("partitionType", identityType.getPartition().getClass().getName()); properties.put("createdDate", identityType.getCreatedDate()); if (identityType.getExpirationDate() != null) { properties.put("expirationDate", identityType.getExpirationDate()); } properties.put("enabled", identityType.isEnabled()); } }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!getClass().isInstance(obj)) { return false; } IdentityType other = (IdentityType) obj; return (getId() != null && other.getId() != null && getPartition() != null && other.getPartition() != null) && (getId().equals(other.getId()) && getPartition().equals(other.getPartition())); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!getClass().isInstance(obj)) { return false; } IdentityType other = (IdentityType) obj; return (getId() != null && other.getId() != null && getPartition() != null && other.getPartition() != null) && (getId().equals(other.getId()) && getPartition().equals(other.getPartition())); }
@Override protected void checkIfExists(IdentityType identityType) throws IdentityManagementException { if (identityType == null) { throw MESSAGES.nullArgument("IdentityType"); } if (lookupIdentityById(identityType.getClass(), identityType.getId()) == null) { throw MESSAGES.attributedTypeNotFoundWithId(identityType.getClass(), identityType.getId(), identityType.getPartition()); } }
@Override protected void checkIfExists(IdentityType identityType) throws IdentityManagementException { if (identityType == null) { throw MESSAGES.nullArgument("IdentityType"); } if (lookupIdentityById(identityType.getClass(), identityType.getId()) == null) { throw MESSAGES.attributedTypeNotFoundWithId(identityType.getClass(), identityType.getId(), identityType.getPartition()); } }
@Override protected void doUpdate(IdentityType attributedType) { if (attributedType.getPartition() == null) { throw MESSAGES.attributedUndefinedPartition(attributedType); } IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForIdentityOperation(identityContext, IdentityStore.class, attributedType.getClass(), IdentityOperation.update) .update(identityContext, attributedType); }
@Override protected void doUpdate(IdentityType attributedType) { if (attributedType.getPartition() == null) { throw MESSAGES.attributedUndefinedPartition(attributedType); } IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForIdentityOperation(identityContext, IdentityStore.class, attributedType.getClass(), IdentityOperation.update) .update(identityContext, attributedType); }
@Override public boolean grantPermission(IdentityContext context, IdentityType assignee, Object resource, String operation) { Partition partition = assignee.getPartition(); FilePartition filePartition = resolve(partition.getClass(), partition.getName()); Class resourceClass = context.getPermissionHandlerPolicy().getResourceClass(resource); Serializable resourceIdentifier = context.getPermissionHandlerPolicy().getIdentifier(resource); List<Permission> existingPermissions = listPermissions(context, new IdentityPermission(resource, assignee, null)); if (existingPermissions.isEmpty()) { List<FilePermission> permissions = filePartition.getPermissions().get(assignee.getId()); if (permissions == null) { permissions = new ArrayList<FilePermission>(); filePartition.getPermissions().put(assignee.getId(), permissions); } FilePermission filePermission = new FilePermission(assignee, new IdentityPermission(resourceClass, resourceIdentifier .toString(), assignee, operation)); permissions.add(filePermission); } else { Permission permission = existingPermissions.get(0); revokePermission(context, assignee, resource, null); String newOperations = PermissionUtil.addOperation(permission.getOperation(), operation); grantPermission(context, assignee, resource, newOperations); } this.fileDataSource.flushPermissions(filePartition); return true; }
@Override public boolean revokePermission(IdentityContext context, IdentityType assignee, Object resource, String operation) { Partition partition = assignee.getPartition(); FilePartition filePartition = resolve(partition.getClass(), partition.getName()); List<FilePermission> permissions = filePartition.getPermissions().get(assignee.getId()); Class resourceClass = context.getPermissionHandlerPolicy().getResourceClass(resource); Serializable resourceIdentifier = context.getPermissionHandlerPolicy().getIdentifier(resource); if (permissions != null) { for (FilePermission filePermission : new ArrayList<FilePermission>(permissions)) { Permission permission = filePermission.getEntry(); if (hasAttributes(permission, resourceClass, resourceIdentifier, operation)) { String newOperations = PermissionUtil.removeOperation(permission.getOperation(), operation); permissions.remove(filePermission); if (operation != null && !isNullOrEmpty(newOperations)) { grantPermission(context, assignee, resource, newOperations); } } } } return false; }
@Override public boolean revokePermission(IdentityContext context, IdentityType assignee, Object resource, String operation) { Partition partition = assignee.getPartition(); FilePartition filePartition = resolve(partition.getClass(), partition.getName()); List<FilePermission> permissions = filePartition.getPermissions().get(assignee.getId()); Class resourceClass = context.getPermissionHandlerPolicy().getResourceClass(resource); Serializable resourceIdentifier = context.getPermissionHandlerPolicy().getIdentifier(resource); if (permissions != null) { for (FilePermission filePermission : new ArrayList<FilePermission>(permissions)) { Permission permission = filePermission.getEntry(); if (hasAttributes(permission, resourceClass, resourceIdentifier, operation)) { String newOperations = PermissionUtil.removeOperation(permission.getOperation(), operation); permissions.remove(filePermission); if (operation != null && !isNullOrEmpty(newOperations)) { grantPermission(context, assignee, resource, newOperations); } } } } return false; }
for (IdentityType storedType: result) { if (property.getValue(storedType).equals(property.getValue(identityType))) { throw MESSAGES.identityTypeAlreadyExists(identityType.getClass(), identityType.getId(), identityType.getPartition());