Examples of ImpersonationCredentials


Examples of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials

                if (userId.equals(creds.getUserID()) && userCreds instanceof CredentialsImpl) {
                    success = PasswordUtil.isSame(((CredentialsImpl) userCreds).getPasswordHash(), creds.getPassword());
                }
                checkSuccess(success, "UserId/Password mismatch.");
            } else if (credentials instanceof ImpersonationCredentials) {
                ImpersonationCredentials ipCreds = (ImpersonationCredentials) credentials;
                AuthInfo info = ipCreds.getImpersonatorInfo();
                success = equalUserId(ipCreds) && impersonate(info, user);
                checkSuccess(success, "Impersonation not allowed.");
            } else {
                // guest login is allowed if an anonymous user exists in the content (see get user above)
                success = (credentials instanceof GuestCredentials);
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials

    @Override
    @Nonnull
    public Session impersonate(Credentials credentials) throws RepositoryException {
        sd.checkAlive();

        ImpersonationCredentials impCreds = new ImpersonationCredentials(credentials, sd.getAuthInfo());
        return getRepository().login(impCreds, sd.getWorkspaceName());
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials

            assertEquals("test", authInfo.getUserID());

            cs.close();

            sc = new SimpleCredentials("test", new char[0]);
            ImpersonationCredentials ic = new ImpersonationCredentials(sc, authInfo);
            cs = login(ic);

            authInfo = cs.getAuthInfo();
            assertEquals("test", authInfo.getUserID());
        } finally {
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials

            cs = null;

            ConfigurationParameters config = securityProvider.getConfiguration(UserConfiguration.class).getParameters();
            String adminId = UserUtil.getAdminId(config);
            sc = new SimpleCredentials(adminId, new char[0]);
            ImpersonationCredentials ic = new ImpersonationCredentials(sc, authInfo);

            try {
                cs = login(ic);
                fail("User 'test' should not be allowed to impersonate " + adminId);
            } catch (LoginException e) {
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials

    @Test
    public void testCreateTokenFromInvalidCredentials() throws Exception {
        List<Credentials> invalid = new ArrayList<Credentials>();
        invalid.add(new GuestCredentials());
        invalid.add(new TokenCredentials("sometoken"));
        invalid.add(new ImpersonationCredentials(new GuestCredentials(), null));
        invalid.add(new SimpleCredentials("unknownUserId", new char[0]));

        for (Credentials creds : invalid) {
            assertNull(tokenProvider.createToken(creds));
        }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials

    @Test
    public void testCreateTokenFromCredentials() throws Exception {
        SimpleCredentials sc = new SimpleCredentials(userId, new char[0]);
        List<Credentials> valid = new ArrayList<Credentials>();
        valid.add(sc);
        valid.add(new ImpersonationCredentials(sc, null));

        for (Credentials creds : valid) {
            TokenInfo info = tokenProvider.createToken(creds);
            assertTokenInfo(info, userId);
        }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials

            assertEquals(USER_ID, authInfo.getUserID());

            cs.close();

            sc = new SimpleCredentials(USER_ID, new char[0]);
            ImpersonationCredentials ic = new ImpersonationCredentials(sc, authInfo);
            cs = login(ic);

            authInfo = cs.getAuthInfo();
            assertEquals(USER_ID, authInfo.getUserID());
        } finally {
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials

            cs = null;

            ConfigurationParameters config = securityProvider.getConfiguration(UserConfiguration.class).getParameters();
            String adminId = UserUtil.getAdminId(config);
            sc = new SimpleCredentials(adminId, new char[0]);
            ImpersonationCredentials ic = new ImpersonationCredentials(sc, authInfo);

            try {
                cs = login(ic);
                fail("User 'test' should not be allowed to impersonate " + adminId);
            } catch (LoginException e) {
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials

            cs.close();
            cs = null;

            sc = new SimpleCredentials(USER_ID, new char[0]);
            sc.setAttribute("attr", "value");
            ImpersonationCredentials ic = new ImpersonationCredentials(sc, authInfo);
            cs = login(ic);

            authInfo = cs.getAuthInfo();
            assertTrue(Arrays.asList(authInfo.getAttributeNames()).contains("attr"));
            assertEquals("value", authInfo.getAttribute("attr"));
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials

        ContentSession cs = null;
        try {
            SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
            sc.setAttribute(".token", "");

            ImpersonationCredentials ic = new ImpersonationCredentials(sc, new AuthInfoImpl(((SimpleCredentials) getAdminCredentials()).getUserID(), Collections.<String, Object>emptyMap(), Collections.<Principal>emptySet()));
            cs = login(ic);

            Object token = sc.getAttribute(".token").toString();
            assertNotNull(token);
            TokenCredentials tc = new TokenCredentials(token.toString());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.