Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Creating SAMLAttribute in OpenSAML 1 /Java

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

840 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