mace-opensaml-users - RE: OpensamlTP2 Signature problem
Subject: OpenSAML user discussion
List archive
- From: "Giuseppe Sarno" <>
- To: <>
- Subject: RE: OpensamlTP2 Signature problem
- Date: Mon, 16 Oct 2006 16:15:00 +0100
sign.setSignatureAlgorithm(org.apache.xml.security.signature.XMLSignature.ALGO_ID_SIGNATURE_DSA);
sign.setCanonicalizationAlgorithm(Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS);
obj.setSignature(sign);
the Wiki might needs updating.
<
samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" AssertionConsumerServiceURL="http://www.example.com/"AttributeConsumingServiceIndex
="0" Consent="urn:oasis:names:tc:SAML:2.0:consent:obtained" Destination="http://www.example.com/" ForceAuthn="true" ID="abe567de6"IssueInstant
="2005-01-31T12:00:00.000Z" ProviderName="SomeProvider" Version="2.0"> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" /> <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" /> <ds:Reference URI="#abe567de6" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:Transforms xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" /> <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="ds saml samlp" /> </ds:Transform> </ds:Transforms> <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" /> <ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#" /> </ds:Reference> <ds:Reference URI="#abe567de6" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:Transforms xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" />
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="ds saml samlp" />
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" />
<ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#" />
</ds:Reference>
</ds:SignedInfo> <ds:SignatureValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#" /> </ds:Signature> <saml:Subject xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"> <saml:NameID Format="urn:oasis:names:tc: SAML:1.1:nameid-format:emailAddress" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"></saml:NameID> </saml:Subject> <saml:Conditions xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"> <saml:AudienceRestriction xmlns:saml=" urn:oasis:names:tc:SAML:2.0:assertion"> <saml:Audience>urn:foo:sp.example.org</saml:Audience> </saml:AudienceRestriction> </saml:Conditions> <samlp:RequestedAuthnContext xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"> <saml:AuthnContextClassRef xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef> </samlp:RequestedAuthnContext></
samlp:AuthnRequest>From: Sarno, Giuseppe (MOP:GM15)
Sent: 16 October 2006 14:33
To:
Subject: OpensamlTP2 Signature problem
org.opensaml.xml.io.MarshallingException: Unable to construct signature Element {http://www.w3.org/2000/09/xmldsig#}Sign
ature
at org.opensaml.xml.signature.SignatureMarshaller.createSignatureElement(SignatureMarshaller.java:146)
at org.opensaml.xml.signature.SignatureMarshaller.marshall(SignatureMarshaller.java:69)
at org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshallChildElements(AbstractXMLObjectMarshaller.java:371)
at org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshallInto(AbstractXMLObjectMarshaller.java:262)
at org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:152)
at org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:96)
.................................
l Message was: null
Original Exception was java.lang.NullPointerException
at org.apache.xml.security.algorithms.SignatureAlgorithm.<init>(Unknown Source)
at org.apache.xml.security.signature.SignedInfo.<init>(Unknown Source)
at org.apache.xml.security.signature.XMLSignature.<init>(Unknown Source)
at org.apache.xml.security.signature.XMLSignature.<init>(Unknown Source)
at org.opensaml.xml.signature.SignatureMarshaller.createSignatureElement(SignatureMarshaller.java:107)
... 10 more
{
SignatureBuilder build = new SignatureBuilder();
Signature sign = build.buildObject();
sign.getContentReferences().add(ref);
PublicKey pubKey = null;
PrivateKey privKey = null;
try
{
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
keyGen.initialize(1024);
KeyPair keypair = keyGen.genKeyPair();
pubKey = keypair.getPublic();
privKey = keypair.getPrivate();
}
catch (NoSuchAlgorithmException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
sign.setSigningKey(privKey);
obj.setSignature(sign);
return obj;
{
MarshallerFactory marshallerFactory = Configuration.getMarshallerFactory();
System.out.println("BLAH");
if (saml_obj == null){
System.out.println("OBJ");
}
else
if (marshallerFactory == null)
{
System.out.println("FACTORY");
}
else{
System.out.println("NONE");
}
// Get the Subject marshaller
Marshaller marshaller = marshallerFactory.getMarshaller(saml_obj);
Element element = null;
try {
element = marshaller.marshall(saml_obj);
} catch (MarshallingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return element;
}
- OpensamlTP2 Signature problem, Giuseppe Sarno, 10/16/2006
- RE: OpensamlTP2 Signature problem, Giuseppe Sarno, 10/16/2006
Archive powered by MHonArc 2.6.16.