public AuthenticationInfo extractCredentials()

in src/main/java/org/apache/sling/auth/xing/login/impl/XingLoginAuthenticationHandler.java [179:211]


    public AuthenticationInfo extractCredentials(final HttpServletRequest request, final HttpServletResponse response) {
        logger.debug("extract credentials");

        String hash = null;
        String user = null;
        String userId = null;

        final Cookie[] cookies = request.getCookies();
        if (cookies != null) {
            for (final Cookie cookie : cookies) {
                final String cookieName = cookie.getName();
                if (cookieName.equals(xingCookie)) {
                    hash = readCookieValue(cookie);
                    logger.debug("“Login with XING” cookie found: {}", hash);
                } else if (cookieName.equals(userCookie)) {
                    user = readCookieValue(cookie);
                } else if (cookieName.equals(userIdCookie)) {
                    userId = readCookieValue(cookie);
                }
            }
        }

        if (!StringUtils.isEmpty(hash) && !StringUtils.isEmpty(userId) && !StringUtils.isEmpty(user)) {
            logger.debug("valid cookies with hash and user data and id found");
            final AuthenticationInfo authenticationInfo = new AuthenticationInfo(XingLogin.AUTH_TYPE, userId);
            authenticationInfo.put(XingLogin.AUTHENTICATION_CREDENTIALS_HASH_KEY, hash);
            authenticationInfo.put(XingLogin.AUTHENTICATION_CREDENTIALS_USERDATA_KEY, user);
            return authenticationInfo;
        } else {
            logger.debug("unable to extract credentials from request");
            return null;
        }
    }