mace-opensaml-users - OpensamlTP2 Signature problem
Subject: OpenSAML user discussion
List archive
- From: "Giuseppe Sarno" <>
- To: <>
- Subject: OpensamlTP2 Signature problem
- Date: Mon, 16 Oct 2006 14:32:51 +0100
Hi I
receive this exception trying to sign a simple Request
message:
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)
.................................
Caused by:
org.apache.xml.security.signature.XMLSignatureException: The requested algorithm
null does not exist. Origina
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
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
I followed the instructions on the WiKi
this is the code ...
public
static SignableSAMLObject signObject (SignableSAMLObject
obj)
{
{
SAMLObjectContentReference ref = new
SAMLObjectContentReference(obj);
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;
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;
Then I
Marshal the Object with this function and here I get the
Exception:
public
static Element marshalSAMLMsg(XMLObject saml_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);
{
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);
// Marshall the
Subject
Element element = null;
try {
element = marshaller.marshall(saml_obj);
} catch (MarshallingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return element;
}
Element element = null;
try {
element = marshaller.marshall(saml_obj);
} catch (MarshallingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return element;
}
Any
idea ?
thanks.
- OpensamlTP2 Signature problem, Giuseppe Sarno, 10/16/2006
- RE: OpensamlTP2 Signature problem, Giuseppe Sarno, 10/16/2006
Archive powered by MHonArc 2.6.16.