Package com.google.gsa

Examples of com.google.gsa.AuthenticationProcessImpl


        //Request has come from the same host as the valve, so must be the login authenticate
        if (internal.match(url)) {

            //Authentication vars
            String repositoryID = null;
            AuthenticationProcessImpl authProcess = null;
            ValveRepositoryConfiguration repositoryConfig = null;

            int order = 1;
            int size = authenticationImplementationsOrder.size();
            if (authenticationImplementationsOrder == null) {
                order = 0;
                logger.error("No Authentication module has been defined. Please check and add those needed at config file");
            }

            while ((1 <= order) && (order <= size)) {

                //Get the repository ID
                logger.debug("###Processing repository # " + order + " ###");
                Integer orderInt = new Integer(order);
                if (authenticationImplementationsOrder.containsKey(orderInt)) {
                    repositoryID =
                            authenticationImplementationsOrder.get(orderInt);
                } else {
                    logger.error("Error during processing authentication methods. Order is not valid");
                    break;
                }

                //Get the Repository config and authentication class                                                   
                authProcess = authenticationImplementations.get(repositoryID);
                repositoryConfig = valveConf.getRepository(repositoryID);

                logger.debug("Authenticating ID: " + repositoryConfig.getId());
                if (repositoryConfig.getId().equals("root")) {
                    //Root should be used for main authentication against an identity repository (LDAP, DB, ..)
                    //and should not be used as a content repository that contains documents
                    try {
                        //add support to cookie array
                        rootAuthCookies.clear();
                        rootStatusCode =
                                authProcess.authenticate(request, response,
                                                         rootAuthCookies, url,
                                                         creds, "root");
                        logger.info("Repository authentication - " +
                                    repositoryConfig.getId() +
                                    " completed. Response was " +
                                    rootStatusCode);
                        if (rootStatusCode ==
                            HttpServletResponse.SC_UNAUTHORIZED) {
                            logger.error("Root AuthN failed");
                        } else {
                            //Support to cookie array
                            if (rootStatusCode == HttpServletResponse.SC_OK) {
                                logger.debug("Root AuthN is SC_OK (200)");
                                if (!rootAuthCookies.isEmpty()) {
                                    logger.debug("Root AuthN returns cookies");
                                    for (int j = 0; j < rootAuthCookies.size();
                                         j++) {
                                        logger.debug("Root Cookie found: " +
                                                     rootAuthCookies.elementAt(j).getName() +
                                                     ":" +
                                                     rootAuthCookies.elementAt(j).getValue());
                                        authCookies.add(rootAuthCookies.elementAt(j));
                                    }
                                } else {
                                    logger.debug("Root AuthN does NOT return cookies");
                                }
                            }
                        }

                        //If no repository is defined called root then rootStatusCode must be set to OK
                        // This flag is used to indicate that a root repository has been defined.
                        rootAuthNDefined = true;
                        //
                    } catch (Exception e) {
                        logger.debug("Exception with authentication for ID: " +
                                     repositoryConfig.getId() + " - " +
                                     e.getMessage());
                        rootAuthNDefined = true;
                    }
                } else {
                    try {

                        //add support to cookie array
                        repositoryAuthCookies.clear();

                        logger.debug("Let's do the authentication");

                        repositoryAuthStatusCode =
                                authProcess.authenticate(request, response,
                                                         repositoryAuthCookies,
                                                         url, creds,
                                                         repositoryConfig.getId());

                        //add support to cookie array
View Full Code Here


        //Protection. Make sure the Map is empty before proceeding
        authenticationImplementations.clear();

        //Authentication process instance
        AuthenticationProcessImpl authenticationProcess = null;

        String repositoryIds[] = valveConf.getRepositoryIds();

        ValveRepositoryConfiguration repository = null;

        int order = 1;

        for (int i = 0; i < repositoryIds.length; i++) {
            try {

                repository = valveConf.getRepository(repositoryIds[i]);

                //Check if repository has to be included in the authentication process. By default set it to true
                boolean checkAuthN = true;
                try {
                    if ((repository.getCheckAuthN() != null) &&
                        (!repository.getCheckAuthN().equals(""))) {
                        checkAuthN =
                                new Boolean(repository.getCheckAuthN()).booleanValue();
                    }
                } catch (Exception e) {
                    logger.error("Error when reading checkAuthN param: " +
                                 e.getMessage(), e);
                    //protection
                    checkAuthN = true;
                }

                if (checkAuthN) {
                    logger.info("Initialising authentication process for " +
                                repository.getId() + " [#" + order + "]");
                    authenticationProcess =
                            (AuthenticationProcessImpl)Class.forName(repository.getAuthN()).newInstance();
                    authenticationProcess.setValveConfiguration(valveConf);
                    //add this authentication process to the Map
                    synchronized (authenticationImplementations) {
                        synchronized (authenticationImplementations) {
                            authenticationImplementations.put(repository.getId(),
                                                              authenticationProcess);
View Full Code Here

                }
                //authentication
                logger.debug("Authenticate crawler");

                //Authentication process
                AuthenticationProcessImpl authenticationProcessCls;
                try {
                    authenticationProcessCls = setAuthenticationProcessImpl();
                } catch (ValveConfigurationException e) {
                    logger.error("Valve configuration error: " +
                                 e.getMessage(), e);
                    authnResponse =
                            HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
                    return authnResponse;
                }

                if (authenticationProcessCls != null) {
                    authnResponse =
                            authenticationProcessCls.authenticate(request,
                                                                  response,
                                                                  authCookies,
                                                                  internalURL,
                                                                  creds, id);
                }
View Full Code Here

                //reauthentication
                logger.debug("Reauthenticate crawler");

                //Authentication process
                AuthenticationProcessImpl authenticationProcessCls;
                try {
                    authenticationProcessCls = setAuthenticationProcessImpl();
                } catch (ValveConfigurationException e) {
                    logger.error("Valve configuration error: " +
                                 e.getMessage(), e);
                    authnResponse =
                            HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
                    return authnResponse;
                }

                if (authenticationProcessCls != null) {
                    authnResponse =
                            authenticationProcessCls.authenticate(request,
                                                                  response,
                                                                  authCookies,
                                                                  internalURL,
                                                                  creds, id);
                }
View Full Code Here

     *
     * @throws ValveConfigurationException
     */
    public AuthenticationProcessImpl setAuthenticationProcessImpl() throws ValveConfigurationException {

        AuthenticationProcessImpl authenticationProcessImpl = null;

        //Set authenticationProcessClsName if it has not been done yet
        if (authenticationProcessClsName == null) {
            //read the authorization class name from Valve Config
            if (valveConf != null) {
                authenticationProcessClsName =
                        valveConf.getAuthenticationProcessImpl();
                logger.debug("Setting authenticationProcessClsName: " +
                             authenticationProcessClsName);
            } else {
                // Throw Configuration Exception
                throw new ValveConfigurationException("Valve Configuration file has not been set correctly");
            }

        }

        // Protection
        if ((authenticationProcessClsName == null) ||
            (authenticationProcessClsName.equals(""))) {

            // Throw Configuration Exception
            throw new ValveConfigurationException("Configuration parameter [authorizationProcessImpl] has not been set correctly");

        }

        try {

            // Instantiate the authorization process class                
            authenticationProcessImpl =
                    (AuthenticationProcessImpl)Class.forName(authenticationProcessClsName).newInstance();
            authenticationProcessImpl.setValveConfiguration(valveConf);

        } catch (InstantiationException ie) {

            // Throw Configuration Exception
            throw new ValveConfigurationException("Configuration parameter [authorizationProcessImpl] has not been set correctly - InstantiationException");
View Full Code Here

TOP

Related Classes of com.google.gsa.AuthenticationProcessImpl

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.