use of org.apache.jackrabbit.oak.spi.security.SecurityProvider in project jackrabbit-oak by apache.
the class SecurityProviderRegistration method maybeRegister.
private void maybeRegister() {
BundleContext context;
log.info("Trying to register a SecurityProvider...");
synchronized (this) {
if (this.context == null) {
log.info("Aborting: no BundleContext is available");
return;
}
if (!preconditions.areSatisfied()) {
log.info("Aborting: preconditions are not satisfied: {}", preconditions);
return;
}
if (registration != null) {
log.info("Aborting: a SecurityProvider is already registered");
return;
}
if (registering) {
log.info("Aborting: a SecurityProvider is already being registered");
return;
}
// Mark the start of a registration process.
registering = true;
// Save the BundleContext for local usage.
context = this.context;
}
// Register the SecurityProvider.
Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put("type", "default");
ServiceRegistration registration = context.registerService(SecurityProvider.class.getName(), createSecurityProvider(context), properties);
synchronized (this) {
this.registration = registration;
this.registering = false;
}
log.info("SecurityProvider instance registered");
}
use of org.apache.jackrabbit.oak.spi.security.SecurityProvider 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.SecurityProvider 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.SecurityProvider 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.SecurityProvider in project jackrabbit-oak by apache.
the class DefaultAuthorizableActionProviderTest method getSecurityProvider.
private SecurityProvider getSecurityProvider() {
AuthorizationConfiguration ac = Mockito.mock(AuthorizationConfiguration.class);
when(ac.getParameters()).thenReturn(ConfigurationParameters.EMPTY);
SecurityProvider sp = Mockito.mock(SecurityProvider.class);
when(sp.getConfiguration(AuthorizationConfiguration.class)).thenReturn(ac);
return sp;
}
Aggregations