Author: atsushi
Date: 2007-04-02 06:23:56 -0400 (Mon, 02 Apr 2007)
New Revision: 75276

Modified:
   trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ChangeLog
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/CommunicationSecurityTokenAuthenticator.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityToken.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenAuthenticator.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenProvider.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslnegoCookieResolver.cs
   trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
   
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
   
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManagerTest.cs
Log:
2007-04-02  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * SecureMessageGenerator.cs : SecurityContextToken support (though
          it is still regarded as invalid by WCF).

        * SecurityContextSecurityToken.cs : Cookie needs a setter.
        * SslnegoCookieResolver.cs : set Cookie so that it can be serialized.
        * SslSecurityTokenProvider.cs, SslSecurityTokenAuthenticator.cs :
          (At provider) check contextId returned by the server.
          Reverted ProofToken value (see comments).
        * CommunicationSecurityTokenAuthenticator.cs : it now implements
          IIssuanceSecurityTokenAuthenticator.

        * WSSecurityTokenSerializer.cs : set cookie property for such tokens
          that was created from cookie binary.

        * ServiceCredentialsSecurityTokenManagerTest.cs : test that ssl
          authenticator implements IIssuanceSecurityTokenAuthenticator.



Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog    
    2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog    
    2007-04-02 10:23:56 UTC (rev 75276)
@@ -1,3 +1,8 @@
+2007-04-02  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * SecureMessageGenerator.cs : SecurityContextToken support (though
+         it is still regarded as invalid by WCF).
+
 2007-03-13  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * WSSecurityMessageHeader.cs, SecureMessageGenerator.cs :

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
        2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
        2007-04-02 10:23:56 UTC (rev 75276)
@@ -303,7 +303,7 @@
                        nsmgr.AddNamespace ("u", Constants.WsuNamespace);
                        nsmgr.AddNamespace ("o11", Constants.Wss11Namespace);
 
-                       WrappedKeySecurityToken primaryToken = null;
+                       /*WrappedKey*/SecurityToken primaryToken = null;
                        DerivedKeySecurityToken dkeyToken = null;
                        SecurityToken actualToken = null;
                        SecurityKeyIdentifierClause actualClause = null;
@@ -325,10 +325,10 @@
                        // - done or notyet. FIXME: not implemented yet
                        // It also affects on key reference output
 
-                       bool includeEncToken = /* FIXME: remove this hack */ 
Parameters is SslSecurityTokenParameters ? false :
+                       bool includeEncToken = // /* FIXME: remove this hack 
*/Parameters is SslSecurityTokenParameters ? false :
                                                ShouldIncludeToken (
                                Security.RecipientParameters.InclusionMode, 
false);
-                       bool includeSigToken = /* FIXME: remove this hack */ 
Parameters is SslSecurityTokenParameters ? false :
+                       bool includeSigToken = // /* FIXME: remove this hack */ 
Parameters is SslSecurityTokenParameters ? false :
                                                ShouldIncludeToken (
                                Security.InitiatorParameters.InclusionMode, 
false);
 
@@ -347,7 +347,10 @@
 if (!ShouldOutputEncryptedKey)
 primaryToken = 
RequestContext.RequestMessage.Properties.Security.ProtectionToken.SecurityToken 
as WrappedKeySecurityToken;
 else
-                       primaryToken = new WrappedKeySecurityToken (messageId + 
"-" + identForMessageId++,
+                       primaryToken =
+                               // FIXME: remove this hack?
+                               encToken is SecurityContextSecurityToken ? 
encToken :
+                               new WrappedKeySecurityToken (messageId + "-" + 
identForMessageId++,
                                actualKey.Key,
                                // security.DefaultKeyWrapAlgorithm,
                                Parameters.InternalHasAsymmetricKey ?
@@ -363,7 +366,7 @@
                        actualToken = primaryToken;
 
                        // FIXME: I doubt it is correct...
-                       WrappedKeySecurityToken requestEncKey = 
ShouldOutputEncryptedKey ? null : primaryToken;
+                       WrappedKeySecurityToken requestEncKey = 
ShouldOutputEncryptedKey ? null : primaryToken as WrappedKeySecurityToken;
                        actualClause = requestEncKey == null ? 
(SecurityKeyIdentifierClause)
                                new LocalIdKeyIdentifierClause (actualToken.Id, 
typeof (WrappedKeySecurityToken)) :
                                new InternalEncryptedKeyIdentifierClause 
(SHA1.Create ().ComputeHash (requestEncKey.GetWrappedKey ()));
@@ -403,7 +406,7 @@
                            !ShouldOutputEncryptedKey)
                                header.AddContent (refList);
                        else
-                               primaryToken.ReferenceList = refList;
+                               ((WrappedKeySecurityToken) 
primaryToken).ReferenceList = refList;
 
                        // [Signature Confirmation]
                        if (security.RequireSignatureConfirmation && 
secprop.ConfirmedSignatures.Count > 0)

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog    
    2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog    
    2007-04-02 10:23:56 UTC (rev 75276)
@@ -1,5 +1,10 @@
 2007-04-02  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * WSSecurityTokenSerializer.cs : set cookie property for such tokens
+         that was created from cookie binary.
+
+2007-04-02  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * DataProtectionSecurityStateEncoder.cs : oops, Encode->Protect,
          Decode->Unprotect.
 

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
     2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
     2007-04-02 10:23:56 UTC (rev 75276)
@@ -547,7 +547,7 @@
                                cookie != null && cookie.Length > 154 ?
                                encoder.DecodeSecurityState (cookie) :
                                cookie;
-                       return SslnegoCookieResolver.ResolveCookie (decoded);
+                       return SslnegoCookieResolver.ResolveCookie (decoded, 
cookie);
                }
 
                WrappedKeySecurityToken ReadWrappedKeySecurityTokenCore (

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ChangeLog
 2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ChangeLog
 2007-04-02 10:23:56 UTC (rev 75276)
@@ -1,3 +1,13 @@
+2007-04-02  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * SecurityContextSecurityToken.cs : Cookie needs a setter.
+       * SslnegoCookieResolver.cs : set Cookie so that it can be serialized.
+       * SslSecurityTokenProvider.cs, SslSecurityTokenAuthenticator.cs :
+         (At provider) check contextId returned by the server.
+         Reverted ProofToken value (see comments).
+       * CommunicationSecurityTokenAuthenticator.cs : it now implements
+         IIssuanceSecurityTokenAuthenticator.
+
 2007-03-30  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * AuthenticatorCommunicationObject.cs : added SecurityBindingElement.

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/CommunicationSecurityTokenAuthenticator.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/CommunicationSecurityTokenAuthenticator.cs
        2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/CommunicationSecurityTokenAuthenticator.cs
        2007-04-02 10:23:56 UTC (rev 75276)
@@ -33,12 +33,27 @@
 
 namespace System.ServiceModel.Security.Tokens
 {
-       abstract class CommunicationSecurityTokenAuthenticator : 
SecurityTokenAuthenticator, ICommunicationObject
+       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]

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityToken.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityToken.cs
   2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityToken.cs
   2007-04-02 10:23:56 UTC (rev 75276)
@@ -183,6 +183,7 @@
 
                internal byte [] Cookie {
                        get { return cookie; }
+                       set { cookie = value; }
                }
 
                public override bool CanCreateKeyIdentifierClause<T> ()

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenAuthenticator.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenAuthenticator.cs
  2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenAuthenticator.cs
  2007-04-02 10:23:56 UTC (rev 75276)
@@ -202,6 +202,7 @@
                        // 
P_SHA1(encrypted_key,SHA1(exc14n(RST..RSTRs))+"CK-HASH")
                        byte [] hash = SHA1.Create ().ComputeHash 
(tlsInfo.Messages.ToArray ());
                        byte [] key = tls.CreateHash (tls.MasterSecret, hash, 
"CK-HASH");
+                       byte [] keyTlsApplied = tls.ProcessApplicationData 
(key);
 foreach (byte b in hash) Console.Write ("{0:X02} ", b); Console.WriteLine ();
 foreach (byte b in key) Console.Write ("{0:X02} ", b); Console.WriteLine ();
 
@@ -225,7 +226,9 @@
                                null,
                                
owner.Manager.ServiceCredentials.SecureConversationAuthentication.SecurityStateEncoder);
                        rstr.RequestedSecurityToken = sct;
-                       rstr.RequestedProofToken = tls.ProcessApplicationData 
(key);
+                       // without this ProcessApplicationData(), .NET seems
+                       // to fail recovering the key.
+                       rstr.RequestedProofToken = keyTlsApplied;
                        rstr.RequestedAttachedReference = new 
LocalIdKeyIdentifierClause (sct.Id);
                        rstr.RequestedUnattachedReference = new 
SecurityContextKeyIdentifierClause (sct.ContextId, null);
                        WstLifetime lt = new WstLifetime ();
@@ -245,6 +248,10 @@
 
                        sessions.Remove (reader.Value.Context);
 
+                       // FIXME: get correct tokenRequestor address (probably 
identity authorized?)
+                       if (owner.IssuedSecurityTokenHandler != null)
+                               owner.IssuedSecurityTokenHandler (sct, 
request.Headers.ReplyTo);
+
                        return Message.CreateMessage (request.Version, 
Constants.WstIssueReplyAction, col);
                }
 

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenProvider.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenProvider.cs
       2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenProvider.cs
       2007-04-02 10:23:56 UTC (rev 75276)
@@ -101,6 +101,7 @@
                        TlsClientSession tls = new TlsClientSession 
(IssuerAddress.Uri.ToString ());
                        WstRequestSecurityToken rst =
                                new WstRequestSecurityToken ();
+                       string contextId = rst.Context;
 
                        // send ClientHello
                        rst.BinaryExchange = new WstBinaryExchange 
(Constants.WstBinaryExchangeValueTls);
@@ -171,13 +172,16 @@
                        tlsctx.StoreMessage 
(XmlDictionaryReader.CreateDictionaryReader (new XmlNodeReader (doc)));
 #endif
 
+                       // the RequestedProofToken is represented as 32 bytes
+                       // of TLS ApplicationData.
+                       // - According to WSE2 doc, it is *the* key, but not
+                       //   sure it also applies to WCF.
+                       // - WSS4J also seems to store the encryped shared key.
+                       // - (Important) It seems that without tls decryption,
+                       //   .NET fails to recover the key.
                        byte [] proof = tls.ProcessApplicationData (
                                (byte []) r.RequestedProofToken);
-                       // the RequestedProofToken is represented as 32 bytes
-                       // of TLS ApplicationData. According to WSE2 doc, it
-                       // is *the* key, but not sure it also applies to WCF.
-                       // WSS4J also seems to store the encryped shared key.
-                       byte [] key = (byte []) r.RequestedProofToken;
+                       byte [] key = proof;
 
                        // Authenticate token.
 
@@ -185,6 +189,9 @@
                        if (actual == null)
                                throw new SecurityNegotiationException ("Token 
authenticator is expected in the RequestSecurityTokenResponse but not found.");
 
+                       if (coll.Responses [0].Context != contextId)
+                               throw new SecurityNegotiationException ("The 
context Id does not match with that of the corresponding token authenticator.");
+
                        // H = sha1(exc14n(RST..RSTRs))
                        byte [] hash = SHA1.Create ().ComputeHash 
(tlsctx.GetC14NResults ());
                        byte [] referent = tls.CreateHash (key, hash, 
"AUTH-HASH");
@@ -202,6 +209,7 @@
                                for (int i = 0; i < referent.Length; i++)
                                        if (referent [i] != actual [i])
                                                mismatch = true;
+                       // FIXME: enable verification
 //                     if (mismatch)
 //                             throw new SecurityNegotiationException ("The 
CombinedHash does not match the expected value.");
 

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslnegoCookieResolver.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslnegoCookieResolver.cs
  2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslnegoCookieResolver.cs
  2007-04-02 10:23:56 UTC (rev 75276)
@@ -85,7 +85,7 @@
 {
        internal class SslnegoCookieResolver
        {
-               public static SecurityContextSecurityToken ResolveCookie (byte 
[] bytes)
+               public static SecurityContextSecurityToken ResolveCookie (byte 
[] bytes, byte [] cookie)
                {
                        string id = null;
                        UniqueId context = null;
@@ -144,9 +144,11 @@
                                }
                        } while (true);
 
-                       return new SecurityContextSecurityToken (
+                       SecurityContextSecurityToken sct = new 
SecurityContextSecurityToken (
                                context, id, key, validFrom, validTo,
                                null, keyEffective, keyExpired, null);
+                       sct.Cookie = cookie;
+                       return sct;
                }
 
                public static byte [] CreateData (UniqueId contextId, UniqueId 
session, byte [] key, DateTime tokenSince, DateTime tokenUntil, DateTime 
keySince, DateTime keyUntil)

Modified: 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
   2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
   2007-04-02 10:23:56 UTC (rev 75276)
@@ -1,3 +1,8 @@
+2007-04-02  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * ServiceCredentialsSecurityTokenManagerTest.cs : test that ssl
+         authenticator implements IIssuanceSecurityTokenAuthenticator.
+
 2007-03-30  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * WSSecurityTokenSerializerTest.cs : removed SCT reader test which

Modified: 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManagerTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManagerTest.cs
       2007-04-02 10:12:43 UTC (rev 75275)
+++ 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManagerTest.cs
       2007-04-02 10:23:56 UTC (rev 75276)
@@ -492,6 +492,7 @@
                        SecurityTokenAuthenticator a = 
def_c.CreateSecurityTokenAuthenticator (r, out resolver);
                        // non-standard authenticator type.
                        Assert.IsNotNull (resolver, "#1");
+                       Assert.IsTrue (a is 
IIssuanceSecurityTokenAuthenticator, "#2");
 
                        try {
                                a.ValidateToken (new X509SecurityToken (cert));

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to