예제 #1
0
 private void ParameterizedTypeUriPreservedTest(string typeUri)
 {
     ClaimsRequest request = new ClaimsRequest(typeUri);
     ClaimsResponse response = request.CreateResponse();
     Assert.AreEqual(typeUri, ((IOpenIdMessageExtension)response).TypeUri);
 }
예제 #2
0
		public ClaimsResponse GetOpenIdProfileFields(ClaimsRequest request) {
			if (request == null) {
				throw new ArgumentNullException("request");
			}

			ClaimsResponse fields = request.CreateResponse();
			fields.BirthDate = this.DateOfBirth;
			fields.Country = this.countryDropdownList.SelectedValue;
			fields.Email = this.emailTextBox.Text;
			fields.FullName = this.fullnameTextBox.Text;
			fields.Gender = this.Gender;
			fields.Language = this.languageDropdownList.SelectedValue;
			fields.Nickname = this.nicknameTextBox.Text;
			fields.PostalCode = this.postcodeTextBox.Text;
			fields.TimeZone = this.timezoneDropdownList.SelectedValue;
			return fields;
		}
예제 #3
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;
        }
예제 #4
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;
        }
예제 #5
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");
            }
        }