@Override public void revokeRole(IdentityType identityType, Role role) { getContextualStoreForFeature(createContext(), Feature.deleteMembership) .removeMembership(identityType, null, role); }
@Override public boolean hasGroupRole(IdentityType identityType, Role role, Group group) { return getContextualStoreForFeature(createContext(), Feature.readMembership) .getMembership(identityType, group, role) != null; }
@Override public void validateCredentials(Credentials credentials) { IdentityStore<?> store = getContextualStoreForFeature(createContext(), Feature.manageCredentials); store.validateCredentials(credentials); }
@Override public void updateCredential(Agent agent, Object credential, Date effectiveDate, Date expiryDate) { IdentityStore<?> store = getContextualStoreForFeature(createContext(), Feature.manageCredentials); store.updateCredential(agent, credential, effectiveDate, expiryDate); }
@Override public boolean hasRole(IdentityType identityType, Role role) { return getContextualStoreForFeature(createContext(), Feature.readMembership) .getMembership(identityType, null, role) != null; }
@Override public void grantRole(IdentityType identityType, Role role) { getContextualStoreForFeature(createContext(), Feature.createMembership) .createMembership(identityType, null, role); }
@Override public void grantGroupRole(IdentityType identityType, Role role, Group group) { getContextualStoreForFeature(createContext(), Feature.createMembership) .createMembership(identityType, group, role); }
@Override public void revokeGroupRole(IdentityType identityType, Role role, Group group) { getContextualStoreForFeature(createContext(), Feature.createMembership) .removeMembership(identityType, group, role); }
@Override public boolean isMember(IdentityType identityType, Group group) { return getContextualStoreForFeature(createContext(), Feature.readMembership).getMembership(identityType, group, null) != null; }
@Override public void removeFromGroup(IdentityType identityType, Group group) { getContextualStoreForFeature(createContext(), Feature.deleteMembership).removeMembership(identityType, group, null); }
@Override public void addToGroup(IdentityType identityType, Group group) { getContextualStoreForFeature(createContext(), Feature.createMembership).createMembership(identityType, group, null); }
@Override public User getUser(String id) { return getContextualStoreForFeature(createContext(), Feature.readUser).getUser(id); }
@Override public <T extends IdentityType> IdentityQuery<T> createQuery(Class<T> identityType) { return new DefaultIdentityQuery<T>(identityType, getContextualStoreForFeature(createContext(), Feature.readUser)); }
public Agent getAgent(String id) { return getContextualStoreForFeature(createContext(), Feature.readAgent).getAgent(id); }
@Override public void update(IdentityType identityType) { Feature feature; IdentityStoreInvocationContext ctx = createContext(); if (User.class.isInstance(identityType)) { feature = Feature.updateUser; } else if (Agent.class.isInstance(identityType)) { feature = Feature.updateAgent; } else if (Group.class.isInstance(identityType)) { if (ctx.getRealm() != null && ctx.getTier() != null) { throw new IllegalStateException("Ambiguous context state - Group may only be managed in either the " + "scope of a Realm or a Tier, however both have been set."); } feature = Feature.updateGroup; } else if (Role.class.isInstance(identityType)) { if (ctx.getRealm() != null && ctx.getTier() != null) { throw new IllegalStateException("Ambiguous context state - Role may only be managed in either the " + "scope of a Realm or a Tier, however both have been set."); } feature = Feature.updateRole; } else { throw new IllegalArgumentException("Unsupported IdentityType"); } getContextualStoreForFeature(createContext(), feature).update(identityType); }
@Override public Role getRole(String name) { IdentityStoreInvocationContext ctx = createContext(); if (ctx.getRealm() != null && ctx.getTier() != null) { throw new IllegalStateException("Ambiguous context state - Role may only be managed in either the " + "scope of a Realm or a Tier, however both have been set."); } return getContextualStoreForFeature(ctx, Feature.readRole).getRole(name); }
@Override public Group getGroup(String groupName, Group parent) { IdentityStoreInvocationContext ctx = createContext(); if (ctx.getRealm() != null && ctx.getTier() != null) { throw new IllegalStateException("Ambiguous context state - Group may only be managed in either the " + "scope of a Realm or a Tier, however both have been set."); } return getContextualStoreForFeature(ctx, Feature.readGroup).getGroup(groupName, parent); }
@Override public void add(IdentityType identityType) { Feature feature; IdentityStoreInvocationContext ctx = createContext(); if (User.class.isInstance(identityType)) { feature = Feature.createUser; } else if (Group.class.isInstance(identityType)) { if (ctx.getRealm() != null && ctx.getTier() != null) { throw new IllegalStateException("Ambiguous context state - Group may only be managed in either the " + "scope of a Realm or a Tier, however both have been set."); } feature = Feature.createGroup; } else if (Role.class.isInstance(identityType)) { if (ctx.getRealm() != null && ctx.getTier() != null) { throw new IllegalStateException("Ambiguous context state - Role may only be managed in either the " + "scope of a Realm or a Tier, however both have been set."); } feature = Feature.createRole; } else if (Agent.class.isInstance(identityType)) { feature = Feature.createAgent; } else if (Relationship.class.isInstance(identityType)) { feature = Feature.createAgent; } else { throw new IllegalArgumentException("Unsupported IdentityType:" + identityType.getClass().getName()); } getContextualStoreForFeature(ctx, feature).add(identityType); }
@Override public Group getGroup(String groupId) { IdentityStoreInvocationContext ctx = createContext(); if (ctx.getRealm() != null && ctx.getTier() != null) { throw new IllegalStateException("Ambiguous context state - Group may only be managed in either the " + "scope of a Realm or a Tier, however both have been set."); } return getContextualStoreForFeature(ctx, Feature.readGroup).getGroup(groupId); }
@Override public void remove(IdentityType identityType) { Feature feature; IdentityStoreInvocationContext ctx = createContext(); if (User.class.isInstance(identityType)) { feature = Feature.deleteUser; } else if (Agent.class.isInstance(identityType)) { feature = Feature.deleteAgent; } else if (Group.class.isInstance(identityType)) { if (ctx.getRealm() != null && ctx.getTier() != null) { throw new IllegalStateException("Ambiguous context state - Group may only be managed in either the " + "scope of a Realm or a Tier, however both have been set."); } feature = Feature.deleteGroup; } else if (Role.class.isInstance(identityType)) { if (ctx.getRealm() != null && ctx.getTier() != null) { throw new IllegalStateException("Ambiguous context state - Role may only be managed in either the " + "scope of a Realm or a Tier, however both have been set."); } feature = Feature.deleteRole; } else { throw new IllegalArgumentException("Unsupported IdentityType"); } getContextualStoreForFeature(ctx, feature).remove(identityType); }