Skip to Content.
Sympa Menu

mace-opensaml-users - Create an assertion

Subject: OpenSAML user discussion

List archive

Create an assertion


Chronological Thread 
  • From: Fátima Milla Olaya <>
  • To:
  • Subject: Create an assertion
  • Date: Thu, 04 Oct 2007 14:33:10 +0200

Hi, I am new in using opensaml, I want to right a simple assertion and print it, but I get [saml:Assertion: null], this is my code:
public static void main(String[] args) throws Exception {
org.opensaml.DefaultBootstrap.bootstrap();
// Get the builder factory
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();

// Get the assertion builder based on the assertion element name
SAMLObjectBuilder<Assertion> builder = (SAMLObjectBuilder<Assertion>)(builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME));

// Create the assertion
Assertion assertion = builder.buildObject();
// set Id
assertion.setID("12345");
IssuerBuilder ib = new IssuerBuilder();
// set Issuer
Issuer i = ib.buildObject();
i.setValue("Hello World");
assertion.setIssuer(i);
// set IssueInstant
//DateTime dt = new DateTime();
//assertion.setIssueInstant(dt);
// Get the marshaller factory
MarshallerFactory marshallerFactory = Configuration.getMarshallerFactory();

// Get the Assertion marshaller
Marshaller marshaller = marshallerFactory.getMarshaller(assertion);

// Marshall the Assertion
Element assertionElement = marshaller.marshall(assertion);
System.out.println(assertionElement.toString());



Thanks.



Archive powered by MHonArc 2.6.16.

Top of Page