Examples of OpenIDRegistrationConfiguration


Examples of org.apache.jetspeed.openid.OpenIDRegistrationConfiguration

        initProviderLabels = OpenIDRegistrationConfiguration.parseParameterList(config.getInitParameter(PROVIDER_LABELS_INIT_PARAM_NAME));
        initProviderDomains = OpenIDRegistrationConfiguration.parseParameterList(config.getInitParameter(PROVIDER_DOMAINS_INIT_PARAM_NAME));
        initEnableOpenIDEntry = Boolean.parseBoolean(config.getInitParameter(ENABLE_OPEN_ID_ENTRY_INIT_PARAM_NAME));
        if (Boolean.parseBoolean(config.getInitParameter(OpenIDConstants.ENABLE_REGISTRATION_CONFIG_INIT_PARAM_NAME)))
        {
            initRegistrationConfiguration = new OpenIDRegistrationConfiguration();
            initRegistrationConfiguration.setEnableRegistration(config.getInitParameter(OpenIDConstants.ENABLE_REGISTRATION_INIT_PARAM_NAME));
            initRegistrationConfiguration.setUserTemplateDirectory(config.getInitParameter(OpenIDConstants.REGISTRATION_USER_TEMPLATE_INIT_PARAM_NAME));
            initRegistrationConfiguration.setSubsiteRootFolder(config.getInitParameter(OpenIDConstants.REGISTRATION_SUBSITE_ROOT_INIT_PARAM_NAME));
            initRegistrationConfiguration.setRoles(config.getInitParameter(OpenIDConstants.REGISTRATION_ROLES_INIT_PARAM_NAME));
            initRegistrationConfiguration.setGroups(config.getInitParameter(OpenIDConstants.REGISTRATION_GROUPS_INIT_PARAM_NAME));
View Full Code Here

Examples of org.apache.jetspeed.openid.OpenIDRegistrationConfiguration

                    // and save in session for consumption by the OpenIDRelayingPartyServlet
                    String logConfiguration = "none";
                    PortletPreferences prefs = actionRequest.getPreferences();
                    if (Boolean.parseBoolean(prefs.getValue(ENABLE_REGISTRATION_CONFIG_PREF_NAME, null)))
                    {
                        OpenIDRegistrationConfiguration registrationConfiguration = new OpenIDRegistrationConfiguration();
                        registrationConfiguration.setEnableRegistration(prefs.getValue(ENABLE_REGISTRATION_PREF_NAME, null));
                        registrationConfiguration.setUserTemplateDirectory(prefs.getValue(REGISTRATION_USER_TEMPLATE_PREF_NAME, null));
                        registrationConfiguration.setSubsiteRootFolder(prefs.getValue(REGISTRATION_SUBSITE_ROOT_PREF_NAME, null));
                        registrationConfiguration.setRoles(prefs.getValue(REGISTRATION_ROLES_PREF_NAME, null));
                        registrationConfiguration.setGroups(prefs.getValue(REGISTRATION_GROUPS_PREF_NAME, null));
                        registrationConfiguration.setProfilerRules(prefs.getValue(REGISTRATION_PROFILER_RULE_NAMES_PREF_NAME, null), prefs.getValue(REGISTRATION_PROFILER_RULE_VALUES_PREF_NAME, null));
                        registrationConfiguration.merge(initRegistrationConfiguration);
                        requestContext.setSessionAttribute(OpenIDConstants.OPEN_ID_REGISTRATION_CONFIGURATION, registrationConfiguration);
                        logConfiguration = "preferences";
                    }
                    else if (initRegistrationConfiguration != null)
                    {
View Full Code Here

Examples of org.apache.jetspeed.openid.OpenIDRegistrationConfiguration

        portalUserContentCacheManager = (UserContentCacheManager)cm.getComponent("userContentCacheManager");

        // registration configuration parameters
        if (Boolean.parseBoolean(config.getInitParameter(OpenIDConstants.ENABLE_REGISTRATION_CONFIG_INIT_PARAM_NAME)))
        {
            initRegistrationConfiguration = new OpenIDRegistrationConfiguration();
            initRegistrationConfiguration.setEnableRegistration(config.getInitParameter(OpenIDConstants.ENABLE_REGISTRATION_INIT_PARAM_NAME));
            initRegistrationConfiguration.setUserTemplateDirectory(config.getInitParameter(OpenIDConstants.REGISTRATION_USER_TEMPLATE_INIT_PARAM_NAME));
            initRegistrationConfiguration.setSubsiteRootFolder(config.getInitParameter(OpenIDConstants.REGISTRATION_SUBSITE_ROOT_INIT_PARAM_NAME));
            initRegistrationConfiguration.setRoles(config.getInitParameter(OpenIDConstants.REGISTRATION_ROLES_INIT_PARAM_NAME));
            initRegistrationConfiguration.setGroups(config.getInitParameter(OpenIDConstants.REGISTRATION_GROUPS_INIT_PARAM_NAME));
View Full Code Here

Examples of org.apache.jetspeed.openid.OpenIDRegistrationConfiguration

                String loginServerName = (String)httpSession.getAttribute(OPEN_ID_LOGIN_SERVER_NAME_ATTR_NAME);
                if (loginServerName != null)
                {
                    httpSession.removeAttribute(OPEN_ID_LOGIN_SERVER_NAME_ATTR_NAME);
                }
                OpenIDRegistrationConfiguration portalRegistrationConfiguration = (OpenIDRegistrationConfiguration)httpSession.getAttribute(OpenIDConstants.OPEN_ID_REGISTRATION_CONFIGURATION);
                if (portalRegistrationConfiguration != null)
                {
                    httpSession.removeAttribute(OpenIDConstants.OPEN_ID_REGISTRATION_CONFIGURATION);
                }

                boolean authenticatedByProvider = false;
                boolean portalUserExists = false;
                try
                {
                    // request parameters
                    ParameterList authParams = new ParameterList(request.getParameterMap());

                    // retrieve OpenID provider from session
                    String provider = (String)httpSession.getAttribute(OPEN_ID_PROVIDER_ATTR_NAME);
                    DiscoveryInformation discovered = (DiscoveryInformation)httpSession.getAttribute(OPEN_ID_DISCOVERY_INFO_ATTR_NAME);

                    // reconstruct the authenticated request URL
                    StringBuffer authRequestURLBuffer = request.getRequestURL();
                    String authRequestQueryString = request.getQueryString();
                    if ((authRequestQueryString != null) && (authRequestQueryString.length() > 0))
                    {
                        authRequestURLBuffer.append('?').append(authRequestQueryString);
                    }
                    String authRequestURL = authRequestURLBuffer.toString();

                    // select consumer implementation based on provider
                    String providerConsumer = OPEN_ID_CONSUMER_INIT_PARAM_NAME_VALUE;
                    if (provider != null)
                    {
                        String consumer = getInitParameter(OPEN_ID_CONSUMER_INIT_PARAM_NAME_PREFIX+provider);
                        if ((consumer != null) && consumer.equals(STEP2_CONSUMER_INIT_PARAM_NAME_VALUE))
                        {
                            providerConsumer = STEP2_CONSUMER_INIT_PARAM_NAME_VALUE;
                        }
                    }
                   
                    // verify the authenticated request
                    VerificationResults verificationResults = null;
                    if (providerConsumer.equals(STEP2_CONSUMER_INIT_PARAM_NAME_VALUE))
                    {
                        // Step2 OpenId verification
                        verificationResults = openIDStep2Verification(authRequestURL, authParams, discovered);
                    }
                    else
                    {
                        // standard OpenId verification
                        verificationResults = openIDVerification(authRequestURL, authParams, discovered);
                    }
                    VerificationResult verification = verificationResults.verification;
                    Identifier verifiedIdentifier = verificationResults.verifiedIdentifier;

                    // extract identifier from verified authenticated request
                    if (verifiedIdentifier == null)
                    {
                        throw new RuntimeException("Verified identifier unavailable for authenticated OpenID login");                   
                    }
                    authenticatedByProvider = true;
                   
                    String email = null;
                    String firstName = null;
                    String lastName = null;
                    String nickname = null;               
                    String fullName = null;
                    // extract requested attribute exchange data
                    AuthSuccess authResponse = (AuthSuccess)verification.getAuthResponse();
                    if (authResponse.hasExtension(AxMessage.OPENID_NS_AX))
                    {
                        try
                        {
                            FetchResponse axResponse = (FetchResponse)authResponse.getExtension(AxMessage.OPENID_NS_AX);
                            email = axResponse.getAttributeValue("email");
                            fullName = axResponse.getAttributeValue("fullname");
                            firstName = axResponse.getAttributeValue("firstname");
                            lastName = axResponse.getAttributeValue("lastname");
                            nickname = axResponse.getAttributeValue("nickname");
                        }
                        catch (OpenIDException oide)
                        {
                            throw new RuntimeException("Unexpected OpenID authenticated attribute exchange fetch exception: "+oide, oide);
                        }
                    }
                    // extract requested simple registration data
                    if (authResponse.hasExtension(SRegMessage.OPENID_NS_SREG))
                    {
                        try
                        {
                            SRegResponse sregResponse = (SRegResponse)authResponse.getExtension(SRegMessage.OPENID_NS_SREG);
                            email = sregResponse.getAttributeValue("email");
                            fullName = sregResponse.getAttributeValue("fullname");
                            nickname = sregResponse.getAttributeValue("nickname");
                        }
                        catch (OpenIDException oide)
                        {
                            throw new RuntimeException("Unexpected OpenID authenticated simple registration fetch exception: "+oide, oide);
                        }
                    }

                    // log authenticated request
                    if (log.isDebugEnabled())
                    {
                        log.debug("Authenticated OpenID verified identifier: "+verifiedIdentifier.getIdentifier()+", email="+email+", fullname="+fullName+", firstname="+firstName+", lastname="+lastName+", nickname="+nickname);
                    }

                    // validate and default attributes
                    if (email == null)
                    {
                        throw new RuntimeException("OpenID email attribute required for portal login");
                    }
                    if (fullName != null)
                    {
                        String [] fullNames = fullName.split("\\s");
                        if ((firstName == null) && (fullNames.length > 1))
                        {
                            firstName = fullNames[0];
                        }
                        if (lastName == null)
                        {
                            lastName = ((fullNames.length > 1) ? fullNames[fullNames.length-1] : fullName);
                        }
                    }
                    if ((nickname == null) && (firstName != null))
                    {
                        nickname = firstName;
                    }
                    if (nickname == null)
                    {
                        int emailDomainIndex = email.indexOf('@');
                        if (emailDomainIndex != -1)
                        {
                            nickname = email.substring(0, emailDomainIndex);
                        }
                    }
                    // construct portal user attributes
                    Map<String,String> userAttributes = new HashMap<String,String>();
                    userAttributes.put(USER_ATTRIBUTE_EMAIL, email);
                    userAttributes.put(USER_ATTRIBUTE_NAME, email);
                    if (firstName != null)
                    {
                        userAttributes.put(USER_ATTRIBUTE_GIVEN_NAME, firstName);
                    }
                    if (lastName != null)
                    {
                        userAttributes.put(USER_ATTRIBUTE_FAMILY_NAME, lastName);                               
                    }
                    if (nickname != null)
                    {
                        userAttributes.put(USER_ATTRIBUTE_NICKNAME, nickname);                               
                    }

                    // login to portal using email, creating portal
                    // user if necessary
                    User portalUser = null;
                    try
                    {
                        portalUser = portalUserManager.getUser(email);
                    }
                    catch (Exception e)
                    {                       
                    }

                    // create portal user if not found
                    if (portalUser == null)
                    {
                        try
                        {
                            // select portal registration configuration and
                            // register portal user
                            String logConfiguration = "none";
                            if (portalRegistrationConfiguration != null)
                            {
                                portalRegistrationConfiguration.merge(initRegistrationConfiguration);
                                logConfiguration = "session, (from login)";
                            }
                            else if (initRegistrationConfiguration != null)
                            {
                                portalRegistrationConfiguration = initRegistrationConfiguration;
                                logConfiguration = "init params";
                            }
                            if ((portalRegistrationConfiguration == null) || portalRegistrationConfiguration.isEnableRegistration())
                            {
                                if (portalRegistrationConfiguration != null)
                                {
                                    portalAdministration.registerUser(email, null,
                                                                      portalRegistrationConfiguration.getRoles(),
                                                                      portalRegistrationConfiguration.getGroups(),
                                                                      userAttributes,
                                                                      portalRegistrationConfiguration.getProfilerRules(),
                                                                      portalRegistrationConfiguration.getUserTemplateDirectory(),
                                                                      portalRegistrationConfiguration.getSubsiteRootFolder(),
                                                                      loginLocale, loginServerName);
                                }
                                else
                                {
                                    portalAdministration.registerUser(email, null, null, null, userAttributes, null, null, null,
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.