Author: atsushi
Date: 2007-01-12 12:14:09 -0500 (Fri, 12 Jan 2007)
New Revision: 70931
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/ChangeLog
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManager.cs
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
trunk/olive/class/System.ServiceModel/System.ServiceModel/ChangeLog
trunk/olive/class/System.ServiceModel/System.ServiceModel/ClientCredentialsSecurityTokenManager.cs
trunk/olive/class/System.ServiceModel/System.ServiceModel/Constants.cs
trunk/olive/class/System.ServiceModel/System.ServiceModel/MessageSecurityVersion.cs
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
Log:
2007-01-12 Atsushi Enomoto <[EMAIL PROTECTED]>
* MessageSecurityVersion.cs, Constants.cs :
Use constants in MessageSecurityTokenVersion.
* ClientCredentialsSecurityTokenManager.cs :
CreateSecurityTokenSerializer() should consider securityVersion
and emitBspRequiredAttributes based on SecurityTokenVersion.
* ServiceCredentialsSecurityTokenManager.cs :
CreateSecurityTokenSerializer() should consider securityVersion
and emitBspRequiredAttributes based on SecurityTokenVersion.
* WSSecurityTokenSerializer.cs : EmitBspRequiredAttributes is the
magic key to determine to output some attributes or not.
Added CreateKeyIdentifierClauseFromTokenXml() stub.
* SecureMessageGenerator.cs : fixed derived keysize. derived key was
causing NRE due to the lack of token reference.
No need to pass doc to SignedXml.ctor() anymore.
Moved ReferenceList before the signature(s).
* WSSecurityTokenSerializerTest.cs : added some tests for
EmitBspRequiredAttributes.
Modified: trunk/olive/class/System.ServiceModel/System.ServiceModel/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel/System.ServiceModel/ChangeLog
2007-01-12 16:51:08 UTC (rev 70930)
+++ trunk/olive/class/System.ServiceModel/System.ServiceModel/ChangeLog
2007-01-12 17:14:09 UTC (rev 70931)
@@ -1,5 +1,13 @@
2007-01-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * MessageSecurityVersion.cs, Constants.cs :
+ Use constants in MessageSecurityTokenVersion.
+ * ClientCredentialsSecurityTokenManager.cs :
+ CreateSecurityTokenSerializer() should consider securityVersion
+ and emitBspRequiredAttributes based on SecurityTokenVersion.
+
+2007-01-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* Constants.cs : added WSSEncryptedKeyToken.
2007-01-10 Atsushi Enomoto <[EMAIL PROTECTED]>
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel/ClientCredentialsSecurityTokenManager.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel/ClientCredentialsSecurityTokenManager.cs
2007-01-12 16:51:08 UTC (rev 70930)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel/ClientCredentialsSecurityTokenManager.cs
2007-01-12 17:14:09 UTC (rev 70931)
@@ -315,10 +315,14 @@
#endregion
- [MonoTODO]
public override SecurityTokenSerializer
CreateSecurityTokenSerializer (SecurityTokenVersion version)
{
- return new WSSecurityTokenSerializer
(SecurityVersion.WSSecurity11);
+ bool bsp = version.GetSecuritySpecifications
().Contains (Constants.WSBasicSecurityProfileCore1);
+ SecurityVersion ver =
+ version.GetSecuritySpecifications ().Contains
(Constants.Wss11Namespace) ?
+ SecurityVersion.WSSecurity11 :
+ SecurityVersion.WSSecurity10;
+ return new WSSecurityTokenSerializer (ver, bsp);
}
protected SecurityTokenSerializer CreateSecurityTokenSerializer
(SecurityVersion version)
Modified: trunk/olive/class/System.ServiceModel/System.ServiceModel/Constants.cs
===================================================================
--- trunk/olive/class/System.ServiceModel/System.ServiceModel/Constants.cs
2007-01-12 16:51:08 UTC (rev 70930)
+++ trunk/olive/class/System.ServiceModel/System.ServiceModel/Constants.cs
2007-01-12 17:14:09 UTC (rev 70931)
@@ -33,6 +33,8 @@
{
public const string WSA1 =
"http://www.w3.org/2005/08/addressing";
+ public const string WSBasicSecurityProfileCore1 =
"http://ws-i.org/profiles/basic-security/core/1.0";
+
public const string WsaAnonymousUri =
"http://www.w3.org/2005/08/addressing/anonymous";
public const string MSSerialization =
"http://schemas.microsoft.com/2003/10/Serialization/";
@@ -57,6 +59,7 @@
public const string WstNamespace =
"http://schemas.xmlsoap.org/ws/2005/02/trust";
public const string WssNamespace =
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
+ public const string Wss11Namespace =
"http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd";
public const string WspNamespace =
"http://schemas.xmlsoap.org/ws/2004/09/policy";
public const string WsaNamespace =
"http://www.w3.org/2005/08/addressing";
public const string WsuNamespace =
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel/MessageSecurityVersion.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel/MessageSecurityVersion.cs
2007-01-12 16:51:08 UTC (rev 70930)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel/MessageSecurityVersion.cs
2007-01-12 17:14:09 UTC (rev 70931)
@@ -48,21 +48,21 @@
static MessageSecurityTokenVersion ()
{
specs10_profile_source = new string [] {
-
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
-
"http://schemas.xmlsoap.org/ws/2005/02/trust",
-
"http://schemas.xmlsoap.org/ws/2005/02/sc",
-
"http://ws-i.org/profiles/basic-security/core/1.0",
+ Constants.WssNamespace,
+ Constants.WstNamespace,
+ Constants.WsscNamespace,
+ Constants.WSBasicSecurityProfileCore1,
};
specs11_source = new string [] {
-
"http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd",
-
"http://schemas.xmlsoap.org/ws/2005/02/trust",
-
"http://schemas.xmlsoap.org/ws/2005/02/sc",
+ Constants.Wss11Namespace,
+ Constants.WstNamespace,
+ Constants.WsscNamespace,
};
specs11_profile_source = new string [] {
-
"http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd",
-
"http://schemas.xmlsoap.org/ws/2005/02/trust",
-
"http://schemas.xmlsoap.org/ws/2005/02/sc",
-
"http://ws-i.org/profiles/basic-security/core/1.0",
+ Constants.Wss11Namespace,
+ Constants.WstNamespace,
+ Constants.WsscNamespace,
+ Constants.WSBasicSecurityProfileCore1,
};
wss10basic = new MessageSecurityTokenVersion
(false, true);
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
2007-01-12 16:51:08 UTC (rev 70930)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
2007-01-12 17:14:09 UTC (rev 70931)
@@ -1,5 +1,12 @@
2007-01-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * SecureMessageGenerator.cs : fixed derived keysize. derived key was
+ causing NRE due to the lack of token reference.
+ No need to pass doc to SignedXml.ctor() anymore.
+ Moved ReferenceList before the signature(s).
+
+2007-01-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* SecureMessageGenerator.cs : add wsu:Timestamp to signing target.
Moved signing key generation code to non-HMACSHA1 signing part.
Don't try to sign wss:Security.
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
2007-01-12 16:51:08 UTC (rev 70930)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
2007-01-12 17:14:09 UTC (rev 70931)
@@ -312,7 +312,7 @@
if (initiatorParams.RequireDerivedKeys) {
// FIXME: it should replace aes
RijndaelManaged deriv = new RijndaelManaged ();
- deriv.KeySize = 128;
+ deriv.KeySize = 192;
deriv.Mode = CipherMode.CBC;
deriv.Padding = PaddingMode.ISO10126;
deriv.GenerateKey ();
@@ -321,9 +321,6 @@
derivedKey.Offset = 0;
derivedKey.Nonce = deriv.Key;
derivedKey.Length = derivedKey.Nonce.Length;
- if (ekey != null)
- derivedKey.SecurityTokenReference =
- new LocalIdKeyIdentifierClause
(encToken.Id);
derivedKeys.Add (derivedKey);
}
@@ -335,6 +332,10 @@
encToken,
new SecurityKeyIdentifier (encClause));
+ if (derivedKey != null)
+ derivedKey.SecurityTokenReference =
+ new LocalIdKeyIdentifierClause (ekeyId,
typeof (WrappedKeySecurityToken));
+
SecurityKeyIdentifierClause ekeyClause =
new LocalIdKeyIdentifierClause (ekeyId, typeof
(WrappedKeySecurityToken));
@@ -346,7 +347,7 @@
case
MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature:
// sign
- SignedXml sxml = new SignedXml (doc);
+ SignedXml sxml = new SignedXml ();
sig = sxml.Signature;
sig.SignedInfo.CanonicalizationMethod =
@@ -426,14 +427,14 @@
foreach (WsscDerivedKeyToken dk in derivedKeys)
header.Contents.Add (dk);
+ if (encRefList != null)
+ header.Contents.Add (encRefList);
+
if (sigenc != null)
header.Contents.Add (sigenc);
else if (sig != null)
header.Contents.Add (sig);
- if (encRefList != null)
- header.Contents.Add (encRefList);
-
return ret;
}
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog
2007-01-12 16:51:08 UTC (rev 70930)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog
2007-01-12 17:14:09 UTC (rev 70931)
@@ -1,5 +1,14 @@
2007-01-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * ServiceCredentialsSecurityTokenManager.cs :
+ CreateSecurityTokenSerializer() should consider securityVersion
+ and emitBspRequiredAttributes based on SecurityTokenVersion.
+ * WSSecurityTokenSerializer.cs : EmitBspRequiredAttributes is the
+ magic key to determine to output some attributes or not.
+ Added CreateKeyIdentifierClauseFromTokenXml() stub.
+
+2007-01-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* WSSecurityTokenSerializer.cs : handle WrappedKeySecurityToken in
GetTokenTypeUri().
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManager.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManager.cs
2007-01-12 16:51:08 UTC (rev 70930)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManager.cs
2007-01-12 17:14:09 UTC (rev 70931)
@@ -254,10 +254,14 @@
#endregion
- [MonoTODO]
public override SecurityTokenSerializer
CreateSecurityTokenSerializer (SecurityTokenVersion version)
{
- return new WSSecurityTokenSerializer
(SecurityVersion.WSSecurity11);
+ bool bsp = version.GetSecuritySpecifications
().Contains (Constants.WSBasicSecurityProfileCore1);
+ SecurityVersion ver =
+ version.GetSecuritySpecifications ().Contains
(Constants.Wss11Namespace) ?
+ SecurityVersion.WSSecurity11 :
+ SecurityVersion.WSSecurity10;
+ return new WSSecurityTokenSerializer (ver, bsp);
}
protected bool IsIssuedSecurityTokenRequirement (
Modified:
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
2007-01-12 16:51:08 UTC (rev 70930)
+++
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
2007-01-12 17:14:09 UTC (rev 70931)
@@ -122,7 +122,6 @@
get { return SecurityVersion ==
SecurityVersion.WSSecurity10; }
}
- [MonoTODO]
public bool EmitBspRequiredAttributes {
get { return emit_bsp; }
}
@@ -204,6 +203,13 @@
}
[MonoTODO]
+ public SecurityKeyIdentifierClause
CreateKeyIdentifierClauseFromTokenXml (
+ XmlElement tokenXml, SecurityTokenReferenceStyle
referenceStyle)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
protected override SecurityKeyIdentifier ReadKeyIdentifierCore (
XmlReader reader)
{
@@ -419,8 +425,8 @@
w.WriteStartElement ("o", "SecurityTokenReference",
Constants.WssNamespace);
w.WriteStartElement ("o", "KeyIdentifier",
Constants.WssNamespace);
w.WriteAttributeString ("ValueType",
Constants.WssX509ThumbptintValueType);
- // FIXME: in some cases it seems to write this
attribute...
- //w.WriteAttributeString ("EncodingType",
Constants.WssBase64BinaryEncodingType);
+ if (EmitBspRequiredAttributes)
+ w.WriteAttributeString ("EncodingType",
Constants.WssBase64BinaryEncodingType);
w.WriteString (Convert.ToBase64String
(ic.GetX509Thumbprint ()));
w.WriteEndElement ();
w.WriteEndElement ();
@@ -431,9 +437,11 @@
{
w.WriteStartElement ("o", "SecurityTokenReference",
Constants.WssNamespace);
w.WriteStartElement ("o", "Reference",
Constants.WssNamespace);
- string valueType = ic.OwnerType != null ?
GetTokenTypeUri (ic.OwnerType) : null;
- if (valueType != null)
- w.WriteAttributeString ("ValueType", valueType);
+ if (EmitBspRequiredAttributes && ic.OwnerType != null) {
+ string vt = GetTokenTypeUri (ic.OwnerType);
+ if (vt != null)
+ w.WriteAttributeString ("ValueType",
vt);
+ }
w.WriteAttributeString ("URI", "#" + ic.LocalId);
w.WriteEndElement ();
w.WriteEndElement ();
Modified:
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
===================================================================
---
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
2007-01-12 16:51:08 UTC (rev 70930)
+++
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
2007-01-12 17:14:09 UTC (rev 70931)
@@ -1,5 +1,10 @@
2007-01-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * WSSecurityTokenSerializerTest.cs : added some tests for
+ EmitBspRequiredAttributes.
+
+2007-01-12 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* WSSecurityTokenSerializerTest.cs : added somewhat wrong test for
serialization for LocalIdKeyIdentifierClause with OwnerType.
Modified:
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
===================================================================
---
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
2007-01-12 16:51:08 UTC (rev 70930)
+++
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
2007-01-12 17:14:09 UTC (rev 70931)
@@ -245,6 +245,7 @@
[ExpectedException (typeof (InvalidOperationException))]
public void WriteX509ThumbprintKeyIdentifierClause2 ()
{
+ // WS-Security1.0 x thumbprint = death
using (XmlWriter w = XmlWriter.Create
(TextWriter.Null)) {
new WSSecurityTokenSerializer
(SecurityVersion.WSSecurity10)
.WriteKeyIdentifierClause (w, new
X509ThumbprintKeyIdentifierClause (cert));
@@ -252,6 +253,18 @@
}
[Test]
+ public void WriteX509ThumbprintKeyIdentifierClause3 ()
+ {
+ // EmitBspRequiredAttributes
+ StringWriter sw = new StringWriter ();
+ X509ThumbprintKeyIdentifierClause ic = new
X509ThumbprintKeyIdentifierClause (cert);
+ using (XmlWriter w = XmlWriter.Create (sw,
GetWriterSettings ())) {
+ new WSSecurityTokenSerializer
(true).WriteKeyIdentifierClause (w, ic);
+ }
+ Assert.AreEqual ("<o:SecurityTokenReference
xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:KeyIdentifier
ValueType=\"http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1\"
EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">GQ3YHlGQhDF1bvMixHliX4uLjlY=</o:KeyIdentifier></o:SecurityTokenReference>",
sw.ToString ());
+ }
+
+ [Test]
public void WriteEncryptedKeyIdentifierClause ()
{
StringWriter sw = new StringWriter ();
@@ -296,7 +309,6 @@
}
[Test]
- [Category ("NotWorking")] // I believe it should output
ValueType attribute, but .net does not.
public void WriteLocalIdKeyIdentifierClause3 ()
{
StringWriter sw = new StringWriter ();
@@ -308,6 +320,17 @@
}
[Test]
+ public void WriteLocalIdKeyIdentifierClause4 () // EmitBsp
+ {
+ StringWriter sw = new StringWriter ();
+ LocalIdKeyIdentifierClause ic = new
LocalIdKeyIdentifierClause ("urn:myIDValue", typeof (WrappedKeySecurityToken));
+ using (XmlWriter w = XmlWriter.Create (sw,
GetWriterSettings ())) {
+ new WSSecurityTokenSerializer
(true).WriteKeyIdentifierClause (w, ic);
+ }
+ Assert.AreEqual ("<o:SecurityTokenReference
xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:Reference
ValueType=\"http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey\"
URI=\"#urn:myIDValue\" /></o:SecurityTokenReference>", sw.ToString (), "#1");
+ }
+
+ [Test]
public void ReadKeyIdentifierClause ()
{
string xml = @"<o:SecurityTokenReference
xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches