• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# TokenService.RequestDetails类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Thinktecture.IdentityServer.TokenService.RequestDetails的典型用法代码示例。如果您正苦于以下问题:C# RequestDetails类的具体用法?C# RequestDetails怎么用?C# RequestDetails使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RequestDetails类属于Thinktecture.IdentityServer.TokenService命名空间,在下文中一共展示了RequestDetails类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: AnalyzeTokenType

 protected virtual void AnalyzeTokenType(RequestSecurityToken rst, RequestDetails details)
 {
     if (string.IsNullOrWhiteSpace(rst.TokenType))
     {
         details.TokenType = _configuration.DefaultTokenType;
         Tracing.Information("Token Type: not specified, falling back to default token type");
     }
     else
     {
         Tracing.Information("Token Type: " + rst.TokenType);
         details.TokenType = rst.TokenType;
     }
 }
开发者ID:kievryan,项目名称:Thinktecture.IdentityServer.45,代码行数:13,代码来源:Request.cs


示例17: AnalyzeDelegation

 protected virtual void AnalyzeDelegation(RequestSecurityToken rst, RequestDetails details)
 {
     // check for identity delegation request
     if (rst.ActAs != null)
     {
         details.IsActAsRequest = true;
         Tracing.Information("Request is ActAs request");
     }
 }
开发者ID:kievryan,项目名称:Thinktecture.IdentityServer.45,代码行数:9,代码来源:Request.cs


示例18: 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);

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

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

            //context claims 
            if (requestDetails.Request.AdditionalContext != null && requestDetails.Request.AdditionalContext.Items.Count() > 0)
            {
                //Aggiunta di Claim da parte del client questa logica serve per settare di lingua,company e profilo

                var passedProfile = requestDetails.Request.AdditionalContext.Items.FirstOrDefault(p => p.Name.ToString() == Sagrada.IdentityServer.ClaimTypes.Profile);
                if (passedProfile != null)
                {
                    var profiles = SagradaIdentityService.GetProfiles(userName);
                    if (profiles.Count(p => p.Item1.ToString() == passedProfile.Value) == 0)
                    {
                        string errors = string.Format("additionalContext request from {0} has a not valid claim : {1}.", requestDetails.Realm.Uri, Sagrada.IdentityServer.ClaimTypes.Profile);
                        Tracing.Error(errors);
                        throw new InvalidRequestException(errors);
                    }
                    else
                        claims.Add(new Claim(Sagrada.IdentityServer.ClaimTypes.Profile, passedProfile.Value));
                }
                
                var passedCompany = requestDetails.Request.AdditionalContext.Items.FirstOrDefault(p => p.Name.ToString() == Sagrada.IdentityServer.ClaimTypes.Company);
                if (passedCompany != null)
                {
                    var companies = SagradaIdentityService.GetCompanies();
                    if (companies.Count(p => p.Item1.ToString() == passedCompany.Value) == 0)
                    {
                        string errors = string.Format("additionalContext request from {0} has a not valid claim : {1}.", requestDetails.Realm.Uri, Sagrada.IdentityServer.ClaimTypes.Company);
                        Tracing.Error(errors);
                        throw new InvalidRequestException(errors);
                    }
                    else
                        claims.Add(new Claim(Sagrada.IdentityServer.ClaimTypes.Company, passedCompany.Value));
                }
            
                var passedLanguage = requestDetails.Request.AdditionalContext.Items.FirstOrDefault(p => p.Name.ToString() == Sagrada.IdentityServer.ClaimTypes.Language);
                if (passedLanguage != null)
                {
                    var languages = SagradaIdentityService.GetLanguages();
                    if (languages.Count(p => p.Name == passedLanguage.Value) == 0)
                    {
                        string errors = string.Format("additionalContext request from {0} has a not valid claim : {1}.", requestDetails.Realm.Uri, Sagrada.IdentityServer.ClaimTypes.Language);
                        Tracing.Error(errors);
                        throw new InvalidRequestException(errors);
                    }
                    else
                        claims.Add(new Claim(Sagrada.IdentityServer.ClaimTypes.Language, passedLanguage.Value));
                }
            
            };

            return claims;
        }
开发者ID:nettunoSolutions,项目名称:Thinktecture.IdentityServer.v2,代码行数:62,代码来源:SagradaProviderClaimsRepository.cs


示例19: ValidateEncryption

 protected virtual void ValidateEncryption(RequestDetails details)
 {
     // check if token must be encrypted
     if (_configuration.RequireEncryption && (!details.UsesEncryption))
     {
         Tracing.Error("Configuration requires encryption - but no key available");
         throw new InvalidRequestException("No encryption key available");
     }
 }
开发者ID:kievryan,项目名称:Thinktecture.IdentityServer.45,代码行数:9,代码来源:Request.cs


示例20: ValidateSsl

 protected virtual void ValidateSsl(RequestDetails details)
 {
     // check if SSL is used (for passive only)
     if (_configuration.RequireSsl && !details.UsesSsl)
     {
         if (!details.IsActive)
         {
             Tracing.Error("Configuration requires SSL - but clear text reply address used");
             throw new InvalidRequestException("SSL is required");
         }
     }
 }
开发者ID:kievryan,项目名称:Thinktecture.IdentityServer.45,代码行数:12,代码来源:Request.cs



注:本文中的Thinktecture.IdentityServer.TokenService.RequestDetails类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# vCards.vCard类代码示例发布时间:2022-05-26
下一篇:
C# Configuration.IdentityServerOptions类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap