@Override public String getConfigurationName(IdentityContext identityContext, Partition partition) { FilePartition filePartition = resolve(partition.getClass(), partition.getName()); if (isNullOrEmpty(filePartition.getConfigurationName())) { throw MESSAGES.partitionWithNoConfigurationName(partition); } return filePartition.getConfigurationName(); }
void flushCredentials(FilePartition partition) { FilePartition filePartition = getPartitions().get(partition.getId()); flush(filePartition, CREDENTIALS_FILE_NAME, filePartition.getCredentials()); }
@Override public <P extends Partition> P lookupById(final IdentityContext context, final Class<P> partitionClass, final String id) { FilePartition filePartition = this.fileDataSource.getPartitions().get(id); if (filePartition != null && partitionClass.isInstance(filePartition.getEntry())) { return (P) cloneAttributedType(context, filePartition.getEntry()); } return null; }
void flushPermissions(FilePartition partition) { FilePartition filePartition = getPartitions().get(partition.getId()); flush(filePartition, PERMISSIONS_FILE_NAME, filePartition.getPermissions()); }
FILE_STORE_LOGGER.debugf("Initializing Partition [%s] with id [%s].", filePartition.getEntry().getName(), partitionId); filePartition.setIdentityTypes(identityTypes); FILE_STORE_LOGGER.debugf("Loaded Identity Types [%s] for Partition [%s].", filePartition.getIdentityTypes().size(), filePartition.getId()); filePartition.setCredentials(credentials); FILE_STORE_LOGGER.debugf("Loaded Credentials [%s] for Partition [%s].", filePartition.getCredentials().size(), filePartition.getId()); filePartition.setPermissions(permissions); FILE_STORE_LOGGER.debugf("Loaded Permissions [%s] for Partition [%s].", filePartition.getPermissions().size(), filePartition.getId());
void flushAttributedTypes(FilePartition partition) { flush(partition, IDENTITY_TYPES__FILE_NAME, partition.getIdentityTypes()); }
@Override public void add(IdentityContext identityContext, Partition partition, String configurationName) { partition.setId(identityContext.getIdGenerator().generate()); FilePartition filePartition = new FilePartition(cloneAttributedType(identityContext, partition), configurationName); this.fileDataSource.getPartitions().put(filePartition.getId(), filePartition); this.fileDataSource.flushPartitions(filePartition); }
@Override public void update(IdentityContext identityContext, Partition partition) { FilePartition filePartition = resolve(partition.getClass(), partition.getName()); this.fileDataSource.getPartitions().put(partition.getId(), new FilePartition(cloneAttributedType(identityContext, partition), filePartition.getConfigurationName())); this.fileDataSource.flushPartitions(); }
@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 flush(final FilePartition partition, final String fileName, final Object object) { flush(partition.getId() + File.separator + fileName, object); }
private List<FileCredentialStorage> getCredentials(Account account, Class<? extends CredentialStorage> storageType) { Partition partition = account.getPartition(); FilePartition filePartition = resolve(partition.getClass(), partition.getName()); Map<String, List<FileCredentialStorage>> agentCredentials = filePartition.getCredentials().get(account.getId()); if (agentCredentials == null) { agentCredentials = new ConcurrentHashMap<String, List<FileCredentialStorage>>(); this.fileDataSource.getPartitions().get(partition.getId()).getCredentials().put(account.getId(), agentCredentials); } List<FileCredentialStorage> credentials = agentCredentials.get(storageType.getName()); if (credentials == null) { credentials = Collections.synchronizedList(new ArrayList<FileCredentialStorage>()); } agentCredentials.put(storageType.getName(), credentials); return credentials; }
@Override protected Partition doCreateInstance(Map<String, Serializable> properties) throws Exception { String name = properties.get("name").toString(); return (Partition) Class.forName(getType()).getConstructor(String.class).newInstance(name); }
FILE_STORE_LOGGER.debugf("Initializing Partition [%s] with id [%s].", filePartition.getEntry().getName(), partitionId); filePartition.setIdentityTypes(identityTypes); FILE_STORE_LOGGER.debugf("Loaded Identity Types [%s] for Partition [%s].", filePartition.getIdentityTypes().size(), filePartition.getId()); filePartition.setCredentials(credentials); FILE_STORE_LOGGER.debugf("Loaded Credentials [%s] for Partition [%s].", filePartition.getCredentials().size(), filePartition.getId()); filePartition.setPermissions(permissions); FILE_STORE_LOGGER.debugf("Loaded Permissions [%s] for Partition [%s].", filePartition.getPermissions().size(), filePartition.getId());
void flushAttributedTypes(FilePartition partition) { flush(partition, IDENTITY_TYPES__FILE_NAME, partition.getIdentityTypes()); }
@Override public void add(IdentityContext identityContext, Partition partition, String configurationName) { partition.setId(identityContext.getIdGenerator().generate()); FilePartition filePartition = new FilePartition(cloneAttributedType(identityContext, partition), configurationName); this.fileDataSource.getPartitions().put(filePartition.getId(), filePartition); this.fileDataSource.flushPartitions(filePartition); }
@Override public void update(IdentityContext identityContext, Partition partition) { FilePartition filePartition = resolve(partition.getClass(), partition.getName()); this.fileDataSource.getPartitions().put(partition.getId(), new FilePartition(cloneAttributedType(identityContext, partition), filePartition.getConfigurationName())); this.fileDataSource.flushPartitions(); }
void flushPermissions(FilePartition partition) { FilePartition filePartition = getPartitions().get(partition.getId()); flush(filePartition, PERMISSIONS_FILE_NAME, filePartition.getPermissions()); }
@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 flush(final FilePartition partition, final String fileName, final Object object) { flush(partition.getId() + File.separator + fileName, object); }
private List<FileCredentialStorage> getCredentials(Account account, Class<? extends CredentialStorage> storageType) { Partition partition = account.getPartition(); FilePartition filePartition = resolve(partition.getClass(), partition.getName()); Map<String, List<FileCredentialStorage>> agentCredentials = filePartition.getCredentials().get(account.getId()); if (agentCredentials == null) { agentCredentials = new ConcurrentHashMap<String, List<FileCredentialStorage>>(); this.fileDataSource.getPartitions().get(partition.getId()).getCredentials().put(account.getId(), agentCredentials); } List<FileCredentialStorage> credentials = agentCredentials.get(storageType.getName()); if (credentials == null) { credentials = Collections.synchronizedList(new ArrayList<FileCredentialStorage>()); } agentCredentials.put(storageType.getName(), credentials); return credentials; }