Search in sources :

Example 1 with AuthorizableActionProvider

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);
        }
    }));
}
Also used : AccessControlAction(org.apache.jackrabbit.oak.spi.security.user.action.AccessControlAction) Nonnull(javax.annotation.Nonnull) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) AuthorizableAction(org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableAction) AuthorizableActionProvider(org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider)

Example 2 with AuthorizableActionProvider

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);
}
Also used : Nonnull(javax.annotation.Nonnull) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) AuthorizableActionProvider(org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider) Test(org.junit.Test)

Example 3 with AuthorizableActionProvider

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);
}
Also used : PasswordValidationAction(org.apache.jackrabbit.oak.spi.security.user.action.PasswordValidationAction) Nonnull(javax.annotation.Nonnull) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) AuthorizableActionProvider(org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)

Example 4 with AuthorizableActionProvider

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);
}
Also used : SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) AuthorizableActionProvider(org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider) UserConfiguration(org.apache.jackrabbit.oak.spi.security.user.UserConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 5 with AuthorizableActionProvider

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;
}
Also used : UserAuthenticationFactory(org.apache.jackrabbit.oak.spi.security.user.UserAuthenticationFactory) RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) DefaultAuthorizableActionProvider(org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider) AuthorizableActionProvider(org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider) DefaultAuthorizableActionProvider(org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider) AuthorizableNodeName(org.apache.jackrabbit.oak.spi.security.user.AuthorizableNodeName) RestrictionProviderImpl(org.apache.jackrabbit.oak.security.authorization.restriction.RestrictionProviderImpl)

Aggregations

AuthorizableActionProvider (org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider)5 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)4 Nonnull (javax.annotation.Nonnull)3 Test (org.junit.Test)2 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)1 RestrictionProviderImpl (org.apache.jackrabbit.oak.security.authorization.restriction.RestrictionProviderImpl)1 ConfigurationParameters (org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)1 RestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider)1 AuthorizableNodeName (org.apache.jackrabbit.oak.spi.security.user.AuthorizableNodeName)1 UserAuthenticationFactory (org.apache.jackrabbit.oak.spi.security.user.UserAuthenticationFactory)1 UserConfiguration (org.apache.jackrabbit.oak.spi.security.user.UserConfiguration)1 AccessControlAction (org.apache.jackrabbit.oak.spi.security.user.action.AccessControlAction)1 AuthorizableAction (org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableAction)1 DefaultAuthorizableActionProvider (org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider)1 PasswordValidationAction (org.apache.jackrabbit.oak.spi.security.user.action.PasswordValidationAction)1