Search in sources :

Example 91 with Authorizable

use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.

the class DefaultSyncContextTest method testCreateSyncedIdentitySyncedGroup.

@Test
public void testCreateSyncedIdentitySyncedGroup() throws Exception {
    ExternalIdentity externalGroup = idp.listGroups().next();
    sync(externalGroup);
    Authorizable a = userManager.getAuthorizable(externalGroup.getId());
    SyncedIdentity si = DefaultSyncContext.createSyncedIdentity(a);
    assertNotNull(si);
    assertEquals(a.getID(), si.getId());
    assertNotNull(si.getExternalIdRef());
    assertTrue(si.isGroup());
    assertEquals(syncCtx.now, si.lastSynced());
}
Also used : ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) SyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 92 with Authorizable

use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.

the class DefaultSyncHandlerTest method testRequiresSyncExpiredSyncProperty.

@Test
public void testRequiresSyncExpiredSyncProperty() throws Exception {
    login(new SimpleCredentials(USER_ID, new char[0])).close();
    root.refresh();
    final Calendar nowCal = Calendar.getInstance();
    nowCal.setTimeInMillis(nowCal.getTimeInMillis() - 1000);
    Value nowValue = getValueFactory().createValue(nowCal);
    Authorizable a = userManager.getAuthorizable(USER_ID);
    a.setProperty(DefaultSyncContext.REP_LAST_SYNCED, nowValue);
    root.commit();
    SyncedIdentity id = syncHandler.findIdentity(userManager, USER_ID);
    assertNotNull("known authorizable should exist", id);
    assertTrue("synced id should require sync", syncHandler.requiresSync(id));
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) Calendar(java.util.Calendar) Value(javax.jcr.Value) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) DefaultSyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity) SyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity) Test(org.junit.Test)

Example 93 with Authorizable

use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.

the class DefaultSyncHandlerTest method testRequiresSyncMissingSyncProperty.

@Test
public void testRequiresSyncMissingSyncProperty() throws Exception {
    sync(USER_ID, false);
    Authorizable a = userManager.getAuthorizable(USER_ID);
    a.removeProperty(DefaultSyncContext.REP_LAST_SYNCED);
    root.commit();
    SyncedIdentity si = syncHandler.findIdentity(userManager, USER_ID);
    assertNotNull(si);
    assertTrue(syncHandler.requiresSync(si));
}
Also used : Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) DefaultSyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity) SyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity) Test(org.junit.Test)

Example 94 with Authorizable

use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.

the class DefaultSyncContextTest method testSyncPropertiesMappingConstants.

@Test
public void testSyncPropertiesMappingConstants() throws Exception {
    ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_SECOND_USER);
    sync(externalUser);
    Authorizable a = userManager.getAuthorizable(externalUser.getId());
    // create mapping that doesn't match to names in the external-properties
    // -> previously synced properties must be removed
    Map<String, String> mapping = new HashMap();
    Map<String, ?> extProps = externalUser.getProperties();
    for (String propName : extProps.keySet()) {
        mapping.put(propName, "\"any\"");
    }
    syncCtx.syncProperties(externalUser, a, mapping);
    Value anyValue = valueFactory.createValue("any");
    for (String propName : extProps.keySet()) {
        assertTrue(a.hasProperty(propName));
        assertEquals(anyValue, a.getProperty(propName)[0]);
    }
}
Also used : HashMap(java.util.HashMap) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Value(javax.jcr.Value) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 95 with Authorizable

use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.

the class DefaultSyncContextTest method testCreateSyncedIdentitySyncedUser.

@Test
public void testCreateSyncedIdentitySyncedUser() throws Exception {
    ExternalIdentity externalUser = idp.listUsers().next();
    sync(externalUser);
    Authorizable a = userManager.getAuthorizable(externalUser.getId());
    SyncedIdentity si = DefaultSyncContext.createSyncedIdentity(a);
    assertNotNull(si);
    assertEquals(a.getID(), si.getId());
    assertNotNull(si.getExternalIdRef());
    assertFalse(si.isGroup());
    assertEquals(syncCtx.now, si.lastSynced());
}
Also used : ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) SyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Aggregations

Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)466 Test (org.junit.Test)254 User (org.apache.jackrabbit.api.security.user.User)104 Group (org.apache.jackrabbit.api.security.user.Group)101 UserManager (org.apache.jackrabbit.api.security.user.UserManager)93 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)64 Principal (java.security.Principal)58 Node (javax.jcr.Node)55 RepositoryException (javax.jcr.RepositoryException)55 Query (org.apache.jackrabbit.api.security.user.Query)50 Session (javax.jcr.Session)49 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)45 Value (javax.jcr.Value)29 NodeImpl (org.apache.jackrabbit.core.NodeImpl)29 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)28 ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)24 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)24 SimpleCredentials (javax.jcr.SimpleCredentials)21 HashMap (java.util.HashMap)18 QueryBuilder (org.apache.jackrabbit.api.security.user.QueryBuilder)16