Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,113 @@
//
// AuthenticatorCommunicationObject.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc. http://www.novell.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.
//
using System;
using System.Collections.Generic;
using System.Net.Security;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Security;
using System.ServiceModel.Security.Tokens;
using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
namespace System.ServiceModel.Security.Tokens
{
abstract class AuthenticatorCommunicationObject : CommunicationObject
{
public abstract Message ProcessNegotiation (Message request, TimeSpan timeout);
Binding issuer_binding;
EndpointAddress issuer_address;
Uri listen_uri;
KeyedByTypeCollection<IEndpointBehavior> behaviors =
new KeyedByTypeCollection<IEndpointBehavior> ();
SecurityTokenSerializer serializer;
SecurityAlgorithmSuite algorithm;
SecurityBindingElement element;
public EndpointAddress IssuerAddress {
get { return issuer_address; }
set { issuer_address = value; }
}
public Uri ListenUri {
get { return listen_uri; }
set { listen_uri = value; }
}
public Binding IssuerBinding {
get { return issuer_binding; }
set { issuer_binding = value; }
}
public KeyedByTypeCollection<IEndpointBehavior> IssuerChannelBehaviors {
get { return behaviors; }
}
public SecurityAlgorithmSuite SecurityAlgorithmSuite {
get { return algorithm; }
set { algorithm= value; }
}
public SecurityBindingElement SecurityBindingElement {
get { return element; }
set { element = value; }
}
public SecurityTokenSerializer SecurityTokenSerializer {
get { return serializer; }
set { serializer = value; }
}
protected void EnsureProperties ()
{
if (State == CommunicationState.Opened)
throw new InvalidOperationException ("Already opened.");
if (SecurityTokenSerializer == null)
throw new InvalidOperationException ("Security token serializer must be set before opening the token provider.");
if (IssuerAddress == null)
throw new InvalidOperationException ("Issuer address must be set before opening the token provider.");
if (IssuerBinding == null)
throw new InvalidOperationException ("IssuerBinding must be set before opening the token provider.");
if (SecurityAlgorithmSuite == null)
throw new InvalidOperationException ("Security algorithm suite must be set before opening the token provider.");
if (ListenUri == null)
throw new InvalidOperationException ("Listening uri must be set before opening the token provider.");
if (SecurityBindingElement == null)
throw new InvalidOperationException ("SecurityBindingElement must be set before opening the token provider.");
}
}
}

View File

@@ -0,0 +1,119 @@
//
// BinarySecretSecurityToken.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System;
using System.Collections.ObjectModel;
using System.Xml;
using System.IdentityModel.Policy;
using System.IdentityModel.Tokens;
namespace System.ServiceModel.Security.Tokens
{
public class BinarySecretSecurityToken : SecurityToken
{
ReadOnlyCollection<SecurityKey> keys;
string id;
byte [] key;
bool allow_crypto;
DateTime valid_from = DateTime.Now.ToUniversalTime ();
BinarySecretSecurityToken (string id, bool allowCrypto)
{
this.id = id;
allow_crypto = allowCrypto;
}
public BinarySecretSecurityToken (byte [] key)
: this ("uuid:" + Guid.NewGuid ().ToString (), key)
{
}
public BinarySecretSecurityToken (string id, byte [] key)
: this (id, key, false)
{
}
protected BinarySecretSecurityToken (string id, byte [] key, bool allowCrypto)
: this (id, allowCrypto)
{
if (key == null)
throw new ArgumentNullException ("key");
this.key = key;
SecurityKey [] arr = new SecurityKey [] {new InMemorySymmetricSecurityKey (key)};
keys = new ReadOnlyCollection<SecurityKey> (arr);
}
public BinarySecretSecurityToken (int keySizeInBits)
: this ("uuid:" + Guid.NewGuid ().ToString (), keySizeInBits)
{
}
public BinarySecretSecurityToken (string id, int keySizeInBits)
: this (id, keySizeInBits, false)
{
}
protected BinarySecretSecurityToken (string id, int keySizeInBits, bool allowCrypto)
: this (id, allowCrypto)
{
if (keySizeInBits < 0)
throw new ArgumentOutOfRangeException ("keySizeInBits");
this.key = new byte [keySizeInBits >> 3 + (keySizeInBits % 8 == 0 ? 0 : 1)];
SecurityKey [] arr = new SecurityKey [] {new InMemorySymmetricSecurityKey (key)};
keys = new ReadOnlyCollection<SecurityKey> (arr);
}
public override DateTime ValidFrom {
get { return valid_from; }
}
public override DateTime ValidTo {
get { return DateTime.MaxValue.AddDays (-1); }
}
public override string Id {
get { return id; }
}
public int KeySize {
get { return key.Length; }
}
public override ReadOnlyCollection<SecurityKey> SecurityKeys {
get { return keys; }
}
public byte [] GetKeyBytes ()
{
return (byte []) key.Clone ();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
//
// ClaimTypeRequirement.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
namespace System.ServiceModel.Security.Tokens
{
public class ClaimTypeRequirement
{
public ClaimTypeRequirement (string claimType)
: this (claimType, false)
{
}
public ClaimTypeRequirement (string claimType, bool isOptional)
{
claim_type = claimType;
is_optional = isOptional;
}
public string ClaimType {
get { return claim_type; }
}
public bool IsOptional {
get { return is_optional; }
}
string claim_type;
bool is_optional;
}
}

View File

@@ -0,0 +1,155 @@
//
// CommunicationSecurityTokenAuthenticator.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc. http://www.novell.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.
//
using System.Collections.ObjectModel;
using System.IdentityModel.Policy;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
namespace System.ServiceModel.Security.Tokens
{
abstract class CommunicationSecurityTokenAuthenticator
: SecurityTokenAuthenticator, ICommunicationObject,
IIssuanceSecurityTokenAuthenticator
{
protected CommunicationSecurityTokenAuthenticator ()
{
}
IssuedSecurityTokenHandler issuance_handler;
RenewedSecurityTokenHandler renew_handler;
public IssuedSecurityTokenHandler IssuedSecurityTokenHandler {
get { return issuance_handler; }
set { issuance_handler = value; }
}
public RenewedSecurityTokenHandler RenewedSecurityTokenHandler {
get { return renew_handler; }
set { renew_handler = value; }
}
public abstract AuthenticatorCommunicationObject Communication { get; }
[MonoTODO]
protected override bool CanValidateTokenCore (SecurityToken token)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected override ReadOnlyCollection<IAuthorizationPolicy> ValidateTokenCore (SecurityToken token)
{
throw new NotImplementedException ();
}
public CommunicationState State {
get { return Communication.State; }
}
public void Abort ()
{
Communication.Abort ();
}
public void Open ()
{
Communication.Open ();
}
public void Open (TimeSpan timeout)
{
Communication.Open (timeout);
}
public IAsyncResult BeginOpen (AsyncCallback callback, object state)
{
return Communication.BeginOpen (callback, state);
}
public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
{
return Communication.BeginOpen (timeout, callback, state);
}
public void EndOpen (IAsyncResult result)
{
Communication.EndOpen (result);
}
public void Close ()
{
Communication.Close ();
}
public void Close (TimeSpan timeout)
{
Communication.Close (timeout);
}
public IAsyncResult BeginClose (AsyncCallback callback, object state)
{
return Communication.BeginClose (callback, state);
}
public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state)
{
return Communication.BeginClose (timeout, callback, state);
}
public void EndClose (IAsyncResult result)
{
Communication.EndClose (result);
}
public event EventHandler Opening {
add { Communication.Opening += value; }
remove { Communication.Opening -= value; }
}
public event EventHandler Opened {
add { Communication.Opened += value; }
remove { Communication.Opened -= value; }
}
public event EventHandler Closing {
add { Communication.Closing += value; }
remove { Communication.Closing -= value; }
}
public event EventHandler Closed {
add { Communication.Closed += value; }
remove { Communication.Closed -= value; }
}
public event EventHandler Faulted {
add { Communication.Faulted += value; }
remove { Communication.Faulted -= value; }
}
}
}

View File

@@ -0,0 +1,140 @@
//
// CommunicationSecurityTokenProvider.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System;
using System.Collections.Generic;
using System.Net.Security;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Security;
using System.ServiceModel.Security.Tokens;
using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
namespace System.ServiceModel.Security.Tokens
{
abstract class CommunicationSecurityTokenProvider : SecurityTokenProvider, ICommunicationObject
{
public abstract ProviderCommunicationObject Communication { get; }
protected override SecurityToken GetTokenCore (TimeSpan timeout)
{
if (State != CommunicationState.Opened)
throw new InvalidOperationException ("Open the provider before issuing actual request to get token.");
return GetOnlineToken (timeout);
}
public abstract SecurityToken GetOnlineToken (TimeSpan timeout);
public CommunicationState State {
get { return Communication.State; }
}
public void Abort ()
{
Communication.Abort ();
}
public void Open ()
{
Communication.Open ();
}
public void Open (TimeSpan timeout)
{
Communication.Open (timeout);
}
public IAsyncResult BeginOpen (AsyncCallback callback, object state)
{
return Communication.BeginOpen (callback, state);
}
public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
{
return Communication.BeginOpen (timeout, callback, state);
}
public void EndOpen (IAsyncResult result)
{
Communication.EndOpen (result);
}
public void Close ()
{
Communication.Close ();
}
public void Close (TimeSpan timeout)
{
Communication.Close (timeout);
}
public IAsyncResult BeginClose (AsyncCallback callback, object state)
{
return Communication.BeginClose (callback, state);
}
public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state)
{
return Communication.BeginClose (timeout, callback, state);
}
public void EndClose (IAsyncResult result)
{
Communication.EndClose (result);
}
public event EventHandler Opening {
add { Communication.Opening += value; }
remove { Communication.Opening -= value; }
}
public event EventHandler Opened {
add { Communication.Opened += value; }
remove { Communication.Opened -= value; }
}
public event EventHandler Closing {
add { Communication.Closing += value; }
remove { Communication.Closing -= value; }
}
public event EventHandler Closed {
add { Communication.Closed += value; }
remove { Communication.Closed -= value; }
}
public event EventHandler Faulted {
add { Communication.Faulted += value; }
remove { Communication.Faulted -= value; }
}
}
}

View File

@@ -0,0 +1,121 @@
using System;
using System.Collections.ObjectModel;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.Security.Cryptography.Xml;
using System.ServiceModel;
using System.ServiceModel.Security;
using System.Text;
namespace System.ServiceModel.Security.Tokens
{
internal class DerivedKeySecurityToken : SecurityToken
{
string algorithm;
SecurityKeyIdentifierClause reference;
SecurityToken resolved_token; // store resolved one.
int? generation, offset, length;
// properties
string id, name, label;
byte [] nonce;
ReadOnlyCollection<SecurityKey> keys;
ReferenceList reflist;
public DerivedKeySecurityToken (string id, string algorithm,
SecurityKeyIdentifierClause reference,
SymmetricSecurityKey referencedKey,
string name,
int? generation,
int? offset,
int? length,
string label,
byte [] nonce)
{
algorithm = algorithm ?? SecurityAlgorithms.Psha1KeyDerivation;
this.id = id;
this.algorithm = algorithm;
this.reference = reference;
this.generation = generation;
this.offset = offset;
this.length = length;
this.nonce = nonce;
this.name = name;
this.label = label;
SecurityKey key = new InMemorySymmetricSecurityKey (
referencedKey.GenerateDerivedKey (
algorithm,
Encoding.UTF8.GetBytes (label ?? Constants.WsscDefaultLabel),
nonce,
(length ?? 32) * 8,
offset ?? 0));
keys = new ReadOnlyCollection<SecurityKey> (
new SecurityKey [] {key});
}
public override string Id {
get { return id; }
}
public override ReadOnlyCollection<SecurityKey> SecurityKeys {
get { return keys; }
}
public override DateTime ValidFrom {
get { return resolved_token.ValidFrom; }
}
public override DateTime ValidTo {
get { return resolved_token.ValidTo; }
}
internal ReferenceList ReferenceList {
get { return reflist; }
set { reflist = value; }
}
public SecurityKeyIdentifierClause TokenReference {
get { return reference; }
}
public int? Generation {
get { return generation; }
}
public int? Length {
get { return length; }
}
public int? Offset {
get { return offset; }
}
public string Label {
get { return label; }
}
public byte [] Nonce {
get { return nonce; }
}
public string Name {
get { return name; }
}
public override bool MatchesKeyIdentifierClause (
SecurityKeyIdentifierClause keyIdentifierClause)
{
LocalIdKeyIdentifierClause l = keyIdentifierClause
as LocalIdKeyIdentifierClause;
return l != null && l.LocalId == Id;
}
public override SecurityKey ResolveKeyIdentifierClause (
SecurityKeyIdentifierClause keyIdentifierClause)
{
return MatchesKeyIdentifierClause (keyIdentifierClause) ?
keys [0] : null;
}
}
}

View File

@@ -0,0 +1,36 @@
//
// IIssuanceSecurityTokenAuthenticator.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
namespace System.ServiceModel.Security.Tokens
{
public interface IIssuanceSecurityTokenAuthenticator
{
IssuedSecurityTokenHandler IssuedSecurityTokenHandler { get; set; }
RenewedSecurityTokenHandler RenewedSecurityTokenHandler { get; set; }
}
}

View File

@@ -0,0 +1,51 @@
//
// ISecurityContextSecurityTokenCache.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System.Collections.ObjectModel;
using System.Xml;
namespace System.ServiceModel.Security.Tokens
{
public interface ISecurityContextSecurityTokenCache
{
void AddContext (SecurityContextSecurityToken token);
void ClearContexts ();
Collection<SecurityContextSecurityToken> GetAllContexts (UniqueId contextId);
SecurityContextSecurityToken GetContext (UniqueId contextId, UniqueId generation);
void RemoveAllContexts (UniqueId contextId);
void RemoveContext (UniqueId contextId, UniqueId generation);
bool TryAddContext (SecurityContextSecurityToken token);
void UpdateContextCachingTime (SecurityContextSecurityToken context, DateTime expirationTime);
}
}

View File

@@ -0,0 +1,66 @@
//
// InitiatorServiceModelSecurityTokenRequirement.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;
namespace System.ServiceModel.Security.Tokens
{
public sealed class InitiatorServiceModelSecurityTokenRequirement
: ServiceModelSecurityTokenRequirement
{
public InitiatorServiceModelSecurityTokenRequirement ()
{
Properties [ServiceModelSecurityTokenRequirement.IsInitiatorProperty] = true;
}
public EndpointAddress TargetAddress {
get {
EndpointAddress ret;
TryGetProperty<EndpointAddress> (TargetAddressProperty, out ret);
return ret;
}
set { Properties [TargetAddressProperty] = value; }
}
public Uri Via {
get {
Uri ret;
TryGetProperty<Uri> (ViaProperty, out ret);
return ret;
}
set { Properties [ViaProperty] = value; }
}
public override string ToString ()
{
return Dump ();
}
}
}

View File

@@ -0,0 +1,51 @@
//
// InternalEncryptedKeyIdentifierClause.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc. http://www.novell.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.
//
using System;
using System.Collections.ObjectModel;
using System.Security.Cryptography.Xml;
using System.Xml;
using System.IdentityModel.Tokens;
namespace System.ServiceModel.Security.Tokens
{
internal class InternalEncryptedKeyIdentifierClause : BinaryKeyIdentifierClause
{
public InternalEncryptedKeyIdentifierClause (byte [] hash)
: base (null, hash, false)
{
}
public override bool Matches (SecurityKeyIdentifierClause keyIdentifierClause)
{
InternalEncryptedKeyIdentifierClause kic = keyIdentifierClause as InternalEncryptedKeyIdentifierClause;
if (kic == null)
return false;
return Matches (kic.GetRawBuffer ());
}
}
}

View File

@@ -0,0 +1,35 @@
//
// IssuedSecurityTokenHandler .cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System.IdentityModel.Tokens;
using System.ServiceModel;
namespace System.ServiceModel.Security.Tokens
{
public delegate void IssuedSecurityTokenHandler (
SecurityToken issuedToken, EndpointAddress tokenRequestor);
}

View File

@@ -0,0 +1,202 @@
//
// IssuedSecurityTokenParameters.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System.Collections.ObjectModel;
using System.Xml;
using System.Xml.XPath;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;
using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
namespace System.ServiceModel.Security.Tokens
{
public class IssuedSecurityTokenParameters : SecurityTokenParameters
{
public IssuedSecurityTokenParameters ()
{
}
public IssuedSecurityTokenParameters (string tokenType)
: this (tokenType, null)
{
}
public IssuedSecurityTokenParameters (string tokenType, EndpointAddress issuerAddress)
: this (tokenType, issuerAddress, null)
{
}
public IssuedSecurityTokenParameters (string tokenType,
EndpointAddress issuerAddress, Binding issuerBinding)
{
token_type = tokenType;
issuer_address = issuerAddress;
binding = issuerBinding;
}
protected IssuedSecurityTokenParameters (IssuedSecurityTokenParameters source)
: base (source)
{
binding = source.binding;
issuer_address = source.issuer_address;
issuer_meta_address = source.issuer_meta_address;
key_size = source.key_size;
key_type = source.key_type;
token_type = source.token_type;
reqs = new Collection<ClaimTypeRequirement> (source.reqs);
additional_reqs = new Collection<XmlElement> (source.additional_reqs);
}
Binding binding;
EndpointAddress issuer_address, issuer_meta_address;
int key_size;
SecurityKeyType key_type;
string token_type;
Collection<ClaimTypeRequirement> reqs =
new Collection<ClaimTypeRequirement> ();
Collection<XmlElement> additional_reqs =
new Collection<XmlElement> ();
public override string ToString ()
{
return base.ToString ();
}
public Collection<XmlElement> AdditionalRequestParameters {
get { return additional_reqs; }
}
public Collection<ClaimTypeRequirement> ClaimTypeRequirements {
get { return reqs; }
}
protected override bool HasAsymmetricKey {
get { return false; }
}
public EndpointAddress IssuerAddress {
get { return issuer_address; }
set { issuer_address = value; }
}
public Binding IssuerBinding {
get { return binding; }
set { binding = value; }
}
public EndpointAddress IssuerMetadataAddress {
get { return issuer_meta_address; }
set { issuer_meta_address = value; }
}
public int KeySize {
get { return key_size; }
set { key_size = value; }
}
public SecurityKeyType KeyType {
get { return key_type; }
set { key_type = value; }
}
public string TokenType {
get { return token_type; }
set { token_type = value; }
}
protected override bool SupportsClientAuthentication {
get { return true; }
}
protected override bool SupportsClientWindowsIdentity {
get { return false; }
}
protected override bool SupportsServerAuthentication {
get { return true; }
}
protected override SecurityTokenParameters CloneCore ()
{
return new IssuedSecurityTokenParameters (this);
}
[MonoTODO]
protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
{
throw new NotImplementedException ();
}
public Collection<XmlElement> CreateRequestParameters (
MessageSecurityVersion messageSecurityVersion,
SecurityTokenSerializer securityTokenSerializer)
{
XmlDocument doc = new XmlDocument ();
Collection<XmlElement> ret = new Collection<XmlElement> ();
// KeyType
string keyTypeUri =
KeyType == SecurityKeyType.SymmetricKey ?
Constants.WstSymmetricKeyTypeUri :
Constants.WstAsymmetricKeyTypeUri;
XmlElement kt = doc.CreateElement ("t", "KeyType", Constants.WstNamespace);
kt.AppendChild (doc.CreateTextNode (keyTypeUri));
ret.Add (kt);
// ClaimTypes
XmlElement cts = doc.CreateElement ("t", "Claims", Constants.WstNamespace);
foreach (ClaimTypeRequirement req in ClaimTypeRequirements) {
XmlElement el = doc.CreateElement ("wsid", "ClaimType", Constants.WsidNamespace);
el.SetAttribute ("Uri", req.ClaimType);
if (req.IsOptional)
el.SetAttribute ("Optional", "true");
cts.AppendChild (el);
}
ret.Add (cts);
// Additional parameters
foreach (XmlElement el in AdditionalRequestParameters)
ret.Add (el);
return ret;
}
protected internal override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
{
if (requirement == null)
throw new ArgumentNullException ("requirement");
requirement.TokenType = TokenType;
requirement.Properties [ReqType.IssuedSecurityTokenParametersProperty] = this.Clone ();
requirement.Properties [ReqType.IssuerAddressProperty] = IssuerAddress;
requirement.Properties [ReqType.IssuerBindingProperty] = IssuerBinding;
requirement.RequireCryptographicToken = true;
requirement.KeyType = KeyType;
}
}
}

View File

@@ -0,0 +1,259 @@
//
// IssuedSecurityTokenProvider.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Xml;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Security;
namespace System.ServiceModel.Security.Tokens
{
public class IssuedSecurityTokenProvider : SecurityTokenProvider, ICommunicationObject
{
public IssuedSecurityTokenProvider ()
{
}
IssuedTokenCommunicationObject comm =
new IssuedTokenCommunicationObject ();
SecurityKeyEntropyMode entropy_mode =
SecurityKeyEntropyMode.CombinedEntropy;
TimeSpan max_cache_time = TimeSpan.MaxValue;
MessageSecurityVersion version = MessageSecurityVersion.Default;
int threshold = 60;
IdentityVerifier verifier = IdentityVerifier.CreateDefault ();
bool cache_issued_tokens = true;
Collection<XmlElement> request_params =
new Collection<XmlElement> ();
CommunicationState state = CommunicationState.Created;
internal IssuedTokenCommunicationObject Communication {
get { return comm; }
}
public bool CacheIssuedTokens {
get { return cache_issued_tokens; }
set { cache_issued_tokens = value; }
}
public virtual TimeSpan DefaultCloseTimeout {
get { return comm.DefaultCloseTimeout; }
}
public virtual TimeSpan DefaultOpenTimeout {
get { return comm.DefaultOpenTimeout; }
}
public IdentityVerifier IdentityVerifier {
get { return verifier; }
set { verifier = value; }
}
public int IssuedTokenRenewalThresholdPercentage {
get { return threshold; }
set { threshold = value; }
}
public EndpointAddress IssuerAddress {
get { return comm.IssuerAddress; }
set { comm.IssuerAddress = value; }
}
public Binding IssuerBinding {
get { return comm.IssuerBinding; }
set { comm.IssuerBinding = value; }
}
public KeyedByTypeCollection<IEndpointBehavior> IssuerChannelBehaviors {
get { return comm.IssuerChannelBehaviors; }
}
public SecurityKeyEntropyMode KeyEntropyMode {
get { return entropy_mode; }
set { entropy_mode = value; }
}
public TimeSpan MaxIssuedTokenCachingTime {
get { return max_cache_time; }
set { max_cache_time = value; }
}
public MessageSecurityVersion MessageSecurityVersion {
get { return version; }
set { version = value; }
}
public SecurityAlgorithmSuite SecurityAlgorithmSuite {
get { return comm.SecurityAlgorithmSuite; }
set { comm.SecurityAlgorithmSuite = value; }
}
public SecurityTokenSerializer SecurityTokenSerializer {
get { return comm.SecurityTokenSerializer; }
set { comm.SecurityTokenSerializer = value; }
}
public EndpointAddress TargetAddress {
get { return comm.TargetAddress; }
set { comm.TargetAddress = value; }
}
public Collection<XmlElement> TokenRequestParameters {
get { return request_params; }
}
// SecurityTokenProvider
[MonoTODO ("support it then")]
public override bool SupportsTokenCancellation {
get { return true; }
}
[MonoTODO]
protected override SecurityToken GetTokenCore (TimeSpan timeout)
{
if (State != CommunicationState.Opened)
throw new InvalidOperationException ("Open the provider before issuing actual request to get token.");
return comm.GetToken (timeout);
}
[MonoTODO]
protected override IAsyncResult BeginGetTokenCore (
TimeSpan timeout,
AsyncCallback callback, object state)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected override SecurityToken EndGetTokenCore (IAsyncResult result)
{
throw new NotImplementedException ();
}
// ICommunicationObject
public CommunicationState State {
get { return comm.State; }
}
[MonoTODO]
public void Abort ()
{
comm.Abort ();
}
public void Open ()
{
comm.Open ();
}
[MonoTODO]
public void Open (TimeSpan timeout)
{
comm.Open (timeout);
}
public IAsyncResult BeginOpen (AsyncCallback callback, object state)
{
return comm.BeginOpen (callback, state);
}
[MonoTODO]
public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
{
return comm.BeginOpen (timeout, callback, state);
}
[MonoTODO]
public void EndOpen (IAsyncResult result)
{
comm.EndOpen (result);
}
public void Close ()
{
comm.Close ();
}
[MonoTODO]
public void Close (TimeSpan timeout)
{
comm.Close (timeout);
}
public IAsyncResult BeginClose (AsyncCallback callback, object state)
{
return comm.BeginClose (callback, state);
}
[MonoTODO]
public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state)
{
return comm.BeginClose (timeout, callback, state);
}
[MonoTODO]
public void EndClose (IAsyncResult result)
{
comm.EndClose (result);
}
public void Dispose ()
{
Close ();
}
public event EventHandler Opened {
add { comm.Opened += value; }
remove { comm.Opened -= value; }
}
public event EventHandler Opening {
add { comm.Opening += value; }
remove { comm.Opening -= value; }
}
public event EventHandler Closed {
add { comm.Closed += value; }
remove { comm.Closed -= value; }
}
public event EventHandler Closing {
add { comm.Closing += value; }
remove { comm.Closing -= value; }
}
public event EventHandler Faulted {
add { comm.Faulted += value; }
remove { comm.Faulted -= value; }
}
}
}

View File

@@ -0,0 +1,116 @@
//
// IssuedTokenCommunicationObject.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Xml;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Security;
namespace System.ServiceModel.Security.Tokens
{
class IssuedTokenCommunicationObject : ProviderCommunicationObject
{
WSTrustSecurityTokenServiceProxy comm;
public SecurityToken GetToken (TimeSpan timeout)
{
WstRequestSecurityToken req = new WstRequestSecurityToken ();
BodyWriter body = new WstRequestSecurityTokenWriter (req, SecurityTokenSerializer);
Message msg = Message.CreateMessage (IssuerBinding.MessageVersion, Constants.WstIssueAction, body);
Message res = comm.Issue (msg);
// FIXME: provide SecurityTokenResolver (but from where?)
using (WSTrustRequestSecurityTokenResponseReader resreader = new WSTrustRequestSecurityTokenResponseReader (null, res.GetReaderAtBodyContents (), SecurityTokenSerializer, null)) {
WstRequestSecurityTokenResponse rstr = resreader.Read ();
if (rstr.RequestedSecurityToken != null)
return rstr.RequestedSecurityToken;
throw new NotImplementedException ("IssuedSecurityTokenProvider did not see RequestedSecurityToken in the response.");
}
}
protected internal override TimeSpan DefaultCloseTimeout {
get { return comm == null ? DefaultCommunicationTimeouts.Instance.CloseTimeout : comm.ChannelFactory.DefaultCloseTimeout; }
}
protected internal override TimeSpan DefaultOpenTimeout {
get { return comm == null ? DefaultCommunicationTimeouts.Instance.OpenTimeout : comm.ChannelFactory.DefaultOpenTimeout; }
}
protected override void OnAbort ()
{
throw new NotImplementedException ();
}
protected override void OnOpen (TimeSpan timeout)
{
if (comm != null)
throw new InvalidOperationException ("Already opened.");
EnsureProperties ();
comm = new WSTrustSecurityTokenServiceProxy (
IssuerBinding, IssuerAddress);
KeyedByTypeCollection<IEndpointBehavior> bl =
comm.Endpoint.Behaviors;
foreach (IEndpointBehavior b in IssuerChannelBehaviors) {
bl.Remove (b.GetType ());
bl.Add (b);
}
comm.Open ();
}
protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
{
throw new NotImplementedException ();
}
protected override void OnEndOpen (IAsyncResult result)
{
throw new NotImplementedException ();
}
protected override void OnClose (TimeSpan timeout)
{
comm.Close ();
}
protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
{
throw new NotImplementedException ();
}
protected override void OnEndClose (IAsyncResult result)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,86 @@
//
// KerberosSecurityTokenParameters.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.ServiceModel.Security;
namespace System.ServiceModel.Security.Tokens
{
public class KerberosSecurityTokenParameters : SecurityTokenParameters
{
public KerberosSecurityTokenParameters ()
{
}
protected KerberosSecurityTokenParameters (KerberosSecurityTokenParameters source)
: base (source)
{
}
[MonoTODO]
protected override bool HasAsymmetricKey {
get { throw new NotImplementedException (); }
}
[MonoTODO]
protected override bool SupportsClientAuthentication {
get { throw new NotImplementedException (); }
}
[MonoTODO]
protected override bool SupportsClientWindowsIdentity {
get { throw new NotImplementedException (); }
}
[MonoTODO]
protected override bool SupportsServerAuthentication {
get { throw new NotImplementedException (); }
}
protected override SecurityTokenParameters CloneCore ()
{
return new KerberosSecurityTokenParameters (this);
}
[MonoTODO]
protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
{
throw new NotImplementedException ();
}
protected internal override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
{
if (requirement == null)
throw new ArgumentNullException ("requirement");
requirement.TokenType = SecurityTokenTypes.Kerberos;
requirement.RequireCryptographicToken = true;
requirement.KeyType = SecurityKeyType.SymmetricKey;
}
}
}

View File

@@ -0,0 +1,102 @@
//
// ProviderCommunicationObject.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System;
using System.Collections.Generic;
using System.Net.Security;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Security;
using System.ServiceModel.Security.Tokens;
using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
namespace System.ServiceModel.Security.Tokens
{
abstract class ProviderCommunicationObject : CommunicationObject
{
Binding issuer_binding;
EndpointAddress issuer_address, target_address;
KeyedByTypeCollection<IEndpointBehavior> behaviors =
new KeyedByTypeCollection<IEndpointBehavior> ();
SecurityTokenSerializer serializer;
SecurityAlgorithmSuite algorithm;
public EndpointAddress IssuerAddress {
get { return issuer_address; }
set { issuer_address = value; }
}
public EndpointAddress TargetAddress {
get { return target_address; }
set { target_address = value; }
}
public Binding IssuerBinding {
get { return issuer_binding; }
set { issuer_binding = value; }
}
public KeyedByTypeCollection<IEndpointBehavior> IssuerChannelBehaviors {
get { return behaviors; }
}
public SecurityAlgorithmSuite SecurityAlgorithmSuite {
get { return algorithm; }
set { algorithm= value; }
}
public SecurityTokenSerializer SecurityTokenSerializer {
get { return serializer; }
set { serializer = value; }
}
protected void EnsureProperties ()
{
if (State == CommunicationState.Opened)
throw new InvalidOperationException ("Already opened.");
if (SecurityTokenSerializer == null)
throw new InvalidOperationException ("Security token serializer must be set before opening the token provider.");
if (IssuerAddress == null)
throw new InvalidOperationException ("Issuer address must be set before opening the token provider.");
if (IssuerBinding == null)
throw new InvalidOperationException ("IssuerBinding must be set before opening the token provider.");
if (SecurityAlgorithmSuite == null)
throw new InvalidOperationException ("Security algorithm suite must be set before opening the token provider.");
if (TargetAddress == null)
throw new InvalidOperationException ("Target address must be set before opening the token provider.");
}
}
}

View File

@@ -0,0 +1,83 @@
//
// RecipientServiceModelSecurityTokenRequirement.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;
namespace System.ServiceModel.Security.Tokens
{
public sealed class RecipientServiceModelSecurityTokenRequirement
: ServiceModelSecurityTokenRequirement
{
public RecipientServiceModelSecurityTokenRequirement ()
{
}
public AuditLogLocation AuditLogLocation {
get {
AuditLogLocation ret;
TryGetProperty<AuditLogLocation> (AuditLogLocationProperty, out ret);
return ret;
}
set { Properties [AuditLogLocationProperty] = value; }
}
public Uri ListenUri {
get {
Uri ret;
TryGetProperty<Uri> (ListenUriProperty, out ret);
return ret;
}
set { Properties [ListenUriProperty] = value; }
}
public AuditLevel MessageAuthenticationAuditLevel {
get {
AuditLevel ret;
TryGetProperty<AuditLevel> (MessageAuthenticationAuditLevelProperty, out ret);
return ret;
}
set { Properties [MessageAuthenticationAuditLevelProperty] = value; }
}
public bool SuppressAuditFailure {
get {
bool ret;
TryGetProperty<bool> (SuppressAuditFailureProperty, out ret);
return ret;
}
set { Properties [SuppressAuditFailureProperty] = value; }
}
public override string ToString ()
{
return Dump ();
}
}
}

View File

@@ -0,0 +1,35 @@
//
// RenewedSecurityTokenHandler.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System.IdentityModel.Tokens;
namespace System.ServiceModel.Security.Tokens
{
public delegate void RenewedSecurityTokenHandler (
SecurityToken newSecurityToken,
SecurityToken oldSecurityToken);
}

View File

@@ -0,0 +1,88 @@
//
// RsaSecurityTokenParameters.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc. http://www.novell.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.
//
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.ServiceModel.Security;
namespace System.ServiceModel.Security.Tokens
{
public class RsaSecurityTokenParameters : SecurityTokenParameters
{
public RsaSecurityTokenParameters ()
{
InclusionMode = SecurityTokenInclusionMode.Never;
RequireDerivedKeys = true;
}
protected RsaSecurityTokenParameters (RsaSecurityTokenParameters source)
: base (source)
{
}
protected override bool HasAsymmetricKey {
get { return true; }
}
protected override bool SupportsClientAuthentication {
get { return true; }
}
protected override bool SupportsClientWindowsIdentity {
get { return false; }
}
protected override bool SupportsServerAuthentication {
get { return true; }
}
protected override SecurityTokenParameters CloneCore ()
{
return new RsaSecurityTokenParameters (this);
}
protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
{
if (token == null)
throw new ArgumentNullException ("token");
RsaSecurityToken rt = token as RsaSecurityToken;
if (rt == null)
throw new NotSupportedException (String.Format ("Cannot create a key identifier clause from this security token '{0}'", token));
return new RsaKeyIdentifierClause (rt.Rsa);
}
protected internal override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
{
if (requirement == null)
throw new ArgumentNullException ("requirement");
requirement.TokenType = SecurityTokenTypes.Rsa;
requirement.RequireCryptographicToken = true;
requirement.KeyType = SecurityKeyType.AsymmetricKey;
}
}
}

Some files were not shown because too many files have changed in this diff Show More