Skip to Content.
Sympa Menu

mace-opensaml-users - Re: Help starting openSAML

Subject: OpenSAML user discussion

List archive

Re: Help starting openSAML


Chronological Thread 
  • From: Subash Devkota <>
  • To:
  • Subject: Re: Help starting openSAML
  • Date: Fri, 26 Jan 2007 21:20:33 +0545
  • Organization: D2Hawkeye

Thank you paul.

I had downloaded the opensaml-2.0-TP2-jdk-1.4.jar and used it.
It was the incomplet one. It didn't have

org.opensaml.DefaultBootstrap

class. As your advice, I pulled the latest code from svn and your code worked and helped me a lot.

One question, I am using jdk1.5 as it says. I tried with jdk1.4.2 and gives the error java.lang.Iterable class not found.
Can I run OpenSAML in jkd1.4? Is it possbile with minor changes in code?

Thank You
Subash

Paul Hethmon wrote:
A couple of things here:

1. Make sure you followed the steps to put the endorsed versions of
Xalan and Xerces in place.
2. What you do next depends on which iteration of the library you are
using. I'm using the latest revision from svn (at least updated in the
last week) and here's some sample code which should compile and run:

// -----
org.opensaml.DefaultBootstrap.bootstrap();

// Use the OpenSAML Configuration singleton to get a builder factory
object
XMLObjectBuilderFactory builderFactory =
org.opensaml.Configuration.getBuilderFactory();
// First get a builder for AuthnRequest
AuthnRequestBuilder arb = (AuthnRequestBuilder)
builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
// And one for Issuer
IssuerBuilder ib = (IssuerBuilder)
builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
// And one for Subject
SubjectBuilder sb = (SubjectBuilder)
builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME);
// build an AuthnRequest object
AuthnRequestImpl auth = (AuthnRequestImpl) arb.buildObject();
// Build the Issuer object
Issuer newIssuer = ib.buildObject();
newIssuer.setValue("MyIssuer");
auth.setIssuer(newIssuer);
auth.setProviderName("MyProviderName");
auth.setAssertionConsumerServiceURL("http://www.example.com";);
auth.setDestination("http://www.example.com";);
//auth.setAssertionConsumerServiceIndex(0);
//auth.setAttributeConsumingServiceIndex(0);
auth.setID("someuniqueidhere");
auth.setVersion(org.opensaml.common.SAMLVersion.VERSION_20);
DateTime dt = new DateTime();
auth.setIssueInstant(dt);
MarshallerFactory marshallerFactory =
org.opensaml.Configuration.getMarshallerFactory();
Marshaller marshaller = marshallerFactory.getMarshaller(auth);
String msg = "";
Element authElement = null;
if (marshaller == null) {
msg = "unable to locate marshaller for [" +
newIssuer.getElementQName() + "]";
} else {
authElement = marshaller.marshall(auth);
}
DOMImplementationRegistry registry =
DOMImplementationRegistry.newInstance();

DOMImplementationLS impl =
(DOMImplementationLS)registry.getDOMImplementation("LS");

LSSerializer writer = impl.createLSSerializer();
String str = writer.writeToString(authElement);
str = str.replace("<", "&lt;");
str = str.replace(">", "&gt;");
// -----
It's not the greatest or prettiest, but it's something you can start
with.

Paul



-----Original Message-----
From: Subash Devkota [mailto:] Sent: Thursday, January 25, 2007 7:59 AM
To:

Subject: Help starting openSAML

Hi all,

I want to test and implement openSAML API. I have got the jar and code.

But, I am getting problem how to start using it. I could not find any
good tutorial or example for simply creating SAML objects and writing
to xml.

I found one example code from
https://spaces.internet2.edu/display/SHIB/OSTwoUsrManJavaCreateFromScrat
ch
but got error using it.

public static void main(String args[]) throws Exception{
// Get the builder factory
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
// Get the subject builder based on the subject element name
SubjectBuilder builder = (SubjectBuilder ) builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME);
System.out.println("subject builder is :"+builder);
// Create the subject
Subject subject = (Subject)builder.buildObject();
I got builder value in second step as null and get NullPointerException
in third step as shown below:

subject builder is :null
Exception in thread "main" java.lang.NullPointerException

Can any one help me how to do it. Also, I would be grateful if anyone
can show me the best example or tutorial for getting started with
openSAML.

Thanks in advance
Subash PRIVACY NOTICE

This email and any attachments may be confidential and/or privileged.
Use of the information contained in this email by anyone other than the
intended recipient is strictly prohibited. If you have received this
email in error, please notify the sender by replying to this message and
delete this email.



Archive powered by MHonArc 2.6.16.

Top of Page