Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Help a newbie migrating from OpenSAML 1 to OpenSAML 2
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ryan  
View profile  
 More options Feb 28, 7:12 pm
From: Ryan <altaio...@gmail.com>
Date: Sat, 28 Feb 2009 16:12:32 -0800
Local: Sat, Feb 28 2009 7:12 pm
Subject: [OpenSAML] Help a newbie migrating from OpenSAML 1 to OpenSAML 2

Hi All,

Forgive me if this is a dumb question, but I'm having some problems
migrating some proof of concept code from the OpenSAML 1 to OpenSAML 2
library. I was able to build a simple SAMLResponse to successfully login to
Salesforce.com, but now that I am trying to port that code over to using
OpenSAML 2 (still using SAML 1.1), I'm not understanding how to link the
objects together to build the assertion. I understand that the two libraries
are not directly compatible, but hoping someone can point me in the right
direction. Specifically, I am having problems with:

-How to add a subject confirmation method?
-How to add an audience to an AudienceRestrictionCondition?
-How to add an AuthenticationStatement to an Assertion?
-How to add an AudienceRestrictionCondition to an Assertion?

Below is a snippet of my working code in OpenSAML 1 and compared to my
attempt in OpenSAML 2 with these items marked as TODOs in the OpenSAML 2
code:

OPEN SAML 1:

    SAMLAssertion createAssertion(String username, String issuer) throws
SAMLException{
        SAMLNameIdentifier nameId = new SAMLNameIdentifier();
            nameId.setName(username);
            nameId.checkValidity();

        SAMLSubject subject = new SAMLSubject();
            subject.setNameIdentifier(nameId);

subject.addConfirmationMethod("urn:oasis:names:tc:SAML:1.0:cm:bearer");
            subject.checkValidity();

        SAMLAuthenticationStatement authStatement = new
SAMLAuthenticationStatement();
            authStatement.setAuthMethod("AuthenticationMethod_Password");
            authStatement.setAuthInstant(new Date());
            authStatement.setSubject(subject);
            authStatement.checkValidity();

        SAMLAudienceRestrictionCondition condition = new
SAMLAudienceRestrictionCondition();
            condition.addAudience("https://saml.salesforce.com");
            condition.checkValidity();

        SAMLAssertion assertion = new SAMLAssertion();
            assertion.setIssuer(issuer);
            assertion.setIssueInstant(new Date());
            assertion.setMinorVersion(1);
            assertion.addStatement(authStatement);
            assertion.addCondition(condition);
            assertion.setId(generateId());
            assertion.setNotBefore(new Date());
            assertion.setNotOnOrAfter(new Date(2010,12,31));
            assertion.checkValidity();
        return assertion;
    }

OpenSAML 2:
    public IdentityProvider() throws Exception{
        DefaultBootstrap.bootstrap();
        builderFactory = Configuration.getBuilderFactory();
    }

    Assertion createAssertion(String username, String issuer) throws
Exception{
        SAMLObjectBuilder<NameIdentifier> nameIdBuilder =
(SAMLObjectBuilder<NameIdentifier>)
builderFactory.getBuilder(NameIdentifier.DEFAULT_ELEMENT_NAME);
        NameIdentifier nameId = nameIdBuilder.buildObject();
            nameId.setNameIdentifier(username);

        SAMLObjectBuilder<SubjectConfirmationData>
subjectConfirmationDataBuilder =
(SAMLObjectBuilder<SubjectConfirmationData>)
builderFactory.getBuilder(SubjectConfirmationData.DEFAULT_ELEMENT_NAME);
        SubjectConfirmationData subjectConfirmationData =
subjectConfirmationDataBuilder.buildObject();
//
subjectConfirmationData.addConfirmationMethod("urn:oasis:names:tc:SAML:1.0: cm:bearer");
//TODO: addConfirmationMethod() method does not exist

        SAMLObjectBuilder<SubjectConfirmation> subjectConfirmationBuilder =
(SAMLObjectBuilder<SubjectConfirmation>)
builderFactory.getBuilder(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
        SubjectConfirmation subjectConfirmation =
subjectConfirmationBuilder.buildObject();

subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);

        SAMLObjectBuilder<Subject> subjectBuilder =
(SAMLObjectBuilder<Subject>)
builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME);
        Subject subject = subjectBuilder.buildObject();
            subject.setNameIdentifier(nameId);
            subject.setSubjectConfirmation(subjectConfirmation);

        SAMLObjectBuilder<AuthenticationStatement> authStatementBuilder =
(SAMLObjectBuilder<AuthenticationStatement>)
builderFactory.getBuilder(AuthenticationStatement.DEFAULT_ELEMENT_NAME);
        AuthenticationStatement authStatement =
authStatementBuilder.buildObject();
            authStatement.setSubject(subject);

authStatement.setAuthenticationMethod("AuthenticationMethod_Password");
            authStatement.setAuthenticationInstant(new DateTime());

        SAMLObjectBuilder<AudienceRestrictionCondition> conditionBuilder =
(SAMLObjectBuilder<AudienceRestrictionCondition>)
builderFactory.getBuilder(AudienceRestrictionCondition.DEFAULT_ELEMENT_NAME );
        AudienceRestrictionCondition condition =
conditionBuilder.buildObject();
            //condition.addAudience("https://saml.salesforce.com"); //TODO:
addAudience() method does not exist

        SAMLObjectBuilder<Assertion> assertionBuilder =
(SAMLObjectBuilder<Assertion>)
builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
        Assertion assertion = assertionBuilder.buildObject();
            assertion.setIssuer(issuer);
            assertion.setIssueInstant(new DateTime());
            assertion.setVersion(SAMLVersion.VERSION_11);
            assertion.setID(generateId());
            //assertion.addStatement(authStatement); //TODO: addStatement()
method does not exist
            //assertion.addCondition(condition); //TODO: addCondition()
method does not exist

        return assertion;
    }

Any tips anyone can provide would be appreciated.

Thank you,
Ryan


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Cantor  
View profile  
 More options Feb 28, 10:00 pm
From: "Scott Cantor" <canto...@osu.edu>
Date: Sat, 28 Feb 2009 22:00:08 -0500
Local: Sat, Feb 28 2009 10:00 pm
Subject: RE: [OpenSAML] Help a newbie migrating from OpenSAML 1 to OpenSAML 2

subjectConfirmationData.addConfirmationMethod("urn:oasis:names:tc:SAML:1.0: c

> m:bearer"); //TODO: addConfirmationMethod() method does not exist

You call getConfirmationMethods() and then add the item to the collection
you get back. Same for all the other collections.

-- Scott


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ryan  
View profile  
 More options Mar 1, 3:50 am
From: Ryan <altaio...@gmail.com>
Date: Sun, 1 Mar 2009 00:50:59 -0800
Local: Sun, Mar 1 2009 3:50 am
Subject: Re: [OpenSAML] Help a newbie migrating from OpenSAML 1 to OpenSAML 2

Scott, thank you very much for the quick response. That worked perfectly!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google