AssertionToken.java revision 4a2f0f0be43dfd4c1b490cbf3cc48b6ba6084b1c
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: AssertionToken.java,v 1.11 2010/01/23 00:20:26 mrudul_uchil Exp $
*
*/
/**
* This class implements the interface <code>SecurityToken</code> for the
* SAML Assertions.
*/
public class AssertionToken implements SecurityToken {
private static final String KEY_INFO_TYPE =
"com.sun.identity.liberty.ws.security.keyinfotype";
/**
* Constructor that initializes the AssertionToken.
*/
" Token specification is null");
throw new SecurityException(
}
}
/**
* Validates the SSOtoken and extract the required properties.
*/
throws SecurityException {
try {
} catch (SSOException se) {
"SSOException", se);
throw new SecurityException(
}
}
/**
* Creates a SAML Assertion for the given token specification.
*/
throws SecurityException{
if(nameIdentifier == null) {
throw new SecurityException(
}
if(confirmationMethod == null) {
}
issuer =
}
if(authStatement != null) {
}
if(attrStatement != null) {
}
}
+ spec.getAssertionInterval());
try {
}
} catch (SAMLException se) {
"SAMLException in creating the assertion.", se);
throw new SecurityException(
}
"Assertion constructs:\n" +
}
try {
} catch (SAMLException se) {
"SAMLException in creating the assertion.", se);
throw new SecurityException(
}
}
/**
* Returns the confirmation method for the given security mech.
*/
throws SecurityException {
if(securityURI == null) {
throw new SecurityException(
}
} else if(
} else {
throw new SecurityException(
}
}
/**
* Creates an authentication statement.
*/
try {
if(confirmationMethod == null) {
throw new SecurityException(
}
} else if(confirmationMethod.equals(
} else if(confirmationMethod.equals(
} else {
throw new SecurityException(
}
} catch (SAMLException se) {
"Failed to generate the authentication statement.", se);
throw new SecurityException(
} catch (ParseException pe) {
"Failed to generate the authentication statement.", pe);
throw new SecurityException(
}
return authStatement;
}
/**
* Returns the security token type.
* @return String SAMLToken type.
*/
public String getTokenType() {
return SecurityToken.WSS_SAML_TOKEN;
}
/**
* Convert the security token into DOM Object.
*
* @return the DOM Document Element.
*
* @exception SecurityException if any failure is occured.
*/
if(assertionE != null) {
}
throw new SecurityException(
}
}
throws SAMLException {
}
public boolean isSenderVouches() {
return false;
}
if (!(statement instanceof SubjectStatement)) {
continue;
}
continue;
}
continue;
}
continue;
}
return true;
}
}
return false;
}
/**
* Returns X509 certificate of the authenticated subject.
*/
"Could not get certificate for alias : " + certAlias);
throw new SecurityException(
}
return cert;
}
/**
* Creates keyinfo for the subject confirmation.
*/
return keyInfo;
}
try {
} catch (Exception e) {
throw new SecurityException(e.getMessage());
}
try {
} catch (Exception e) {
throw new SecurityException(e.getMessage());
}
//keyInfo.setAttribute("xmlns", SAMLConstants.XMLSIG_NAMESPACE_URI);
if ( (keyInfoType!=null) &&
//put Certificate in KeyInfo
} else {
//put public key in keyinfo
, "DSAKeyValue");
p.setPrefix("ds");
p.appendChild(value_p);
q.setPrefix("ds");
q.appendChild(value_q);
g.setPrefix("ds");
g.appendChild(value_g);
y.setPrefix("ds");
y.appendChild(value_y);
} else {
// It is RSA
, "RSAKeyValue");
, "Modulus");
, "Exponent");
}
}
return keyInfo;
}
/**
* Signs the Assertion Token.
*
* @exception SecurityException if unable to sign the assertion.
*/
try {
} catch (SAMLException se) {
throw new SecurityException(
}
}
/**
* Returns the generated <code>SAML Assertion</code>.
*
* @return <code>Assertion</code> generated saml assertion.
*/
public Assertion getAssertion() {
return assertion;
}
if(attributes == null) {
return null;
}
try {
continue;
}
continue;
}
"</AttributeValue>";
}
}
if(samlAttributes.isEmpty()) {
return null;
}
return attrStatement;
} catch (SAMLException se) {
"Unable to create attribute statement", se);
}
}
}