Package org.apache.sling.engine.auth

Examples of org.apache.sling.engine.auth.AuthenticationInfo


                sessionAttr);
            req.removeAttribute(EngineConstants.SESSION);
        }

        // 1. Ask all authentication handlers to try to extract credentials
        AuthenticationInfo authInfo = getAuthenticationInfo(req, res);

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

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

        } else if (authInfo == null) {

            log.debug("authenticate: no credentials in the request, anonymous");
            return getAnonymousSession(req, res);

        } else {
            // try to connect
            try {
                log.debug("authenticate: credentials, trying to get a session");
                Session session = getRepository().login(
                    authInfo.getCredentials(), null);

                // handle impersonation
                session = handleImpersonation(req, res, session);
                setAttributes(session, authInfo.getAuthType(), req);

                return true;

            } catch (RepositoryException re) {
View Full Code Here


    private AuthenticationInfo getAuthenticationInfo(
            HttpServletRequest request, HttpServletResponse response) {
        AuthenticationHandlerInfo[] local = getAuthenticationHandlers();
        for (int i = 0; i < local.length; i++) {
            if ( request.getPathInfo().startsWith(local[i].path) ) {
                final AuthenticationInfo authInfo = local[i].handler.authenticate(request,
                    response);
                if (authInfo != null) {
                    return authInfo;
                }
            }
View Full Code Here

     */
    public AuthenticationInfo authenticate(HttpServletRequest request,
            HttpServletResponse response) {

        // extract credentials and return
        AuthenticationInfo info = this.extractAuthentication(request);
        if (info != null) {
            return info;
        }

        // no credentials, check whether the client wants to login
View Full Code Here

        if (NOT_LOGGED_IN_USER.equals(creds.getUserID())) {
            return null;
        }

        return new AuthenticationInfo(HttpServletRequest.BASIC_AUTH, creds);
    }
View Full Code Here

                sessionAttr);
            req.removeAttribute(EngineConstants.SESSION);
        }

        // 1. Ask all authentication handlers to try to extract credentials
        AuthenticationInfo authInfo = getAuthenticationInfo(req, res);

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

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

        } else if (authInfo == null) {

            log.debug("authenticate: no credentials in the request, anonymous");
            return getAnonymousSession(req, res);

        } else {
            // try to connect
            try {
                log.debug("authenticate: credentials, trying to get a session");
                Session session = getRepository().login(
                    authInfo.getCredentials(), authInfo.getWorkspaceName());

                // handle impersonation
                session = handleImpersonation(req, res, session);
                setAttributes(session, authInfo.getAuthType(), req);

                return true;

            } catch (RepositoryException re) {
View Full Code Here

        for (int i = 0; i < local.length; i++) {
            if ( pathInfo.startsWith(local[i].path) ) {
                Object oldPathAttr = RequestUtil.setRequestAttribute(request,
                    AuthenticationHandler.PATH_PROPERTY, local[i].fullPath);
                try {
                    final AuthenticationInfo authInfo = local[i].handler.authenticate(
                        request, response);
                    if (authInfo != null) {
                        return authInfo;
                    }
                } finally {
View Full Code Here

     */
    public AuthenticationInfo authenticate(HttpServletRequest request,
            HttpServletResponse response) {

        // extract credentials and return
        AuthenticationInfo info = this.extractAuthentication(request);
        if (info != null) {
            return info;
        }

        // no credentials, check whether the client wants to login
View Full Code Here

        if (NOT_LOGGED_IN_USER.equals(creds.getUserID())) {
            return null;
        }

        return new AuthenticationInfo(HttpServletRequest.BASIC_AUTH, creds);
    }
View Full Code Here

     */
    public AuthenticationInfo authenticate(HttpServletRequest request,
            HttpServletResponse response) {

        // extract credentials and return
        AuthenticationInfo info = this.extractAuthentication(request, response);
        if (info != null) {
            return info;
        }

        return null;
View Full Code Here

              }
             
              if(accessAuthPageAnon) {
                // Causes anonymous login
                // but does not respect SlingAuthenticator allowAnonymous
                return new AuthenticationInfo(OpenIDConstants.OPEN_ID_AUTH_TYPE, null);
              }
            }
          }
        }
         
            if(user != null) {
              if(user.isAuthenticated()) {
                  // user already authenticated
                  request.setAttribute(OpenIdUser.ATTR_NAME, user);
                  return getAuthInfoFromUser(user);
              } else if(user.isAssociated()) {
                if(RelyingParty.isAuthResponse(request)) {
                  if(relyingParty.verifyAuth(user, request, response)) {
                        // authenticated                   
                        response.sendRedirect(request.getRequestURI());
                        return AuthenticationInfo.DOING_AUTH;
                    } else {
                        // failed verification
                      AuthenticationInfo authInfo = handleAuthFailure(OpenIDFailure.VERIFICATION, request, response);
                if(authInfo != null) {
                  return authInfo;
                }
                    }
                } else {
                  // Assume a cancel or some other non-successful response from provider
                  // failed verification
                  relyingParty.invalidate(request, response);
                  user = null;
                 
                    AuthenticationInfo authInfo = handleAuthFailure(OpenIDFailure.AUTHENTICATION, request, response);
              if(authInfo != null) {
                return authInfo;
              }
                }
              } else {
                // associate and authenticate user
                StringBuffer url = null;
                String trustRoot = null;
                String returnTo = null;
               
                if(externalUrlPrefix != null && !"".equals(externalUrlPrefix.trim())) {
                  url = new StringBuffer(externalUrlPrefix).append(request.getRequestURI());
                  trustRoot = externalUrlPrefix;
                } else {
                  url = request.getRequestURL();
                  trustRoot = url.substring(0, url.indexOf(SLASH, 9));
                }
               
                String realm = url.substring(0, url.lastIndexOf(SLASH));
               
                if(redirectToOriginalUrl) {
                  returnTo = url.toString();       
                } else {
                  request.setAttribute(OpenIDConstants.ORIGINAL_URL_ATTRIBUTE, request.getRequestURI());
                  returnTo =  authSuccessUrl;
            }
               
                if(relyingParty.associateAndAuthenticate(user, request, response, trustRoot, realm,
                        returnTo)) {
                    // user is associated and then redirected to his openid provider for authentication               
                    return AuthenticationInfo.DOING_AUTH;
                } else {
                  // failed association or auth request generation
                    AuthenticationInfo authInfo = handleAuthFailure(OpenIDFailure.ASSOCIATION, request, response);
              if(authInfo != null) {
                return authInfo;
              }
                }
              }
View Full Code Here

TOP

Related Classes of org.apache.sling.engine.auth.AuthenticationInfo

Copyright © 2018 www.massapicom. 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.