Search in sources :

Example 11 with GuestCredentials

use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.

the class RepositoryTest method loginWithAttribute.

@Test
public void loginWithAttribute() throws RepositoryException {
    Session session = ((JackrabbitRepository) getRepository()).login(new GuestCredentials(), null, Collections.<String, Object>singletonMap(RepositoryImpl.REFRESH_INTERVAL, 42));
    String[] attributeNames = session.getAttributeNames();
    assertEquals(1, attributeNames.length);
    assertEquals(RepositoryImpl.REFRESH_INTERVAL, attributeNames[0]);
    assertEquals(42L, session.getAttribute(RepositoryImpl.REFRESH_INTERVAL));
    session.logout();
}
Also used : JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) JackrabbitRepository(org.apache.jackrabbit.api.JackrabbitRepository) GuestCredentials(javax.jcr.GuestCredentials) Session(javax.jcr.Session) Test(org.junit.Test)

Example 12 with GuestCredentials

use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.

the class RepositoryTest method loginInvalidWorkspace.

@Test(expected = NoSuchWorkspaceException.class)
public void loginInvalidWorkspace() throws RepositoryException {
    Repository repository = getRepository();
    repository.login(new GuestCredentials(), "invalid");
}
Also used : Repository(javax.jcr.Repository) JackrabbitRepository(org.apache.jackrabbit.api.JackrabbitRepository) GuestCredentials(javax.jcr.GuestCredentials) Test(org.junit.Test)

Example 13 with GuestCredentials

use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.

the class L2_AuthInfoTest method testGuestAuthInfo.

@Test
public void testGuestAuthInfo() throws LoginException, NoSuchWorkspaceException {
    contentSession = login(new GuestCredentials());
    AuthInfo authInfo = contentSession.getAuthInfo();
    // EXERCISE : fill in the expected id
    String expectedId = null;
    assertEquals(expectedId, authInfo.getUserID());
    // EXERCISE: create the set of expected principals.
    // EXERCISE: what are the variants you have at hand when using the Jackrabbit API
    // EXERCISE: what are the variants you have at hand when using public Oak SPI interfaces?
    Set<Principal> expectedPrincipals = null;
    assertEquals(expectedPrincipals, authInfo.getPrincipals());
}
Also used : AuthInfo(org.apache.jackrabbit.oak.api.AuthInfo) GuestCredentials(javax.jcr.GuestCredentials) Principal(java.security.Principal) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 14 with GuestCredentials

use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.

the class L3_LoginModuleTest method testLogin.

@Test
public void testLogin() throws LoginException, NoSuchWorkspaceException, IOException {
    ContentSession contentSession = login(new GuestCredentials());
    contentSession.close();
}
Also used : ContentSession(org.apache.jackrabbit.oak.api.ContentSession) GuestCredentials(javax.jcr.GuestCredentials) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 15 with GuestCredentials

use of javax.jcr.GuestCredentials in project jackrabbit-oak by apache.

the class LoginModuleImplTest method testGuestLogin.

@Test
public void testGuestLogin() throws Exception {
    try (ContentSession cs = login(new GuestCredentials())) {
        AuthInfo authInfo = cs.getAuthInfo();
        String anonymousID = UserUtil.getAnonymousId(getUserConfiguration().getParameters());
        assertEquals(anonymousID, authInfo.getUserID());
    }
}
Also used : AuthInfo(org.apache.jackrabbit.oak.api.AuthInfo) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) GuestCredentials(javax.jcr.GuestCredentials) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

GuestCredentials (javax.jcr.GuestCredentials)39 Test (org.junit.Test)25 SimpleCredentials (javax.jcr.SimpleCredentials)13 Credentials (javax.jcr.Credentials)12 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)12 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)10 Session (javax.jcr.Session)8 LoginException (javax.security.auth.login.LoginException)7 TokenCredentials (org.apache.jackrabbit.api.security.authentication.token.TokenCredentials)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Subject (javax.security.auth.Subject)4 AuthInfo (org.apache.jackrabbit.oak.api.AuthInfo)4 ImpersonationCredentials (org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials)4 ArrayList (java.util.ArrayList)3 Repository (javax.jcr.Repository)3 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)3 Map (java.util.Map)2 RepositoryException (javax.jcr.RepositoryException)2 AccessControlManager (javax.jcr.security.AccessControlManager)2