Examples of AuthenticationInfo


Examples of org.apache.shiro.authc.AuthenticationInfo

        return aggregate;//返回之前合并的
    }

    @Override
    public AuthenticationInfo afterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo singleRealmInfo, AuthenticationInfo aggregateInfo, Throwable t) throws AuthenticationException {
        AuthenticationInfo info;
        if (singleRealmInfo == null) {
            info = aggregateInfo;
        } else {
            if (aggregateInfo == null) {
                info = singleRealmInfo;
View Full Code Here

Examples of org.apache.shiro.authc.AuthenticationInfo

        return aggregate;//返回之前合并的
    }

    @Override
    public AuthenticationInfo afterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo singleRealmInfo, AuthenticationInfo aggregateInfo, Throwable t) throws AuthenticationException {
        AuthenticationInfo info;
        if (singleRealmInfo == null) {
            info = aggregateInfo;
        } else {
            if (aggregateInfo == null) {
                info = singleRealmInfo;
            } else {
                info = merge(singleRealmInfo, aggregateInfo);
                if(info.getPrincipals().getRealmNames().size() > 1) {
                    System.out.println(info.getPrincipals().getRealmNames());
                    throw new AuthenticationException("Authentication token of type [" + token.getClass() + "] " +
                            "could not be authenticated by any configured realms.  Please ensure that only one realm can " +
                            "authenticate these tokens.");
                }
            }
View Full Code Here

Examples of org.apache.sling.auth.core.spi.AuthenticationInfo

                xingUser = fetchUser(accessToken);
                logger.debug("xing user: {}", xingUser);
                httpSession.setAttribute(USER_SESSION_ATTRIBUTE_NAME, xingUser);
            }

            final AuthenticationInfo authenticationInfo = new AuthenticationInfo(XingOauth.AUTH_TYPE, xingUser.getId());
            authenticationInfo.put(XingOauth.AUTHENTICATION_CREDENTIALS_ACCESS_TOKEN_KEY, accessToken);
            authenticationInfo.put(XingOauth.AUTHENTICATION_CREDENTIALS_USER_KEY, xingUser);
            return authenticationInfo;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            removeAuthFromSession(request);
            return null;
View Full Code Here

Examples of org.apache.sling.auth.core.spi.AuthenticationInfo

            return AuthenticationInfo.DOING_AUTH;
        }

        // backwards compatibility support for JCR credentials and workspace
        // name now encapsulated in the JCR Resource bundle
        AuthenticationInfo info = new AuthenticationInfo(
            engineAuthInfo.getAuthType());
        info.put("user.jcr.credentials", engineAuthInfo.getCredentials());
        info.put("user.jcr.workspace", engineAuthInfo.getWorkspaceName());

        return info;
    }
View Full Code Here

Examples of org.apache.sling.auth.core.spi.AuthenticationInfo

        return requestLogin != null
            && !OpenIDConstants.OPENID_AUTH.equals(requestLogin);
    }

    private AuthenticationInfo getAuthInfoFromUser(final OpenIdUser user) {
        final AuthenticationInfo info = new AuthenticationInfo(
            OpenIDConstants.OPENID_AUTH, getUserName(user));

        // if there is no login module plugin service, set the credentials
        // attribute to the user's OpenID identity, otherwise set it to
        // the actual OpenIDUser object
        if (loginModule == null) {
            info.put(openIdAttribute, user.getIdentity());
        } else {
            info.put(openIdAttribute, user);
        }

        return info;
    }
View Full Code Here

Examples of org.apache.sling.auth.core.spi.AuthenticationInfo

            info.getAuthType());
    }

    @Test
    public void testSetUser() {
        final AuthenticationInfo info = new AuthenticationInfo("test", "user");
        Assert.assertEquals("user", info.getUser());

        info.setUser(null);
        Assert.assertEquals("user", info.getUser());

        info.setUser("dummy");
        Assert.assertEquals("dummy", info.getUser());

        info.setUser("");
        Assert.assertEquals("", info.getUser());
    }
View Full Code Here

Examples of org.apache.sling.auth.core.spi.AuthenticationInfo

        Assert.assertEquals("", info.getUser());
    }

    @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());
    }
View Full Code Here

Examples of org.apache.sling.auth.core.spi.AuthenticationInfo

    }

    private boolean doHandleSecurity(HttpServletRequest request, HttpServletResponse response) {

        // 1. Ask all authentication handlers to try to extract credentials
        final AuthenticationInfo authInfo = getAuthenticationInfo(request, response);

        // 2. PostProcess credentials
        try {
            postProcess(authInfo, request, response);
        } catch (LoginException e) {
            handleLoginFailure(request, response, authInfo.getUser(), e);
            return false;
        }

        // 3. Check Credentials
        if (authInfo == AuthenticationInfo.DOING_AUTH) {

            log.debug("doHandleSecurity: ongoing authentication in the handler");
            return false;

        } else if (authInfo == AuthenticationInfo.FAIL_AUTH) {

            log.debug("doHandleSecurity: Credentials present but not valid, request authentication again");
            AuthUtil.setLoginResourceAttribute(request, request.getRequestURI());
            doLogin(request, response);
            return false;

        } else if (authInfo.getAuthType() == null) {

            log.debug("doHandleSecurity: No credentials in the request, anonymous");
            return getAnonymousResolver(request, response, authInfo);

        } else {

            log.debug("doHandleSecurity: Trying to get a session for {}", authInfo.getUser());
            return getResolver(request, response, authInfo);

        }
    }
View Full Code Here

Examples of org.apache.sling.auth.core.spi.AuthenticationInfo

    }

    @Test
    public void testSetPassword() {
        final char[] pwd = new char[6];
        final AuthenticationInfo info = new AuthenticationInfo("test", "name");

        assertFalse(info.containsKey(ResourceResolverFactory.PASSWORD));

        info.setPassword(pwd);
        assertSame(pwd, info.get(ResourceResolverFactory.PASSWORD));

        info.setPassword(null);
        assertSame(pwd, info.get(ResourceResolverFactory.PASSWORD));
    }
View Full Code Here

Examples of org.apache.sling.auth.core.spi.AuthenticationInfo

        if (response.isCommitted()) {
            throw new IllegalStateException("Response already committed");
        }

        // make sure impersonation is dropped
        setSudoCookie(request, response, new AuthenticationInfo("dummy", request.getRemoteUser()));

        final String path = getHandlerSelectionPath(request);
        final Collection<AbstractAuthenticationHandlerHolder>[] holdersArray = this.authHandlerCache
                .findApplicableHolder(request);
        for (int m = 0; m < holdersArray.length; m++) {
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.