@Override public Group getGroup(String identifier) throws AuthorizationAccessException { Group group = configurableUserGroupProvider.getGroup(identifier); if (group == null) { group = super.getGroup(identifier); } return group; }
@Override public Set<Group> getGroups() throws AuthorizationAccessException { final Set<Group> groups = new HashSet<>(configurableUserGroupProvider.getGroups()); groups.addAll(super.getGroups()); return groups; }
@Override public User getUser(String identifier) throws AuthorizationAccessException { User user = configurableUserGroupProvider.getUser(identifier); if (user == null) { user = super.getUser(identifier); } return user; }
UserAndGroups compositeProvidersResult = super.getUserAndGroups(identity); for (final Group group : super.getGroups()) { if (group.getUsers() != null && group.getUsers().contains(userIdentifier)) { combinedResult.addGroup(group);
@Override public Set<User> getUsers() throws AuthorizationAccessException { final Set<User> users = new HashSet<>(configurableUserGroupProvider.getUsers()); users.addAll(super.getUsers()); return users; }
@Override public void preDestruction() throws AuthorizerDestructionException { try { configurableUserGroupProvider.preDestruction(); } finally { super.preDestruction(); } } }
@Override public void initialize(UserGroupProviderInitializationContext initializationContext) throws AuthorizerCreationException { userGroupProviderLookup = initializationContext.getUserGroupProviderLookup(); // initialize the CompositeUserGroupProvider super.initialize(initializationContext); }
@Override public User getUserByIdentity(String identity) throws AuthorizationAccessException { User user = configurableUserGroupProvider.getUserByIdentity(identity); if (user == null) { user = super.getUserByIdentity(identity); } return user; }
@Override public void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException { final PropertyValue configurableUserGroupProviderKey = configurationContext.getProperty(PROP_CONFIGURABLE_USER_GROUP_PROVIDER); if (!configurableUserGroupProviderKey.isSet()) { throw new AuthorizerCreationException("The Configurable User Group Provider must be set."); } final UserGroupProvider userGroupProvider = userGroupProviderLookup.getUserGroupProvider(configurableUserGroupProviderKey.getValue()); if (userGroupProvider == null) { throw new AuthorizerCreationException(String.format("Unable to locate the Configurable User Group Provider: %s", configurableUserGroupProviderKey)); } if (!(userGroupProvider instanceof ConfigurableUserGroupProvider)) { throw new AuthorizerCreationException(String.format("The Configurable User Group Provider is not configurable: %s", configurableUserGroupProviderKey)); } // Ensure that the ConfigurableUserGroupProvider is not also listed as one of the providers for the CompositeUserGroupProvider for (Map.Entry<String, String> entry : configurationContext.getProperties().entrySet()) { Matcher matcher = USER_GROUP_PROVIDER_PATTERN.matcher(entry.getKey()); if (matcher.matches() && !StringUtils.isBlank(entry.getValue())) { final String userGroupProviderKey = entry.getValue(); if (userGroupProviderKey.equals(configurableUserGroupProviderKey.getValue())) { throw new AuthorizerCreationException(String.format("Duplicate provider in Composite Configurable User Group Provider configuration: %s", userGroupProviderKey)); } } } configurableUserGroupProvider = (ConfigurableUserGroupProvider) userGroupProvider; // configure the CompositeUserGroupProvider super.onConfigured(configurationContext); }