Search in sources :

Example 11 with AuthenticationInfo

use of org.apache.sling.auth.core.spi.AuthenticationInfo in project sling by apache.

the class AuthenticationInfoTest method testAuthenticationInfoStringString.

@Test
public void testAuthenticationInfoStringString() {
    final AuthenticationInfo info = new AuthenticationInfo("test", "name");
    Assert.assertEquals("test", info.getAuthType());
    Assert.assertEquals("name", info.getUser());
    assertNull(info.getPassword());
}
Also used : AuthenticationInfo(org.apache.sling.auth.core.spi.AuthenticationInfo) Test(org.junit.Test)

Example 12 with AuthenticationInfo

use of org.apache.sling.auth.core.spi.AuthenticationInfo in project sling by apache.

the class AuthenticationInfoTest method testGetUser.

@Test
public void testGetUser() {
    final AuthenticationInfo info = new AuthenticationInfo("test");
    info.put(ResourceResolverFactory.USER, "name");
    Assert.assertEquals("name", info.getUser());
    Assert.assertEquals("name", info.get(ResourceResolverFactory.USER));
    Assert.assertEquals(info.get(ResourceResolverFactory.USER), info.getUser());
}
Also used : AuthenticationInfo(org.apache.sling.auth.core.spi.AuthenticationInfo) Test(org.junit.Test)

Example 13 with AuthenticationInfo

use of org.apache.sling.auth.core.spi.AuthenticationInfo in project sling by apache.

the class AuthenticationInfoTest method testSetAuthType.

@Test
public void testSetAuthType() {
    final AuthenticationInfo info = new AuthenticationInfo("test");
    Assert.assertEquals("test", info.getAuthType());
    info.setAuthType(null);
    Assert.assertEquals("test", info.getAuthType());
    info.setAuthType("dummy");
    Assert.assertEquals("dummy", info.getAuthType());
    info.setAuthType("");
    Assert.assertEquals("", info.getAuthType());
}
Also used : AuthenticationInfo(org.apache.sling.auth.core.spi.AuthenticationInfo) Test(org.junit.Test)

Example 14 with AuthenticationInfo

use of org.apache.sling.auth.core.spi.AuthenticationInfo in project sling by apache.

the class AuthenticationInfoTest method testSetCredentials.

@Test
public void testSetCredentials() {
    final Credentials creds = new SimpleCredentials("user", new char[0]);
    final AuthenticationInfo info = new AuthenticationInfo("test");
    info.put(CREDENTIALS, creds);
    Assert.assertSame(creds, info.get(CREDENTIALS));
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) SimpleCredentials(javax.jcr.SimpleCredentials) Credentials(javax.jcr.Credentials) AuthenticationInfo(org.apache.sling.auth.core.spi.AuthenticationInfo) Test(org.junit.Test)

Example 15 with AuthenticationInfo

use of org.apache.sling.auth.core.spi.AuthenticationInfo in project sling by apache.

the class AuthenticationInfoTest method testPutStringObject.

@Test
public void testPutStringObject() {
    final AuthenticationInfo info = new AuthenticationInfo("test", "user", new char[2]);
    info.put(CREDENTIALS, new SimpleCredentials("user", new char[2]));
    test_put_fail(info, AuthenticationInfo.AUTH_TYPE, null);
    test_put_fail(info, ResourceResolverFactory.USER, null);
    test_put_fail(info, ResourceResolverFactory.PASSWORD, null);
    test_put_fail(info, AuthenticationInfo.AUTH_TYPE, 42);
    test_put_fail(info, ResourceResolverFactory.USER, 42);
    test_put_fail(info, ResourceResolverFactory.PASSWORD, "string");
    test_put_success(info, AuthenticationInfo.AUTH_TYPE, "new_type");
    test_put_success(info, ResourceResolverFactory.USER, "new_user");
    test_put_success(info, ResourceResolverFactory.PASSWORD, "new_pwd".toCharArray());
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) AuthenticationInfo(org.apache.sling.auth.core.spi.AuthenticationInfo) Test(org.junit.Test)

Aggregations

AuthenticationInfo (org.apache.sling.auth.core.spi.AuthenticationInfo)36 Test (org.junit.Test)25 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 SimpleCredentials (javax.jcr.SimpleCredentials)4 IOException (java.io.IOException)3 Collection (java.util.Collection)2 Credentials (javax.jcr.Credentials)2 LoginException (org.apache.sling.api.resource.LoginException)2 Method (java.lang.reflect.Method)1 AccountLockedException (javax.security.auth.login.AccountLockedException)1 AccountNotFoundException (javax.security.auth.login.AccountNotFoundException)1 CredentialExpiredException (javax.security.auth.login.CredentialExpiredException)1 Cookie (javax.servlet.http.Cookie)1 HttpSession (javax.servlet.http.HttpSession)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1 FormCredentials (org.apache.sling.auth.form.impl.jaas.FormCredentials)1 XingUser (org.apache.sling.auth.xing.api.XingUser)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 Token (org.scribe.model.Token)1