use of org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider in project jackrabbit-oak by apache.
the class SystemUserImplTest method getSecurityConfigParameters.
@Override
protected ConfigurationParameters getSecurityConfigParameters() {
return ConfigurationParameters.of(UserConfiguration.NAME, ConfigurationParameters.of(UserConstants.PARAM_AUTHORIZABLE_ACTION_PROVIDER, new AuthorizableActionProvider() {
@Nonnull
@Override
public List<? extends AuthorizableAction> getAuthorizableActions(@Nonnull SecurityProvider securityProvider) {
AuthorizableAction action = new AccessControlAction();
action.init(securityProvider, ConfigurationParameters.of(AccessControlAction.USER_PRIVILEGE_NAMES, new String[] { PrivilegeConstants.JCR_ALL }));
return ImmutableList.of(action);
}
}));
}
use of org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider in project jackrabbit-oak by apache.
the class WhiteboardAuthorizableActionProviderTest method testRegisteredImplementation.
@Test
public void testRegisteredImplementation() {
actionProvider.start(whiteboard);
AuthorizableActionProvider registered = new AuthorizableActionProvider() {
@Nonnull
@Override
public List<? extends AuthorizableAction> getAuthorizableActions(@Nonnull SecurityProvider securityProvider) {
return ImmutableList.of(new TestAction());
}
};
whiteboard.register(AuthorizableActionProvider.class, registered, ImmutableMap.of());
List<? extends AuthorizableAction> actions = actionProvider.getAuthorizableActions(Mockito.mock(SecurityProvider.class));
assertNotNull(actions);
assertEquals(1, actions.size());
assertTrue(actions.get(0) instanceof TestAction);
}
use of org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider in project jackrabbit-oak by apache.
the class PasswordExpiryHistoryTest method getSecurityConfigParameters.
@Override
protected ConfigurationParameters getSecurityConfigParameters() {
final PasswordValidationAction pwAction = new PasswordValidationAction();
pwAction.init(null, ConfigurationParameters.of(PasswordValidationAction.CONSTRAINT, "^.*(?=.{4,}).*"));
final AuthorizableActionProvider actionProvider = new AuthorizableActionProvider() {
@Nonnull
@Override
public List<? extends AuthorizableAction> getAuthorizableActions(@Nonnull SecurityProvider securityProvider) {
return ImmutableList.of(pwAction);
}
};
ConfigurationParameters userConfig = ConfigurationParameters.of(ImmutableMap.of(UserConstants.PARAM_AUTHORIZABLE_ACTION_PROVIDER, actionProvider, UserConstants.PARAM_PASSWORD_MAX_AGE, 10, UserConstants.PARAM_PASSWORD_HISTORY_SIZE, 10));
return ConfigurationParameters.of(UserConfiguration.NAME, userConfig);
}
use of org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testUnbindMandatoryCandidate.
@Test
public void testUnbindMandatoryCandidate() {
registration.activate(context.bundleContext(), configWithRequiredServiceIds("actionProvider"));
registration.bindUserConfiguration(mockConfiguration(UserConfiguration.class));
AuthorizableActionProvider ap = Mockito.mock(AuthorizableActionProvider.class);
registration.bindAuthorizableActionProvider(ap, ImmutableMap.of(Constants.SERVICE_PID, "actionProvider"));
SecurityProvider service = context.getService(SecurityProvider.class);
assertNotNull(service);
registration.unbindAuthorizableActionProvider(ap, ImmutableMap.of(Constants.SERVICE_PID, "actionProvider"));
service = context.getService(SecurityProvider.class);
assertNull(service);
}
use of org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider in project jackrabbit-oak by apache.
the class SecurityProviderBuilder method with.
public SecurityProviderBuilder with(@Nonnull ConfigurationParameters configuration) {
authenticationParams = configuration.getConfigValue(AuthenticationConfiguration.NAME, EMPTY);
privilegeParams = configuration.getConfigValue(PrivilegeConfiguration.NAME, EMPTY);
if (configuration.contains(UserConfiguration.NAME)) {
userParams = configuration.getConfigValue(UserConfiguration.NAME, EMPTY);
} else {
AuthorizableActionProvider authorizableActionProvider = new DefaultAuthorizableActionProvider();
AuthorizableNodeName authorizableNodeName = AuthorizableNodeName.DEFAULT;
UserAuthenticationFactory userAuthenticationFactory = UserConfigurationImpl.getDefaultAuthenticationFactory();
userParams = ConfigurationParameters.of(ConfigurationParameters.of(UserConstants.PARAM_AUTHORIZABLE_ACTION_PROVIDER, authorizableActionProvider), ConfigurationParameters.of(UserConstants.PARAM_AUTHORIZABLE_NODE_NAME, authorizableNodeName), ConfigurationParameters.of(UserConstants.PARAM_USER_AUTHENTICATION_FACTORY, userAuthenticationFactory));
}
if (configuration.contains(AuthorizationConfiguration.NAME)) {
authorizationParams = configuration.getConfigValue(AuthorizationConfiguration.NAME, EMPTY);
} else {
RestrictionProvider restrictionProvider = new RestrictionProviderImpl();
authorizationParams = ConfigurationParameters.of(AccessControlConstants.PARAM_RESTRICTION_PROVIDER, restrictionProvider);
}
principalParams = configuration.getConfigValue(PrincipalConfiguration.NAME, EMPTY);
tokenParams = configuration.getConfigValue(TokenConfiguration.NAME, EMPTY);
return this;
}
Aggregations