@Override public void setup(FileIdentityStoreConfiguration configuration) { super.setup(configuration); this.fileDataSource = new FileDataSource(configuration); }
void flushPartitions() { flush(PARTITIONS_FILE_NAME, getPartitions()); }
private void storeRelationshipType(Relationship relationship) { String type = relationship.getClass().getName(); Map<String, FileRelationship> storedRelationships = this.fileDataSource.getRelationships().get(type); if (storedRelationships == null) { storedRelationships = new ConcurrentHashMap<String, FileRelationship>(); this.fileDataSource.getRelationships().put(type, storedRelationships); } storedRelationships.put(relationship.getId(), new FileRelationship(relationship)); this.fileDataSource.flushRelationships(); }
void flushAttributes() { flush(ATTRIBUTES_FILE_NAME, getAttributes()); }
void flushRelationships() { flush(RELATIONSHIPS_FILE_NAME, getRelationships()); }
@Override public void removeAttributedType(IdentityContext context, AttributedType attributedType) { if (IdentityType.class.isInstance(attributedType)) { IdentityType identityType = (IdentityType) attributedType; Partition partition = identityType.getPartition(); FilePartition filePartition = resolve(partition.getClass(), partition.getName()); Map<String, FileIdentityType> identityTypes = filePartition.getIdentityTypes().get(attributedType.getClass().getName()); if (identityTypes != null) { identityTypes.remove(identityType.getId()); } this.fileDataSource.flushAttributedTypes(filePartition); } else if (Relationship.class.isInstance(attributedType)) { Map<String, FileRelationship> fileRelationships = this.fileDataSource.getRelationships() .get(attributedType.getClass().getName()); for (FileRelationship fileRelationship : new HashMap<String, FileRelationship>(fileRelationships).values()) { if (fileRelationship.getId().equals(attributedType.getId())) { fileRelationships.remove(fileRelationship.getId()); } } this.fileDataSource.flushRelationships(); } else { this.fileDataSource.getAttributedTypes().remove(attributedType.getId()); this.fileDataSource.flushAttributedTypes(); } }
@Override public void remove(IdentityContext identityContext, Partition partition) { FilePartition filePartition = resolve(partition.getClass(), partition.getName()); this.fileDataSource.getPartitions().remove(filePartition.getId()); this.fileDataSource.flushPartitions(); }
void flushPartitions(FilePartition partition) { initPartition(partition.getId()); flush(PARTITIONS_FILE_NAME, getPartitions()); }
@Override public void doSetAttribute(IdentityContext context, AttributedType type, Attribute<? extends Serializable> attribute) { FileAttribute fileAttribute = getFileAttribute(type); if (fileAttribute == null) { fileAttribute = new FileAttribute(type); } removeAttribute(context, type, attribute.getName()); fileAttribute.getEntry().add(attribute); this.fileDataSource.getAttributes().put(type.getId(), fileAttribute); this.fileDataSource.flushAttributes(); }
void flushAttributedTypes() { flush(ATTRIBUTED_TYPES__FILE_NAME, getAttributedTypes()); }
private void flushCredentials(Partition partition) { this.fileDataSource.flushCredentials(resolve(partition.getClass(), partition.getName())); }
private void flush(final FilePartition partition, final String fileName, final Object object) { flush(partition.getId() + File.separator + fileName, object); }
@Override public void revokeAllPermissions(IdentityContext context, Object resource) { Partition partition = context.getPartition(); FilePartition filePartition = resolve(partition.getClass(), partition.getName()); Collection<List<FilePermission>> allPermissions = filePartition.getPermissions().values(); Class resourceClass = context.getPermissionHandlerPolicy().getResourceClass(resource); Serializable resourceIdentifier = context.getPermissionHandlerPolicy().getIdentifier(resource); if (allPermissions != null) { for (List<FilePermission> permissions : allPermissions) { for (FilePermission filePermission : new ArrayList<FilePermission>(permissions)) { Permission permission = filePermission.getEntry(); if (hasAttributes(permission, resourceClass, resourceIdentifier, null)) { permissions.remove(filePermission); } } } this.fileDataSource.flushPermissions(filePartition); } }
private void storeIdentityType(IdentityContext context, IdentityType identityType) { FilePartition filePartition = resolve(context.getPartition().getClass(), context.getPartition().getName()); Map<String, FileIdentityType> identityTypes = filePartition.getIdentityTypes().get(identityType.getClass().getName()); if (identityTypes == null) { identityTypes = new ConcurrentHashMap<String, FileIdentityType>(); filePartition.getIdentityTypes().put(identityType.getClass().getName(), identityTypes); } identityTypes.put(identityType.getId(), new FileIdentityType(identityType)); this.fileDataSource.flushAttributedTypes(filePartition); }
@Override public void removeAttribute(IdentityContext context, AttributedType type, String attributeName) { FileAttribute fileAttribute = getFileAttribute(type); if (fileAttribute != null) { for (Attribute<? extends Serializable> attribute : new ArrayList<Attribute<? extends Serializable>> (fileAttribute.getEntry())) { if (attribute.getName().equals(attributeName)) { fileAttribute.getEntry().remove(attribute); } } } this.fileDataSource.flushAttributes(); }
@Override public void addAttributedType(IdentityContext context, final AttributedType attributedType) { AttributedType clonedAttributedType = cloneAttributedType(context, attributedType); if (IdentityType.class.isInstance(clonedAttributedType)) { storeIdentityType(context, (IdentityType) clonedAttributedType); } else if (Relationship.class.isInstance(clonedAttributedType)) { storeRelationshipType((Relationship) clonedAttributedType); } else { this.fileDataSource.getAttributedTypes().put(attributedType.getId(), new FileAttributedType(attributedType)); } }
private FileAttribute getFileAttribute(final AttributedType type) { return this.fileDataSource.getAttributes().get(type.getId()); }
@Override public void removeAttributedType(IdentityContext context, AttributedType attributedType) { if (IdentityType.class.isInstance(attributedType)) { IdentityType identityType = (IdentityType) attributedType; Partition partition = identityType.getPartition(); FilePartition filePartition = resolve(partition.getClass(), partition.getName()); Map<String, FileIdentityType> identityTypes = filePartition.getIdentityTypes().get(attributedType.getClass().getName()); if (identityTypes != null) { identityTypes.remove(identityType.getId()); } this.fileDataSource.flushAttributedTypes(filePartition); } else if (Relationship.class.isInstance(attributedType)) { Map<String, FileRelationship> fileRelationships = this.fileDataSource.getRelationships() .get(attributedType.getClass().getName()); for (FileRelationship fileRelationship : new HashMap<String, FileRelationship>(fileRelationships).values()) { if (fileRelationship.getId().equals(attributedType.getId())) { fileRelationships.remove(fileRelationship.getId()); } } this.fileDataSource.flushRelationships(); } else { this.fileDataSource.getAttributedTypes().remove(attributedType.getId()); this.fileDataSource.flushAttributedTypes(); } }
@Override public void remove(IdentityContext identityContext, Partition partition) { FilePartition filePartition = resolve(partition.getClass(), partition.getName()); this.fileDataSource.getPartitions().remove(filePartition.getId()); this.fileDataSource.flushPartitions(); }
void flushPartitions(FilePartition partition) { initPartition(partition.getId()); flush(PARTITIONS_FILE_NAME, getPartitions()); }