mace-opensaml-users - RE: Help starting openSAML
Subject: OpenSAML user discussion
List archive
- From: "Paul Hethmon" <>
- To: <>
- Subject: RE: Help starting openSAML
- Date: Thu, 25 Jan 2007 11:15:55 -0800
Chad,
Thanks for the pointer. I'm still learning the classes and what they do.
I'm going to try and put together a tutorial type app/document in the
next month or so and I'll make that available to everyone, either on one
of my sites or thru the wiki.
Paul
-----Original Message-----
From: Chad La Joie
[mailto:]
Sent: Thursday, January 25, 2007 11:56 AM
To:
Subject: Re: Help starting openSAML
One minor note for you Paul, you can use the
XMLHelper.nodeToString(Node) method or writeNode(Node,Writer) to use the
DOM LS functions to write nodes to strings or writers respectively.
Thank you for the example code.
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("<", "<");
> str = str.replace(">", ">");
> // -----
>
> 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/OSTwoUsrManJavaCreateFromScr
> at
> 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.
--
Chad La Joie 2052-C Harris Bldg
OIS-Middleware 202.687.0124
- Help starting openSAML, Subash Devkota, 01/25/2007
- Re: Help starting openSAML, Rod Widdowson, 01/25/2007
- RE: Help starting openSAML, Paul Hethmon, 01/25/2007
- Re: Help starting openSAML, Chad La Joie, 01/25/2007
- RE: Help starting openSAML, Paul Hethmon, 01/25/2007
- Re: Help starting openSAML, Subash Devkota, 01/26/2007
- Re: Help starting openSAML, Chad La Joie, 01/25/2007
Archive powered by MHonArc 2.6.16.