private <T extends Partition> void loadAttributes(final IdentityContext context, final T partition) { AttributeStore<?> attributeStore = getStoreSelector().getStoreForAttributeOperation(context); if (attributeStore != null) { attributeStore.loadAttributes(context, partition); } }
@Override protected void doAdd(IdentityType attributedType) { IdentityContext identityContext = getIdentityContext(); IdentityStore identityStore = getStoreSelector().getStoreForIdentityOperation(identityContext, IdentityStore.class, attributedType.getClass(), IdentityOperation.create); identityStore.add(identityContext, attributedType); configureDefaultPartition(identityContext, attributedType, identityStore, this.partitionManager); }
@Override protected void doUpdate(Partition attributedType) { checkPartitionManagementSupported(); IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForPartitionOperation(identityContext, attributedType.getClass()).update(identityContext, attributedType); }
@Override public void revokePermission(IdentityType assignee, Class<?> resourceclass, String operation) { try { storeSelector.getStoreForPermissionOperation(this.identityContext).revokePermission(this.identityContext, assignee, resourceclass, operation); } catch (Exception ex) { throw MESSAGES.permissionRevokeFailed(assignee, resourceclass, operation, ex); } }
@Override public void validateCredentials(Credentials credentials) { if (credentials == null) { throw MESSAGES.nullArgument("Credentials"); } try { IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForCredentialOperation(identityContext, credentials.getClass()).validateCredentials(identityContext, credentials); } catch (Exception e) { throw MESSAGES.credentialValidationFailed(credentials, e); } }
@Override public List<T> getResultList() { // remove this statement once deprecated methods on IdentityQuery are removed if (this.sortParameters != null) { for (QueryParameter parameter : this.sortParameters) { if (isSortAscending()) { sortBy(this.queryBuilder.asc(parameter)); } else { sortBy(this.queryBuilder.desc(parameter)); } } } List<T> result = new ArrayList<T>(); try { Set<IdentityStore<?>> identityStores = this.storeSelector.getStoresForIdentityQuery(this.context, this.getIdentityType()); AttributeStore<?> attributeStore = this.storeSelector.getStoreForAttributeOperation(context); for (IdentityStore<?> store : identityStores) { for (T identityType : store.fetchQueryResults(this.context, this)) { configureDefaultPartition(this.context, identityType, store, this.partitionManager); if (attributeStore != null) { attributeStore.loadAttributes(this.context, identityType); } result.add(identityType); } } } catch (Exception e) { throw MESSAGES.queryIdentityTypeFailed(this, e); } return result; }
@Override protected void doAdd(Relationship relationship) { IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForRelationshipOperation(identityContext, relationship.getClass(), relationship, IdentityOperation.create) .add(identityContext, relationship); }
@Override public <T extends CredentialStorage> List<T> retrieveCredentials(Account account, Class<T> storageClass) { checkIfExists(account); if (storageClass == null) { throw MESSAGES.nullArgument("CredentialStorage type"); } List<T> storages = new ArrayList<T>(); try { IdentityContext identityContext = getIdentityContext(); for (CredentialStore credentialStore : getStoreSelector().getStoresForCredentialStorage(identityContext, storageClass)) { storages.addAll(credentialStore.retrieveCredentials(identityContext, account, storageClass)); } } catch (Exception e) { throw MESSAGES.credentialRetrievalFailed(account, storageClass, e); } return storages; }
@Override public int getResultCount() { int count = 0; Set<IdentityStore<?>> identityStores = this.storeSelector.getStoresForIdentityQuery(this.context, this.getIdentityType()); for (IdentityStore<?> store : identityStores) { count = count + store.countQueryResults(this.context, this); } return count; }
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; } }
@Override public void clearPermissions(Object resource) { try { storeSelector.getStoreForPermissionOperation(this.identityContext).revokeAllPermissions(this.identityContext, resource); } catch (Exception ex) { throw MESSAGES.permissionRevokeAllFailed(resource, ex); } }
@Override public void validateCredentials(Credentials credentials) { if (credentials == null) { throw MESSAGES.nullArgument("Credentials"); } try { IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForCredentialOperation(identityContext, credentials.getClass()).validateCredentials(identityContext, credentials); } catch (Exception e) { throw MESSAGES.credentialValidationFailed(credentials, e); } }
@Override public List<T> getResultList() { // remove this statement once deprecated methods on IdentityQuery are removed if (this.sortParameters != null) { for (QueryParameter parameter : this.sortParameters) { if (isSortAscending()) { sortBy(this.queryBuilder.asc(parameter)); } else { sortBy(this.queryBuilder.desc(parameter)); } } } List<T> result = new ArrayList<T>(); try { Set<IdentityStore<?>> identityStores = this.storeSelector.getStoresForIdentityQuery(this.context, this.getIdentityType()); AttributeStore<?> attributeStore = this.storeSelector.getStoreForAttributeOperation(context); for (IdentityStore<?> store : identityStores) { for (T identityType : store.fetchQueryResults(this.context, this)) { configureDefaultPartition(this.context, identityType, store, this.partitionManager); if (attributeStore != null) { attributeStore.loadAttributes(this.context, identityType); } result.add(identityType); } } } catch (Exception e) { throw MESSAGES.queryIdentityTypeFailed(this, e); } return result; }
@Override protected void doRemove(Relationship relationship) { IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForRelationshipOperation(identityContext, relationship.getClass(), relationship, IdentityOperation.delete) .remove(identityContext, relationship); }
@Override public <T extends CredentialStorage> List<T> retrieveCredentials(Account account, Class<T> storageClass) { checkIfExists(account); if (storageClass == null) { throw MESSAGES.nullArgument("CredentialStorage type"); } List<T> storages = new ArrayList<T>(); try { IdentityContext identityContext = getIdentityContext(); for (CredentialStore credentialStore : getStoreSelector().getStoresForCredentialStorage(identityContext, storageClass)) { storages.addAll(credentialStore.retrieveCredentials(identityContext, account, storageClass)); } } catch (Exception e) { throw MESSAGES.credentialRetrievalFailed(account, storageClass, e); } return storages; }
@Override public int getResultCount() { int count = 0; Set<IdentityStore<?>> identityStores = this.storeSelector.getStoresForIdentityQuery(this.context, this.getIdentityType()); for (IdentityStore<?> store : identityStores) { count = count + store.countQueryResults(this.context, this); } return count; }
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; } }
@Override public void revokePermission(IdentityType assignee, Class<?> resourceclass, String operation) { try { storeSelector.getStoreForPermissionOperation(this.identityContext).revokePermission(this.identityContext, assignee, resourceclass, operation); } catch (Exception ex) { throw MESSAGES.permissionRevokeFailed(assignee, resourceclass, operation, ex); } }
@Override protected void doUpdate(Partition attributedType) { checkPartitionManagementSupported(); IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForPartitionOperation(identityContext, attributedType.getClass()).update(identityContext, attributedType); }
@Override public void updateCredential(Account account, Object credential, Date effectiveDate, Date expiryDate) { checkIfExists(account); if (credential == null) { throw MESSAGES.nullArgument("Credential"); } try { IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForCredentialOperation(identityContext, credential.getClass()).updateCredential(identityContext, account, credential, effectiveDate, expiryDate); fireEvent(new CredentialUpdatedEvent(account, credential, effectiveDate, expiryDate, this.partitionManager)); } catch (Exception e) { throw MESSAGES.credentialUpdateFailed(account, credential, e); } }