Imported Upstream version 3.10.0

Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
Jo Shields
2014-10-04 11:27:48 +01:00
parent fe777c5c82
commit 8b9b85e7f5
970 changed files with 20242 additions and 31308 deletions

View File

@ -0,0 +1,51 @@
//
// AudienceRestriction.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System.Collections.ObjectModel;
using System.IdentityModel.Selectors;
namespace System.IdentityModel.Tokens
{
public class AudienceRestriction
{
public Collection<Uri> AllowedAudienceUris { get; private set; }
public AudienceUriMode AudienceMode { get; set; }
public AudienceRestriction () {
AllowedAudienceUris = new Collection<Uri>();
}
public AudienceRestriction (AudienceUriMode audienceMode)
: this ()
{
AudienceMode = audienceMode;
}
}
}
#endif

View File

@ -0,0 +1,46 @@
//
// AuthenticationContext.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.Collections.ObjectModel;
namespace System.IdentityModel.Tokens
{
public class AuthenticationContext
{
public Collection<string> Authorities { get; private set; }
public string ContextClass { get; set; }
public string ContextDeclaration { get; set; }
public AuthenticationContext () {
Authorities = new Collection<string> ();
}
}
}
#endif

View File

@ -0,0 +1,47 @@
//
// AuthenticationInformation.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.Collections.ObjectModel;
using System.IdentityModel.Tokens;
namespace System.Security.Claims
{
public class AuthenticationInformation
{
private Collection<AuthenticationContext> authorizationContexts = new Collection<AuthenticationContext> ();
public String Address { get; set; }
public Collection<AuthenticationContext> AuthorizationContexts { get { return authorizationContexts; } }
public String DnsName { get; set; }
public Nullable<DateTime> NotOnOrAfter { get; set; }
public String Session { get; set; }
}
}
#endif

View File

@ -0,0 +1,50 @@
//
// EncryptingCredentials.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
namespace System.IdentityModel.Tokens
{
public class EncryptingCredentials
{
public string Algorithm { get; set; }
public SecurityKey SecurityKey { get; set; }
public SecurityKeyIdentifier SecurityKeyIdentifier { get; set; }
public EncryptingCredentials ()
{ }
public EncryptingCredentials (SecurityKey key, SecurityKeyIdentifier keyIdentifier, string algorithm) {
SecurityKey = key;
SecurityKeyIdentifier = keyIdentifier;
Algorithm = algorithm;
}
}
}
#endif

View File

@ -0,0 +1,55 @@
//
// IssuerNameRegistry.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System.IdentityModel.Configuration;
using System.Xml;
namespace System.IdentityModel.Tokens
{
public abstract class IssuerNameRegistry : ICustomIdentityConfiguration
{
public abstract string GetIssuerName (SecurityToken securityToken);
[MonoTODO]
public virtual string GetIssuerName (SecurityToken securityToken, System.String requestedIssuerName) {
throw new NotImplementedException ();
}
[MonoTODO]
public virtual string GetWindowsIssuerName() {
throw new NotImplementedException ();
}
[MonoTODO]
public virtual void LoadCustomConfiguration(XmlNodeList nodelist) {
throw new NotImplementedException ();
}
}
}
#endif

View File

@ -0,0 +1,41 @@
//
// ProofDescriptor.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System.IdentityModel.Protocols.WSTrust;
namespace System.IdentityModel.Tokens
{
public abstract class ProofDescriptor
{
public abstract SecurityKeyIdentifier KeyIdentifier { get; }
public abstract void ApplyTo (RequestSecurityTokenResponse response);
}
}
#endif

View File

@ -68,6 +68,8 @@ namespace System.IdentityModel.Tokens
return nonce != null ? (byte []) nonce.Clone () : null;
}
public string Id { get; set; }
public virtual SecurityKey CreateKey ()
{
throw new NotSupportedException (String.Format ("This '{0}' identifier clause does not support key creation.", GetType ()));

View File

@ -0,0 +1,74 @@
//
// SecurityTokenDescriptor.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.IdentityModel.Protocols.WSTrust;
using System.Security.Claims;
namespace System.IdentityModel.Tokens
{
public class SecurityTokenDescriptor
{
private Dictionary<string, Object> properties = new Dictionary<string, object> ();
public string AppliesToAddress { get; set; }
public SecurityKeyIdentifierClause AttachedReference { get; set; }
public AuthenticationInformation AuthenticationInfo { get; set; }
public EncryptingCredentials EncryptingCredentials { get; set; }
public Lifetime Lifetime { get; set; }
public ProofDescriptor Proof { get; set; }
public Dictionary<string, Object> Properties { get { return properties; } }
public string ReplyToAddress { get; set; }
public SigningCredentials SigningCredentials { get; set; }
public ClaimsIdentity Subject { get; set; }
public SecurityToken Token { get; set; }
public string TokenIssuerName { get; set; }
public string TokenType { get; set; }
public SecurityKeyIdentifierClause UnattachedReference { get; set; }
[MonoTODO]
public void AddAuthenticationClaims (string authType) {
throw new NotImplementedException ();
}
[MonoTODO]
public void AddAuthenticationClaims (string authType, DateTime time) {
throw new NotImplementedException ();
}
[MonoTODO]
public virtual void ApplyTo (RequestSecurityTokenResponse response) {
throw new NotImplementedException ();
}
}
}
#endif

View File

@ -0,0 +1,123 @@
//
// SecurityTokenHandler.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.Collections.ObjectModel;
using System.IdentityModel.Configuration;
using System.IdentityModel.Selectors;
using System.Security.Claims;
using System.Xml;
namespace System.IdentityModel.Tokens
{
public abstract class SecurityTokenHandler : ICustomIdentityConfiguration
{
public virtual bool CanValidateToken { get { return false; } }
public virtual bool CanWriteToken { get { return false; } }
public SecurityTokenHandlerConfiguration Configuration { get; set; }
public SecurityTokenHandlerCollection ContainingCollection { get; internal set; }
public abstract Type TokenType { get; }
public virtual bool CanReadKeyIdentifierClause (XmlReader reader) {
return false;
}
public virtual bool CanReadToken (string tokenString) {
return false;
}
public virtual bool CanReadToken (XmlReader reader) {
return false;
}
public virtual bool CanWriteKeyIdentifierClause (SecurityKeyIdentifierClause securityKeyIdentifierClause) {
return false;
}
public virtual SecurityKeyIdentifierClause CreateSecurityTokenReference (SecurityToken token, bool attached) {
throw new NotImplementedException ();
}
public virtual SecurityToken CreateToken (SecurityTokenDescriptor tokenDescriptor) {
throw new NotImplementedException ();
}
protected virtual void DetectReplayedToken (SecurityToken token) {
throw new NotImplementedException ();
}
public abstract string[] GetTokenTypeIdentifiers ();
public virtual void LoadCustomConfiguration (XmlNodeList nodelist) {
throw new NotImplementedException ();
}
public virtual SecurityKeyIdentifierClause ReadKeyIdentifierClause (XmlReader reader) {
throw new NotImplementedException ();
}
public virtual SecurityToken ReadToken (string tokenString) {
throw new NotImplementedException ();
}
public virtual SecurityToken ReadToken (XmlReader reader) {
throw new NotImplementedException ();
}
public virtual SecurityToken ReadToken (XmlReader reader, SecurityTokenResolver tokenResolver) {
return this.ReadToken (reader);
}
protected void TraceTokenValidationFailure (SecurityToken token, string errorMessage) {
throw new NotImplementedException ();
}
protected void TraceTokenValidationSuccess (SecurityToken token) {
throw new NotImplementedException ();
}
public virtual ReadOnlyCollection<ClaimsIdentity> ValidateToken (SecurityToken token) {
throw new NotImplementedException ();
}
public virtual void WriteKeyIdentifierClause (XmlWriter writer, SecurityKeyIdentifierClause securityKeyIdentifierClause) {
throw new NotImplementedException ();
}
public virtual string WriteToken (SecurityToken token) {
throw new NotImplementedException ();
}
public virtual void WriteToken (XmlWriter writer, SecurityToken token) {
throw new NotImplementedException ();
}
}
}
#endif

View File

@ -0,0 +1,197 @@
//
// SecurityTokenHandlerCollection.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IdentityModel.Selectors;
using System.Security.Claims;
using System.Xml;
namespace System.IdentityModel.Tokens
{
public class SecurityTokenHandlerCollection : Collection<SecurityTokenHandler>
{
private SecurityTokenHandlerConfiguration config;
private IEnumerable<string> tokenTypeIdentifiers = new List<string> ();
private IEnumerable<Type> tokenTypes = new List<Type> ();
public SecurityTokenHandlerConfiguration Configuration { get { return this.config; } }
public IEnumerable<string> TokenTypeIdentifiers { get { return tokenTypeIdentifiers; } }
public IEnumerable<Type> TokenTypes { get { return tokenTypes; } }
public SecurityTokenHandler this[SecurityToken token] {
get {
if (token == null) { return null; }
return this[token.GetType ()];
}
}
[MonoTODO]
public SecurityTokenHandler this[string tokenTypeIdentifier] {
get {
throw new NotImplementedException ();
}
}
[MonoTODO]
public SecurityTokenHandler this[Type tokenType] {
get {
throw new NotImplementedException ();
}
}
public SecurityTokenHandlerCollection ()
: this(new SecurityTokenHandlerConfiguration ())
{ }
public SecurityTokenHandlerCollection (SecurityTokenHandlerConfiguration configuration) {
config = configuration;
}
public SecurityTokenHandlerCollection (IEnumerable<SecurityTokenHandler> handlers)
: this (handlers, new SecurityTokenHandlerConfiguration ())
{ }
public SecurityTokenHandlerCollection (IEnumerable<SecurityTokenHandler> handlers, SecurityTokenHandlerConfiguration configuration) : this (configuration) {
foreach (var handler in handlers) {
Add (handler);
}
}
[MonoTODO]
public void AddOrReplace(SecurityTokenHandler handler) {
throw new NotImplementedException ();
}
[MonoTODO]
public bool CanReadKeyIdentifierClause(XmlReader reader) {
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual bool CanReadKeyIdentifierClauseCore(XmlReader reader) {
throw new NotImplementedException ();
}
[MonoTODO]
public bool CanReadToken(string tokenString) {
throw new NotImplementedException ();
}
[MonoTODO]
public bool CanReadToken(XmlReader reader) {
throw new NotImplementedException ();
}
[MonoTODO]
public bool CanWriteToken(SecurityToken token) {
throw new NotImplementedException ();
}
[MonoTODO]
protected override void ClearItems() {
throw new NotImplementedException ();
}
[MonoTODO]
public static SecurityTokenHandlerCollection CreateDefaultSecurityTokenHandlerCollection() {
throw new NotImplementedException ();
}
[MonoTODO]
public static SecurityTokenHandlerCollection CreateDefaultSecurityTokenHandlerCollection(SecurityTokenHandlerConfiguration configuration) {
throw new NotImplementedException ();
}
[MonoTODO]
public SecurityToken CreateToken(SecurityTokenDescriptor tokenDescriptor) {
throw new NotImplementedException ();
}
[MonoTODO]
protected override void InsertItem(int index, SecurityTokenHandler item) {
throw new NotImplementedException ();
}
[MonoTODO]
public SecurityKeyIdentifierClause ReadKeyIdentifierClause(XmlReader reader) {
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual SecurityKeyIdentifierClause ReadKeyIdentifierClauseCore(XmlReader reader) {
throw new NotImplementedException ();
}
[MonoTODO]
public SecurityToken ReadToken(string tokenString) {
throw new NotImplementedException ();
}
[MonoTODO]
public SecurityToken ReadToken(XmlReader reader) {
throw new NotImplementedException ();
}
[MonoTODO]
protected override void RemoveItem(int index) {
throw new NotImplementedException ();
}
[MonoTODO]
protected override void SetItem(int index, SecurityTokenHandler item) {
throw new NotImplementedException ();
}
[MonoTODO]
public ReadOnlyCollection<ClaimsIdentity> ValidateToken(SecurityToken token) {
throw new NotImplementedException ();
}
[MonoTODO]
public void WriteKeyIdentifierClause(XmlWriter writer, SecurityKeyIdentifierClause keyIdentifierClause) {
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual void WriteKeyIdentifierClauseCore(XmlWriter writer, SecurityKeyIdentifierClause keyIdentifierClause) {
throw new NotImplementedException ();
}
[MonoTODO]
public string WriteToken(SecurityToken token) {
throw new NotImplementedException ();
}
[MonoTODO]
public void WriteToken(XmlWriter writer, SecurityToken token) {
throw new NotImplementedException ();
}
}
}
#endif

View File

@ -0,0 +1,66 @@
//
// SecurityTokenHandlerConfiguration.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.IdentityModel.Configuration;
using System.IdentityModel.Selectors;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel.Security;
namespace System.IdentityModel.Tokens
{
public class SecurityTokenHandlerConfiguration
{
public static readonly X509CertificateValidationMode DefaultCertificateValidationMode;
public static readonly X509CertificateValidator DefaultCertificateValidator;
public static readonly bool DefaultDetectReplayedTokens;
public static readonly IssuerNameRegistry DefaultIssuerNameRegistry;
public static readonly SecurityTokenResolver DefaultIssuerTokenResolver;
public static readonly TimeSpan DefaultMaxClockSkew;
public static readonly X509RevocationMode DefaultRevocationMode;
public static readonly bool DefaultSaveBootstrapContext;
public static readonly TimeSpan DefaultTokenReplayCacheExpirationPeriod;
public static readonly StoreLocation DefaultTrustedStoreLocation;
public AudienceRestriction AudienceRestriction { get; set; }
public IdentityModelCaches Caches { get; set; }
public X509CertificateValidationMode CertificateValidationMode { get; set; }
public X509CertificateValidator CertificateValidator { get; set; }
public bool DetectReplayedTokens { get; set; }
public IssuerNameRegistry IssuerNameRegistry { get; set; }
public SecurityTokenResolver IssuerTokenResolver { get; set; }
public TimeSpan MaxClockSkew { get; set; }
public X509RevocationMode RevocationMode { get; set; }
public bool SaveBootstrapContext { get; set; }
public SecurityTokenResolver ServiceTokenResolver { get; set; }
public TimeSpan TokenReplayCacheExpirationPeriod { get; set; }
public StoreLocation TrustedStoreLocation { get; set; }
}
}
#endif

View File

@ -0,0 +1,109 @@
//
// SessionSecurityToken.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Security.Claims;
using System.Xml;
namespace System.IdentityModel.Tokens
{
[Serializable]
public class SessionSecurityToken : SecurityToken
{
private ReadOnlyCollection<SecurityKey> securityKeys;
private DateTime validFrom;
private DateTime validTo;
public ClaimsPrincipal ClaimsPrincipal { get; private set; }
public string Context { get; private set; }
public UniqueId ContextId { get; private set; }
public string EndpointId { get; private set; }
[MonoTODO]
public override string Id { get { throw new NotImplementedException (); } }
public bool IsPersistent { get; set; }
public bool IsReferenceMode { get; set; }
public DateTime KeyEffectiveTime { get; private set; }
public DateTime KeyExpirationTime { get; private set; }
public UniqueId KeyGeneration { get; private set; }
public Uri SecureConversationVersion { get; private set; }
public override ReadOnlyCollection<SecurityKey> SecurityKeys { get { return securityKeys; } }
public override DateTime ValidFrom { get { return validFrom; } }
public override DateTime ValidTo { get { return validTo; } }
public SessionSecurityToken (ClaimsPrincipal claimsPrincipal)
: this (claimsPrincipal, null)
{ }
protected SessionSecurityToken (SerializationInfo info, StreamingContext context) {
throw new NotImplementedException ();
}
public SessionSecurityToken (ClaimsPrincipal claimsPrincipal, string context)
: this (claimsPrincipal, context, DateTime.UtcNow, DateTime.UtcNow + SessionSecurityTokenHandler.DefaultTokenLifetime)
{ }
public SessionSecurityToken (ClaimsPrincipal claimsPrincipal, TimeSpan lifetime)
: this (claimsPrincipal, null, DateTime.UtcNow, DateTime.UtcNow + lifetime)
{ }
public SessionSecurityToken (ClaimsPrincipal claimsPrincipal, string context, DateTime? validFrom, DateTime? validTo)
: this (claimsPrincipal, new UniqueId (), context, String.Empty, validFrom, validTo, null)
{ }
public SessionSecurityToken (ClaimsPrincipal claimsPrincipal, string context, string endpointId, DateTime? validFrom, DateTime? validTo)
: this(claimsPrincipal, new UniqueId (), context, endpointId, validFrom, validTo, null)
{ }
public SessionSecurityToken (ClaimsPrincipal claimsPrincipal, UniqueId contextId, string context, string endpointId, TimeSpan lifetime, SymmetricSecurityKey key)
: this (claimsPrincipal, contextId, context, endpointId, DateTime.UtcNow, lifetime, key)
{ }
public SessionSecurityToken (ClaimsPrincipal claimsPrincipal, UniqueId contextId, string context, string endpointId, DateTime validFrom, TimeSpan lifetime, SymmetricSecurityKey key)
: this (claimsPrincipal, contextId, context, endpointId, validFrom, validFrom + lifetime, key)
{ }
public SessionSecurityToken (ClaimsPrincipal claimsPrincipal, UniqueId contextId, string context, string endpointId, DateTime? validFrom, DateTime? validTo, SymmetricSecurityKey key) {
ClaimsPrincipal = claimsPrincipal;
ContextId = contextId;
Context = context;
EndpointId = endpointId;
validFrom = (validFrom.HasValue) ? validFrom.Value.ToUniversalTime () : DateTime.UtcNow;
validTo = (validTo.HasValue) ? validTo.Value.ToUniversalTime () : ValidFrom + SessionSecurityTokenHandler.DefaultTokenLifetime;
securityKeys = new ReadOnlyCollection<SecurityKey> (new SecurityKey[] { new InMemorySymmetricSecurityKey ((key == null) ? null : key.GetSymmetricKey ()) });
}
[MonoTODO]
public virtual void GetObjectData (SerializationInfo info, StreamingContext context) {
throw new NotImplementedException ();
}
}
}
#endif

View File

@ -0,0 +1,51 @@
//
// SessionSecurityTokenCache.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.Collections.Generic;
using System.IdentityModel.Configuration;
using System.Xml;
namespace System.IdentityModel.Tokens
{
public abstract class SessionSecurityTokenCache : ICustomIdentityConfiguration
{
public abstract void AddOrUpdate (SessionSecurityTokenCacheKey key, SessionSecurityToken value, DateTime expiryTime);
public abstract SessionSecurityToken Get (SessionSecurityTokenCacheKey key);
public abstract IEnumerable<SessionSecurityToken> GetAll (string endpointId, UniqueId contextId);
[MonoTODO]
public virtual void LoadCustomConfiguration (XmlNodeList nodelist) {
throw new NotImplementedException ();
}
public abstract void Remove (SessionSecurityTokenCacheKey key);
public abstract void RemoveAll (string endpointId);
public abstract void RemoveAll (string endpointId, UniqueId contextId);
}
}
#endif

View File

@ -0,0 +1,74 @@
//
// SessionSecurityTokenCacheKey.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.Xml;
namespace System.IdentityModel.Tokens
{
public class SessionSecurityTokenCacheKey
{
[MonoTODO]
public static bool operator !=(SessionSecurityTokenCacheKey first, SessionSecurityTokenCacheKey second) {
throw new NotImplementedException ();
}
[MonoTODO]
public static bool operator ==(SessionSecurityTokenCacheKey first, SessionSecurityTokenCacheKey second) {
throw new NotImplementedException ();
}
public UniqueId ContextId { get; private set; }
public string EndpointId { get; private set; }
public bool IgnoreKeyGeneration { get; set; }
public UniqueId KeyGeneration { get; private set; }
public SessionSecurityTokenCacheKey (string endpointId, UniqueId contextId, UniqueId keyGeneration) {
EndpointId = endpointId;
ContextId = contextId;
KeyGeneration = keyGeneration;
}
[MonoTODO]
public override bool Equals (System.Object obj) {
throw new NotImplementedException ();
}
[MonoTODO]
public override int GetHashCode () {
throw new NotImplementedException ();
}
[MonoTODO]
public override string ToString () {
throw new NotImplementedException ();
}
}
}
#endif

View File

@ -0,0 +1,148 @@
//
// SessionSecurityTokenHandler.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IdentityModel.Selectors;
using System.Security.Claims;
using System.Xml;
namespace System.IdentityModel.Tokens
{
public class SessionSecurityTokenHandler : SecurityTokenHandler
{
public static readonly ReadOnlyCollection<CookieTransform> DefaultCookieTransforms;
public static readonly TimeSpan DefaultLifetime = TimeSpan.FromHours (10);
private bool canValidateToken;
private bool canWriteToken;
private string cookieElementName;
private string cookieNamespace;
private Type tokenType;
public override bool CanValidateToken { get { return canValidateToken; } }
public override bool CanWriteToken { get { return canWriteToken; } }
public virtual string CookieElementName { get { return cookieElementName; } }
public virtual string CookieNamespace { get { return cookieNamespace; } }
public static TimeSpan DefaultTokenLifetime { get { return SessionSecurityTokenHandler.DefaultLifetime; } }
public virtual TimeSpan TokenLifetime { get; set; }
public override Type TokenType { get { return tokenType; } }
public ReadOnlyCollection<CookieTransform> Transforms { get; private set; }
public SessionSecurityTokenHandler ()
: this (SessionSecurityTokenHandler.DefaultCookieTransforms)
{ }
public SessionSecurityTokenHandler (ReadOnlyCollection<CookieTransform> transforms)
: this (transforms, SessionSecurityTokenHandler.DefaultLifetime)
{ }
public SessionSecurityTokenHandler (ReadOnlyCollection<CookieTransform> transforms, TimeSpan tokenLifetime) {
Transforms = transforms;
TokenLifetime = tokenLifetime;
}
[MonoTODO]
protected virtual byte[] ApplyTransforms (byte[] cookie, bool outbound) {
throw new NotImplementedException ();
}
[MonoTODO]
public override bool CanReadToken (XmlReader reader) {
throw new NotImplementedException ();
}
[MonoTODO]
public virtual SessionSecurityToken CreateSessionSecurityToken (ClaimsPrincipal principal, string context, string endpointId, DateTime validFrom, DateTime validTo) {
throw new NotImplementedException ();
}
[MonoTODO]
public override SecurityToken CreateToken (SecurityTokenDescriptor tokenDescriptor) {
throw new NotImplementedException ();
}
[MonoTODO]
public override string[] GetTokenTypeIdentifiers () {
throw new NotImplementedException ();
}
[MonoTODO]
public override void LoadCustomConfiguration (XmlNodeList customConfigElements) {
throw new NotImplementedException ();
}
[MonoTODO]
public override SecurityToken ReadToken (XmlReader reader) {
throw new NotImplementedException ();
}
[MonoTODO]
public virtual SecurityToken ReadToken (byte[] token, SecurityTokenResolver tokenResolver) {
throw new NotImplementedException ();
}
[MonoTODO]
public override SecurityToken ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver) {
throw new NotImplementedException ();
}
[MonoTODO]
protected void SetTransforms (IEnumerable<CookieTransform> transforms) {
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual void ValidateSession (SessionSecurityToken securityToken) {
throw new NotImplementedException ();
}
[MonoTODO]
public override ReadOnlyCollection<ClaimsIdentity> ValidateToken (SecurityToken token) {
throw new NotImplementedException ();
}
[MonoTODO]
public virtual ReadOnlyCollection<ClaimsIdentity> ValidateToken (SessionSecurityToken token, string endpointId) {
throw new NotImplementedException ();
}
[MonoTODO]
public virtual byte[] WriteToken (SessionSecurityToken sessionToken) {
throw new NotImplementedException ();
}
[MonoTODO]
public override void WriteToken (XmlWriter writer, SecurityToken token) {
throw new NotImplementedException ();
}
}
}
#endif

View File

@ -0,0 +1,52 @@
//
// TokenReplayCache.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.IdentityModel.Configuration;
using System.Xml;
namespace System.IdentityModel.Tokens
{
public abstract class TokenReplayCache : ICustomIdentityConfiguration
{
public abstract void AddOrUpdate (string key, SecurityToken securityToken, DateTime expirationTime);
public abstract bool Contains (string key);
public abstract SecurityToken Get (string key);
[MonoTODO]
public virtual void LoadCustomConfiguration (XmlNodeList nodelist) {
throw new NotImplementedException ();
}
public abstract void Remove (string key);
}
}
#endif

View File

@ -84,24 +84,62 @@ namespace System.IdentityModel.Tokens
switch (algorithm) {
//case SignedXml.XmlDsigDSAUrl: // it is documented as supported, but it isn't in reality and it wouldn't be possible.
case SignedXml.XmlDsigRSASHA1Url:
return new HMACSHA1 ();
return new SHA1Managed ();
case SecurityAlgorithms.RsaSha256Signature:
return new HMACSHA256 ();
return new SHA256Managed ();
default:
throw new NotSupportedException (String.Format ("'{0}' Hash algorithm is not supported in this security key.", algorithm));
}
}
[MonoTODO]
public override AsymmetricSignatureDeformatter GetSignatureDeformatter (string algorithm)
{
throw new NotImplementedException ();
switch (algorithm) {
//case SignedXml.XmlDsigDSAUrl:
// DSA dsa = (cert.PublicKey.Key as DSA);
// if (dsa == null) {
// throw new NotSupportedException (String.Format ("The certificate does not contain DSA public key while '{0}' requires it.", algorithm));
// }
// else {
// return new DSASignatureDeformatter(dsa);
// }
case SignedXml.XmlDsigRSASHA1Url:
case SecurityAlgorithms.RsaSha256Signature:
RSA rsa = (cert.PublicKey.Key as RSA);
if (rsa == null) {
throw new NotSupportedException (String.Format ("The certificate does not contain RSA public key while '{0}' requires it.", algorithm));
}
else {
return new RSAPKCS1SignatureDeformatter (rsa);
}
default:
throw new NotSupportedException (String.Format ("'{0}' Hash algorithm is not supported in this security key.", algorithm));
}
}
[MonoTODO]
public override AsymmetricSignatureFormatter GetSignatureFormatter (string algorithm)
{
throw new NotImplementedException ();
switch (algorithm) {
//case SignedXml.XmlDsigDSAUrl:
// DSA dsa = (cert.PrivateKey as DSA);
// if (dsa == null) {
// throw new NotSupportedException (String.Format ("The certificate does not contain DSA private key while '{0}' requires it.", algorithm));
// }
// else {
// return new DSASignatureFormatter(dsa);
// }
case SignedXml.XmlDsigRSASHA1Url:
case SecurityAlgorithms.RsaSha256Signature:
RSA rsa = (cert.PrivateKey as RSA);
if (rsa == null) {
throw new NotSupportedException (String.Format ("The certificate does not contain RSA private key while '{0}' requires it.", algorithm));
}
else {
return new RSAPKCS1SignatureFormatter (rsa);
}
default:
throw new NotSupportedException (String.Format ("'{0}' Hash algorithm is not supported in this security key.", algorithm));
}
}
public override bool HasPrivateKey ()

View File

@ -0,0 +1,62 @@
//
// X509SigningCredentials.cs
//
// Author:
// Noesis Labs (Ryan.Melena@noesislabs.com)
//
// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using System.Security.Cryptography.X509Certificates;
namespace System.IdentityModel.Tokens
{
public class X509SigningCredentials : SigningCredentials
{
public X509Certificate2 Certificate { get; private set; }
public X509SigningCredentials (X509Certificate2 certificate)
: this (certificate, X509SigningCredentials.GetSecurityKeyIdentifier (certificate), SecurityAlgorithms.RsaSha256Signature, SecurityAlgorithms.Sha256Digest)
{ }
public X509SigningCredentials (X509Certificate2 certificate, SecurityKeyIdentifier ski)
: this (certificate, ski, SecurityAlgorithms.RsaSha256Signature, SecurityAlgorithms.Sha256Digest)
{ }
public X509SigningCredentials (X509Certificate2 certificate, string signatureAlgorithm, string digestAlgorithm)
: this (certificate, X509SigningCredentials.GetSecurityKeyIdentifier (certificate), signatureAlgorithm, digestAlgorithm)
{ }
public X509SigningCredentials (X509Certificate2 certificate, SecurityKeyIdentifier ski, string signatureAlgorithm, string digestAlgorithm)
: base (new X509SecurityToken (certificate).SecurityKeys[0], signatureAlgorithm, digestAlgorithm, ski)
{
Certificate = certificate;
}
private static SecurityKeyIdentifier GetSecurityKeyIdentifier (X509Certificate2 certificate) {
return new SecurityKeyIdentifier (new X509SecurityToken (certificate).CreateKeyIdentifierClause<X509RawDataKeyIdentifierClause> ());
}
}
}
#endif