Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Creating SAMLAttribute in OpenSAML 1 /Java

Posted on 2009-05-14
1
Medium Priority
?
478 Views
Last Modified: 2012-05-07
Hi,

I'm stuck using an old version of the OpenSAML 1 framework (the Java version). I'm trying to create an Attribute but am getting NullPointerExceptions. Tutorials and APIs for this early version of OpenSAML is extremely scarce, and I really hope someone here familiar with OpenSAML 1 can help me.

The NullPointer occurs when I'm transforming the AttributeStatement to a DOM tree. See code snippet.
SAMLAttributeStatement attributeStatement = new SAMLAttributeStatement();
Collection attribute = new ArrayList();
attribute.add("sv-se");
QName qualifiedName = new QName("saml", "AttributeValue");
SAMLAttribute samlAttribute = new SAMLAttribute("LanguageCulture",
                 "http://schemas.visma.com/saml/2009/03/languageCulture",
                 qualifiedName,
                 100,
                 attribute
);
attributeStatement.addAttribute(samlAttribute);
 
(...)
 
samlAssertion.addStatement(attributeStatement);
 
(...)
 
samlResponse.addAssertion(samlAssertion);
 
(...)
 
samlResponse.toDOM();

Open in new window

0
Comment
Question by:thecosimist
1 Comment
 

Accepted Solution

by:
thecosimist earned 0 total points
ID: 24392855
I have found the solution - the SAMLAttributeStatement expects a Subject element, so what is needed is something like the code below.

I realize that this might be a rather obscure field of interest :-) but I'm posting the solution anyway.
...
SAMLAttribute samlAttribute = new SAMLAttribute(...);
SAMLSubject subject = new SAMLSubject(...);
Collection<SAMLAttribute> attributes = new ArrayList<SAMLAttribute>();
attributes.add(samlAttribute);
SAMLAttributeStatement attributeStatement = new SAMLAttributeStatement(subject, attributes);
...

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question