當前位置: 首頁>>代碼示例>>C#>>正文


C# TokenService.RequestDetails類代碼示例

本文整理匯總了C#中Thinktecture.IdentityServer.TokenService.RequestDetails的典型用法代碼示例。如果您正苦於以下問題:C# RequestDetails類的具體用法?C# RequestDetails怎麽用?C# RequestDetails使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RequestDetails類屬於Thinktecture.IdentityServer.TokenService命名空間,在下文中一共展示了RequestDetails類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetClaims

        public IEnumerable<Claim> GetClaims(ClaimsPrincipal principal, RequestDetails requestDetails)
        {
            var userName = principal.Identity.Name;
            var claims = new List<Claim>(from c in principal.Claims select c);

            // email address
            string email = Membership.FindUsersByName(userName)[userName].Email;
            if (!String.IsNullOrEmpty(email))
            {
                claims.Add(new Claim(ClaimTypes.Email, email));
            }

            // roles
            GetRolesForToken(userName).ToList().ForEach(role => claims.Add(new Claim(ClaimTypes.Role, role)));

            // profile claims
            if (ProfileManager.Enabled)
            {
                var profile = ProfileBase.Create(userName, true);
                if (profile != null)
                {
                    foreach (SettingsProperty prop in ProfileBase.Properties)
                    {
                        string value = profile.GetPropertyValue(prop.Name).ToString();
                        if (!String.IsNullOrWhiteSpace(value))
                        {
                            claims.Add(new Claim(ProfileClaimPrefix + prop.Name.ToLowerInvariant(), value));
                        }
                    }
                }
            }

            return claims;
        }
開發者ID:rmarinho,項目名稱:Thinktecture.IdentityServer.v2,代碼行數:34,代碼來源:ProviderClaimsRepository.cs

示例2: GetClaims

        public virtual IEnumerable<Claim> GetClaims(ClaimsPrincipal principal, RequestDetails requestDetails)
        {
            var userName = principal.Identity.Name;
            var claims = new List<Claim>(from c in principal.Claims select c);

            var nameIdClaim = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier);
            if (nameIdClaim == null)
            {
                claims.Add(new Claim(ClaimTypes.NameIdentifier, userName));
            }

            // email address
            var membership = Membership.FindUsersByName(userName)[userName];
            if (membership != null)
            {
                string email = membership.Email;
                if (!String.IsNullOrEmpty(email))
                {
                    claims.Add(new Claim(ClaimTypes.Email, email));
                }
            }

            // roles
            GetRolesForToken(userName).ToList().ForEach(role => claims.Add(new Claim(ClaimTypes.Role, role)));

            // profile claims
            claims.AddRange(GetProfileClaims(userName));

            return claims;
        }
開發者ID:cotepatrice,項目名稱:Thinktecture.IdentityServer.v2,代碼行數:30,代碼來源:ProviderClaimsRepository.cs

示例3: GetClaims

 public IEnumerable<Claim> GetClaims(ClaimsPrincipal principal, RequestDetails requestDetails)
 {
     return new List<Claim>
     {
         principal.Identities.First().FindFirst(ClaimTypes.Name),
         new Claim("http://claims/custom/foo", "bar")
     };
 }
開發者ID:EduOrtega,項目名稱:Thinktecture.IdentityServer.v2,代碼行數:8,代碼來源:ClaimsRepository.cs

示例4: GetClaims

        public IEnumerable<Claim> GetClaims(IClaimsPrincipal principal, RequestDetails requestDetails)
        {
            var claims = from c in NewContext.UserClaims
                         where c.PartitionKey == principal.Identity.Name.ToLower() &&
                               c.Kind == UserClaimEntity.EntityKind
                         select new Claim(c.ClaimType, c.Value);

            return claims.ToList();
        }
開發者ID:saikat2k01,項目名稱:Thinktecture.IdentityServer,代碼行數:9,代碼來源:TableStorageClaimsRepository.cs

示例5: Analyze

        public RequestDetails Analyze(RequestSecurityToken rst, ClaimsPrincipal principal)
        {
            if (rst == null)
            {
                throw new ArgumentNullException("rst");
            }

            if (principal == null)
            {
                throw new ArgumentNullException("principal");
            }

            Tracing.Information("Starting PolicyOptions creation");

            var clientIdentity = AnalyzeClientIdentity(principal);

            var details = new RequestDetails
            {
                ClientIdentity = clientIdentity,
                IsActive = false,
                Realm = null,
                IsKnownRealm = false,
                UsesSsl = false,
                UsesEncryption = false,
                ReplyToAddress = null,
                ReplyToAddressIsWithinRealm = false,
                IsReplyToFromConfiguration = false,
                EncryptingCertificate = null,
                ClaimsRequested = false,
                RequestClaims = null,
                Request = null,
                IsActAsRequest = false,
                RelyingPartyRegistration = null
            };

            AnalyzeRst(rst, details);
            AnalyzeTokenType(rst, details);
            AnalyzeKeyType(rst);
            AnalyzeRealm(rst, details);
            AnalyzeOperationContext(details);
            AnalyzeDelegation(rst, details);
            AnalyzeRelyingParty(details);
            AnalyzeEncryption(details);
            AnalyzeReplyTo(details);
            AnalyzeSsl(details);
            AnalyzeRequestClaims(details);

            Tracing.Information("PolicyOptions creation done.");

            _details = details;
            return details;
        }
開發者ID:kievryan,項目名稱:Thinktecture.IdentityServer.45,代碼行數:52,代碼來源:Request.cs

示例6: GetClaims

        public IEnumerable<Claim> GetClaims(ClaimsPrincipal principal, RequestDetails requestDetails)
        {
            var claims = new List<Claim>();
            var nameClaim = principal.Identities.First().FindFirst(ClaimTypes.Name);
            claims.Add(nameClaim);
            var response = RewardService.GetRewardProgram(new GetRewardProgramRequest {UserName = nameClaim.Value});
            if(response != null)
            {
                claims.Add(new Claim("http://oceanicairlines.com/rewardlevel/", response.RewardLevel.ToString()));
            };

            return claims;
        }
開發者ID:hansarnevartdal,項目名稱:BlogExamples,代碼行數:13,代碼來源:ClaimsRepository.cs

示例7: Get

        HttpResponseMessage Get()
        {
            var requestClaims = new RequestClaimCollection();

            var scopes = ClaimsPrincipal.Current.FindAll(OAuth2Constants.Scope);
            foreach (var scope in scopes)
            {
                if (OidcConstants.Mappings.ContainsKey(scope.Value))
                {
                    foreach (var oidcClaim in OidcConstants.Mappings[scope.Value])
                    {
                        requestClaims.Add(new RequestClaim(oidcClaim));
                    }
                }
                else
                {
                    Request.CreateErrorResponse(HttpStatusCode.BadRequest, "invalid scope");
                }
            }

            var details = new RequestDetails { IsOpenIdRequest = true };
            details.ClaimsRequested = true;
            details.RequestClaims = requestClaims;

            var principal = Principal.Create("OpenIdConnect",
                new Claim(ClaimTypes.NameIdentifier, ClaimsPrincipal.Current.FindFirst("sub").Value));

            var claims = ClaimsRepository.GetClaims(principal, details);

            var dictionary = new Dictionary<string, string>();
            foreach (var claim in claims)
            {
                if (!dictionary.ContainsKey(claim.Type))
                {
                    dictionary.Add(claim.Type, claim.Value);
                }
                else
                {
                    var currentValue = dictionary[claim.Type];
                    dictionary[claim.Type] = currentValue += ("," + claim.Value);
                }
            }

            return Request.CreateResponse<Dictionary<string, string>>(HttpStatusCode.OK, dictionary, "application/json");
        }
開發者ID:Excelsior-Charles,項目名稱:Thinktecture.IdentityServer.v2,代碼行數:45,代碼來源:UserInfoController.cs

示例8: RequestDetailsScope

        public RequestDetailsScope(RequestDetails details, SigningCredentials signingCredentials, bool requireEncryption)
            : base(details.Realm.Uri.AbsoluteUri, signingCredentials)
        {
            RequestDetails = details;

            if (RequestDetails.UsesEncryption)
            {
                EncryptingCredentials = new X509EncryptingCredentials(details.EncryptingCertificate);
            }

            if (RequestDetails.TokenType == SimpleWebToken.OasisTokenProfile)
            {
                SigningCredentials = new SymmetricSigningCredentials(details.RelyingPartyRegistration.SymmetricSigningKey);
            }

            ReplyToAddress = RequestDetails.ReplyToAddress.AbsoluteUri;
            TokenEncryptionRequired = requireEncryption;
        }
開發者ID:saikat2k01,項目名稱:Thinktecture.IdentityServer,代碼行數:18,代碼來源:RequestDetailsScope.cs

示例9: Get

        public HttpResponseMessage Get()
        {
            Tracing.Start("OIDC UserInfo endpoint");

            var details = new RequestDetails { IsOpenIdRequest = true };
            var scopeClaims = ClaimsPrincipal.Current.FindAll(OAuth2Constants.Scope).ToList();
            var requestedClaims = ClaimsPrincipal.Current.FindAll("requestclaim").ToList();

            if (scopeClaims.Count > 0)
            {
                var scopes = new List<string>(scopeClaims.Select(sc => sc.Value));
                details.OpenIdScopes = scopes;
            }

            if (requestedClaims.Count > 0)
            {
                var requestClaims = new RequestClaimCollection();
                requestedClaims.ForEach(rc => requestClaims.Add(new RequestClaim(rc.Value)));
                
                details.ClaimsRequested = true;
                details.RequestClaims = requestClaims;
            }

            var principal = Principal.Create("OpenIdConnect",
                new Claim(ClaimTypes.Name, ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value));

            var claims = ClaimsRepository.GetClaims(principal, details);

            var dictionary = new Dictionary<string, string>();
            foreach (var claim in claims)
            {
                if (!dictionary.ContainsKey(claim.Type))
                {
                    dictionary.Add(claim.Type, claim.Value);
                }
                else
                {
                    var currentValue = dictionary[claim.Type];
                    dictionary[claim.Type] = currentValue += ("," + claim.Value);
                }
            }

            return Request.CreateResponse<Dictionary<string, string>>(HttpStatusCode.OK, dictionary, "application/json");
        }
開發者ID:EduOrtega,項目名稱:Thinktecture.IdentityServer.v2,代碼行數:44,代碼來源:UserInfoController.cs

示例10: GetClaims

        public virtual IEnumerable<Claim> GetClaims(ClaimsPrincipal principal, RequestDetails requestDetails)
        {
            var userName = principal.Identity.Name;
            var claims = new List<Claim>(from c in principal.Claims select c);

            // email address
            string email = userName;
            if (!String.IsNullOrEmpty(email))
            {
                    claims.Add(new Claim(ClaimTypes.Email, email));                
            }

            // roles
            GetRolesForToken(userName).ToList().ForEach(role => claims.Add(new Claim(ClaimTypes.Role, role)));

            // profile claims
            claims.AddRange(GetProfileClaims(userName));
            return claims;
        }
開發者ID:gotshoo,項目名稱:Thinktecture.IdentityServer.v2,代碼行數:19,代碼來源:ProviderClaimsRepository.cs

示例11: GetClaims

        virtual public IEnumerable<Claim> GetClaims(IClaimsPrincipal principal, RequestDetails requestDetails)
        {
            var claims = new List<Claim>();

            using (PrincipalContext context = GetPrincipalContext())
            {
                var userName = principal.Identity.Name;

                // find the user in the identity store
                UserPrincipal user = UserPrincipal.FindByIdentity(context, userName);

                // email address
                string email = user.EmailAddress;
                if (!String.IsNullOrEmpty(email))
                {
                    claims.Add(new Claim(ClaimTypes.Email, email));
                }

                // roles
                GetRoles(userName, RoleTypes.Client).ToList().ForEach(role => claims.Add(new Claim(ClaimTypes.Role, role)));

                // profile claims
                if (ProfileManager.Enabled)
                {
                    var profile = ProfileBase.Create(userName, true);
                    if (profile != null)
                    {
                        foreach (SettingsProperty prop in ProfileBase.Properties)
                        {
                            string value = profile.GetPropertyValue(prop.Name).ToString();
                            if (!String.IsNullOrWhiteSpace(value))
                            {
                                claims.Add(new Claim(ProfileClaimPrefix + prop.Name.ToLowerInvariant(), value));
                            }
                        }
                    }
                }
            }

            return claims;
        }
開發者ID:mscherpenisse,項目名稱:Thinktecture.IdentityServer.Contrib,代碼行數:41,代碼來源:ActiveDirectoryProviderUserRepository.cs

示例12: RequestDetailsScope

        public RequestDetailsScope(RequestDetails details, SigningCredentials signingCredentials, bool requireEncryption)
            : base(details.Realm.Uri.AbsoluteUri, signingCredentials)
        {
            RequestDetails = details;

            if (RequestDetails.UsesEncryption)
            {
                EncryptingCredentials = new X509EncryptingCredentials(details.EncryptingCertificate);
            }

            if (RequestDetails.TokenType == TokenTypes.SimpleWebToken || RequestDetails.TokenType == TokenTypes.JsonWebToken)
            {
                if (details.RelyingPartyRegistration.SymmetricSigningKey != null && details.RelyingPartyRegistration.SymmetricSigningKey.Length > 0)
                {
                    SigningCredentials = new HmacSigningCredentials(details.RelyingPartyRegistration.SymmetricSigningKey);
                }
            }

            ReplyToAddress = RequestDetails.ReplyToAddress.AbsoluteUri;
            TokenEncryptionRequired = requireEncryption;
        }
開發者ID:BinaryCoderL,項目名稱:Thinktecture.IdentityServer.v2,代碼行數:21,代碼來源:RequestDetailsScope.cs

示例13: GetClaims

        public override IEnumerable<Claim> GetClaims(ClaimsPrincipal principal, RequestDetails requestDetails)
        {
            if (requestDetails.Realm.Uri.AbsoluteUri == "http://sbserver/swttest/")
            {
                if (principal.Identity.Name == "bob")
                {
                    return new List<Claim>
                    {
                        new Claim(sbClaimType, "Listen"),
                        new Claim(sbClaimType, "Manage"),
                    };
                }
                else
                {
                    return new List<Claim>
                    {
                        new Claim(sbClaimType, "Send"),
                    };
                }
            }

            return base.GetClaims(principal, requestDetails);
        }
開發者ID:EduOrtega,項目名稱:Thinktecture.IdentityServer.v2,代碼行數:23,代碼來源:MyClaimsRepository.cs

示例14: ProcessClaims

        public IEnumerable<Claim> ProcessClaims(ClaimsPrincipal incomingPrincipal, IdentityProvider identityProvider, RequestDetails details)
        {
            var audienceUri = details.Realm.Uri.AbsoluteUri;
            var newClaimsPrincipal = (ClaimsIdentity)incomingPrincipal.Identity;
            newClaimsPrincipal.AddClaim(new Claim("http://schemas.fcsamerica.com/claims/PartnerApps/audienceuri", audienceUri));
            return newClaimsPrincipal.Claims;

            /*  Prototype code to test loading Claims Mapper Claims from STS.

            ClaimsIdentity claimsIdentity = incomingPrincipal.Identity as ClaimsIdentity;
            var emailClaim = incomingPrincipal.Claims.FirstOrDefault(_ => _.Type.Equals(ClaimTypes.Email));
               // var partnerClaim = incomingPrincipal.Claims.FirstOrDefault(_ => _.Type.Con)
               // NOTE: McGruff has a Get Partner Name from Host Header Method.
               // QUESTION:  How will we store the STS generated SAML token on the claims principal?  It isn't rewritten yet. We will need to generate it here?
               // QUESTION:  If the Audit Info is on the claims principal... We would still need logic to help people determine which one to pull.  Look at RequestHeader first, then Claims Principal.
               // QUESTION:  We still need an API for accessing SAML token and AuditInfo.   Can this be the Token Generator?
               // QUESTION:  How much of the WIF settings can be added to the Website Root for Inheritance?
               // QUESTION:  How can we call Claims Mapper Service without a SAML token.  - it hasn't been created yet. Or can we create a temporary one here????
            List<Claim> claims = new List<Claim>();
            if( emailClaim != null)
            {
                var emailAddress = emailClaim.Value;
                var realm = details.Realm.ToString();
                var applicationName = realm.Substring(realm.IndexOf(":")+1);

                // call claims mapper and add additional claims...
                claims.Add(new Claim("AuditInfo", "Test AuditInfo Value"));
            }
            else
            {
                claims.Add(new Claim("STSClaimsLoadError", "Could not determine the partner and/or application. Make sure the realm has the application name and IdP provides the partner claim."));
            }

            claimsIdentity.AddClaims(claims);
            return claimsIdentity.Claims;
            */
        }
開發者ID:FCSAmerica,項目名稱:SecureTokenServer,代碼行數:37,代碼來源:PassThruTransformationRuleProxy.cs

示例15: ProcessClaims

 public IEnumerable<Claim> ProcessClaims(ClaimsPrincipal incomingPrincipal, IdentityProvider identityProvider, RequestDetails details)
 {
     return incomingPrincipal.Claims;
 }
開發者ID:nyankov,項目名稱:Thinktecture.IdentityServer.v2,代碼行數:4,代碼來源:PassThruTransformationRuleRepository.cs


注:本文中的Thinktecture.IdentityServer.TokenService.RequestDetails類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。