Search in sources :

Example 31 with SecurityProvider

use of org.apache.jackrabbit.oak.spi.security.SecurityProvider in project jackrabbit-oak by apache.

the class AbstractLoginModuleTest method testGetSecurityProvider.

@Test
public void testGetSecurityProvider() {
    AbstractLoginModule loginModule = initLoginModule(TestCredentials.class, new TestCallbackHandler(null, new OpenSecurityProvider(), null));
    SecurityProvider securityProvider = loginModule.getSecurityProvider();
    assertNotNull(securityProvider);
    // securityProvider is stored as field -> second access returns the same object
    assertSame(securityProvider, loginModule.getSecurityProvider());
}
Also used : SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Test(org.junit.Test)

Example 32 with SecurityProvider

use of org.apache.jackrabbit.oak.spi.security.SecurityProvider in project jackrabbit-oak by apache.

the class SecurityProviderCallbackTest method testCallback.

@Test
public void testCallback() {
    SecurityProviderCallback cb = new SecurityProviderCallback();
    SecurityProvider sp = new OpenSecurityProvider();
    cb.setSecurityProvider(sp);
    assertSame(sp, cb.getSecurityProvider());
}
Also used : OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Test(org.junit.Test)

Example 33 with SecurityProvider

use of org.apache.jackrabbit.oak.spi.security.SecurityProvider in project jackrabbit-oak by apache.

the class ImportIgnoreTest method before.

@Before
public void before() throws Exception {
    String importBehavior = getImportBehavior();
    SecurityProvider securityProvider;
    if (importBehavior != null) {
        Map<String, String> params = new HashMap<String, String>();
        params.put(ProtectedItemImporter.PARAM_IMPORT_BEHAVIOR, getImportBehavior());
        ConfigurationParameters config = ConfigurationParameters.of(AuthorizationConfiguration.NAME, ConfigurationParameters.of(params));
        securityProvider = new SecurityProviderImpl(config);
    } else {
        securityProvider = new SecurityProviderImpl();
    }
    QueryEngineSettings queryEngineSettings = new QueryEngineSettings();
    queryEngineSettings.setFailTraversal(true);
    Jcr jcr = new Jcr();
    jcr.with(securityProvider);
    jcr.with(queryEngineSettings);
    repo = jcr.createRepository();
    adminSession = repo.login(new SimpleCredentials(UserConstants.DEFAULT_ADMIN_ID, UserConstants.DEFAULT_ADMIN_ID.toCharArray()));
    target = adminSession.getRootNode().addNode("nodeName1");
    target.addMixin("rep:AccessControllable");
    adminSession.save();
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) HashMap(java.util.HashMap) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) SecurityProviderImpl(org.apache.jackrabbit.oak.security.SecurityProviderImpl) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) Before(org.junit.Before)

Aggregations

SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)33 Test (org.junit.Test)19 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)15 Root (org.apache.jackrabbit.oak.api.Root)8 Nonnull (javax.annotation.Nonnull)6 ConfigurationParameters (org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)6 WhiteboardRestrictionProvider (org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider)5 AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)5 RestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider)5 UserConfiguration (org.apache.jackrabbit.oak.spi.security.user.UserConfiguration)5 AuthorizableActionProvider (org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider)5 CheckForNull (javax.annotation.CheckForNull)4 AuthorizationConfigurationImpl (org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 SimpleCredentials (javax.jcr.SimpleCredentials)3 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)3 UserManager (org.apache.jackrabbit.api.security.user.UserManager)3 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)3 SecurityProviderImpl (org.apache.jackrabbit.oak.security.SecurityProviderImpl)3