Solved

Creating SAMLAttribute in OpenSAML 1 /Java

Posted on 2009-05-14
1
467 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
print map entry 34 69
JQuery to parse xml string and get element by id 4 35
Error in @AspectJ Based AOP with Spring 2 13
going to wrong jsp page 2 21
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

773 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