Search in sources :

Example 81 with Credentials

use of javax.jcr.Credentials in project sling by apache.

the class OakServerIT method testExplicitAdminLogin.

@Test
public void testExplicitAdminLogin() throws RepositoryException {
    final Credentials creds = new SimpleCredentials("admin", "admin".toCharArray());
    repository.login(creds).logout();
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) SimpleCredentials(javax.jcr.SimpleCredentials) Credentials(javax.jcr.Credentials) Test(org.junit.Test)

Example 82 with Credentials

use of javax.jcr.Credentials in project sling by apache.

the class DavExIntegrationTest method testReadNode.

/** Create a node via Sling's http interface and verify that admin can
     *  read it via davex remote access.
     */
public void testReadNode() throws Exception {
    final String path = "/DavExNodeTest_1_" + System.currentTimeMillis();
    final String url = HTTP_BASE_URL + path;
    // add some properties to the node
    final Map<String, String> props = new HashMap<String, String>();
    props.put("name1", "value1");
    props.put("name2", "value2");
    testClient.createNode(url, props);
    // Oak does not support login without credentials, so to
    // verify that davex access works we do need valid repository credentials.
    final Credentials creds = new SimpleCredentials("admin", "admin".toCharArray());
    Session session = repository.login(creds);
    try {
        final Node node = session.getNode(path);
        assertNotNull(node);
        assertEquals("value1", node.getProperty("name1").getString());
        assertEquals("value2", node.getProperty("name2").getString());
    } finally {
        session.logout();
    }
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) HashMap(java.util.HashMap) Node(javax.jcr.Node) GuestCredentials(javax.jcr.GuestCredentials) SimpleCredentials(javax.jcr.SimpleCredentials) Credentials(javax.jcr.Credentials) Session(javax.jcr.Session)

Example 83 with Credentials

use of javax.jcr.Credentials in project sling by apache.

the class VltSerializationDataBuilder method init.

public void init(org.apache.sling.ide.transport.Repository repository, File contentSyncRoot) throws SerializationException {
    this.repo = repository;
    try {
        this.skm = new SerializationKindManager();
        this.skm.init(repository);
        if (!contentSyncRoot.exists()) {
            throw new IllegalArgumentException("contentSyncRoot does not exist: " + contentSyncRoot);
        }
        Repository jcrRepo = RepositoryUtils.getRepository(repo.getRepositoryInfo());
        Credentials credentials = RepositoryUtils.getCredentials(repo.getRepositoryInfo());
        session = jcrRepo.login(credentials);
        RepositoryAddress address = RepositoryUtils.getRepositoryAddress(repo.getRepositoryInfo());
        fs = fsLocator.getFileSystem(address, contentSyncRoot, session);
    } catch (org.apache.sling.ide.transport.RepositoryException e) {
        throw new SerializationException(e);
    } catch (RepositoryException e) {
        throw new SerializationException(e);
    } catch (IOException e) {
        throw new SerializationException(e);
    } catch (ConfigurationException e) {
        throw new SerializationException(e);
    }
}
Also used : RepositoryAddress(org.apache.jackrabbit.vault.fs.api.RepositoryAddress) SerializationException(org.apache.sling.ide.serialization.SerializationException) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException) SerializationKindManager(org.apache.sling.ide.serialization.SerializationKindManager) Repository(javax.jcr.Repository) ConfigurationException(org.apache.jackrabbit.vault.fs.config.ConfigurationException) Credentials(javax.jcr.Credentials)

Example 84 with Credentials

use of javax.jcr.Credentials in project sling by apache.

the class DefaultBatcherTest method prepare.

@Before
public void prepare() {
    mockRepo = createMock(Repository.class);
    credentials = createMock(Credentials.class);
    batcher = new DefaultBatcher();
}
Also used : Repository(javax.jcr.Repository) DefaultBatcher(org.apache.sling.ide.transport.impl.DefaultBatcher) Credentials(javax.jcr.Credentials) Before(org.junit.Before)

Example 85 with Credentials

use of javax.jcr.Credentials in project sling by apache.

the class AbstractSlingLaunchpadOakTestSupport method testWrongLogin.

@Test(expected = RepositoryException.class)
public void testWrongLogin() throws RepositoryException {
    final Credentials creds = new SimpleCredentials("badName", "badPAssword".toCharArray());
    slingRepository.login(creds);
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) SimpleCredentials(javax.jcr.SimpleCredentials) Credentials(javax.jcr.Credentials) Test(org.junit.Test)

Aggregations

Credentials (javax.jcr.Credentials)86 SimpleCredentials (javax.jcr.SimpleCredentials)53 Test (org.junit.Test)33 GuestCredentials (javax.jcr.GuestCredentials)26 Session (javax.jcr.Session)17 TokenCredentials (org.apache.jackrabbit.api.security.authentication.token.TokenCredentials)14 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)13 RepositoryException (javax.jcr.RepositoryException)12 User (org.apache.jackrabbit.api.security.user.User)12 ImpersonationCredentials (org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials)12 LoginException (javax.security.auth.login.LoginException)8 ArrayList (java.util.ArrayList)7 LoginException (javax.jcr.LoginException)6 Subject (javax.security.auth.Subject)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Repository (javax.jcr.Repository)5 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)5 Principal (java.security.Principal)4 Map (java.util.Map)4