예제 #1
0
        bool DoAuthentication(OSHttpResponse httpResponse, DotNetOpenAuth.OpenId.Provider.IAuthenticationRequest authRequest, ClaimsRequest claimsRequest,
            UserProfileData profile, string pass)
        {
            bool authSuccess = false;

            if (!String.IsNullOrEmpty(pass))
            {
                authSuccess = CableBeachState.LoginService.AuthenticateUser(profile, pass);
                m_log.Info("[CABLE BEACH IDP]: Password match result for " + profile.Name + ": " + authSuccess);

                if (authSuccess)
                {
                    // Mark the OpenID request as successfully authenticated
                    authRequest.IsAuthenticated = true;

                    // Cache this login
                    SetCookie(httpResponse, new Uri(authRequest.ClaimedIdentifier), profile);

                    if (claimsRequest != null)
                    {
                        // Fill in a few Simple Registration values if there was a request for SREG data
                        ClaimsResponse claimsResponse = claimsRequest.CreateResponse();
                        claimsResponse.Email = profile.Email;
                        claimsResponse.FullName = profile.Name;
                        claimsResponse.BirthDate = Utils.UnixTimeToDateTime(profile.Created);
                        authRequest.AddResponseExtension(claimsResponse);

                        m_log.Debug("[CABLE BEACH IDP]: Appended SREG values to the positive assertion response");
                    }
                }
            }
            else
            {
                // Valid POST but missing the password field
                m_log.Warn("[CABLE BEACH IDP]: POST is missing pass field for " + profile.Name);
            }

            return authSuccess;
        }
예제 #2
0
        bool DoAuthentication(OSHttpResponse httpResponse, DotNetOpenAuth.OpenId.Provider.IAuthenticationRequest authRequest, ClaimsRequest claimsRequest,
            string first, string last, string pass)
        {
            bool authSuccess = false;

            if (!String.IsNullOrEmpty(first) && !String.IsNullOrEmpty(last) && !String.IsNullOrEmpty(pass))
            {
                UserProfileData profile;
                if (CableBeachState.TryGetProfile(first, last, out profile))
                {
                    // Set the claimed identifier to the URL of the given identity
                    Uri identity = new Uri(CableBeachState.UserServerUrl, String.Format("/users/{0}.{1}", profile.FirstName, profile.SurName));
                    authRequest.ClaimedIdentifier = identity;

                    authSuccess = CableBeachState.LoginService.AuthenticateUser(profile, pass);
                    m_log.Info("[CABLE BEACH IDP]: Password match result for " + profile.Name + ": " + authRequest.IsAuthenticated);

                    if (authSuccess)
                    {
                        // Mark the OpenID request as successfully authenticated
                        authRequest.IsAuthenticated = true;

                        // Cache this login
                        SetCookie(httpResponse, identity, profile);

                        if (claimsRequest != null)
                        {
                            // Fill in a few Simple Registration values if there was a request for SREG data
                            ClaimsResponse claimsResponse = claimsRequest.CreateResponse();
                            claimsResponse.Email = profile.Email;
                            claimsResponse.FullName = profile.Name;
                            claimsResponse.BirthDate = Utils.UnixTimeToDateTime(profile.Created);
                            authRequest.AddResponseExtension(claimsResponse);

                            m_log.Debug("[CABLE BEACH IDP]: Appended SREG values to the positive assertion response");
                        }
                    }
                }
                else
                {
                    m_log.Warn("[CABLE BEACH IDP]: Profile for user " + first + " " + last + " not found");
                }
            }
            else
            {
                // Valid POST but missing one or more fields
                m_log.Warn("[CABLE BEACH IDP]: POST is missing first, last, or pass field, sending directed login form");
            }

            return authSuccess;
        }
예제 #3
0
        void DoCachedAuthentication(DotNetOpenAuth.OpenId.Provider.IAuthenticationRequest authRequest, ClaimsRequest claimsRequest, AuthCookie authCookie)
        {
            m_log.Info("[CABLE BEACH IDP]: Using cached login credentials for " + authCookie.UserProfile.Name);

            authRequest.ClaimedIdentifier = authCookie.Identity;
            authRequest.IsAuthenticated = true;

            if (claimsRequest != null)
            {
                // Fill in a few Simple Registration values if there was a request for SREG data
                ClaimsResponse claimsResponse = claimsRequest.CreateResponse();
                claimsResponse.Email = authCookie.UserProfile.Email;
                claimsResponse.FullName = authCookie.UserProfile.Name;
                claimsResponse.BirthDate = Utils.UnixTimeToDateTime(authCookie.UserProfile.Created);
                authRequest.AddResponseExtension(claimsResponse);

                m_log.Debug("[CABLE BEACH IDP]: Appended SREG values to the positive assertion response");
            }
        }