001/** 002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 003 * 004 * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved 005 * 006 * The contents of this file are subject to the terms 007 * of the Common Development and Distribution License 008 * (the License). You may not use this file except in 009 * compliance with the License. 010 * 011 * You can obtain a copy of the License at 012 * https://opensso.dev.java.net/public/CDDLv1.0.html or 013 * opensso/legal/CDDLv1.0.txt 014 * See the License for the specific language governing 015 * permission and limitations under the License. 016 * 017 * When distributing Covered Code, include this CDDL 018 * Header Notice in each file and include the License file 019 * at opensso/legal/CDDLv1.0.txt. 020 * If applicable, add the following below the CDDL Header, 021 * with the fields enclosed by brackets [] replaced by 022 * your own identifying information: 023 * "Portions Copyrighted [year] [name of copyright owner]" 024 * 025 * $Id: SAML2TokenSpec.java,v 1.7 2009/08/29 03:05:57 mallas Exp $ 026 * 027 */ 028 029package com.sun.identity.wss.security; 030 031import java.util.Map; 032import java.util.List; 033import javax.xml.namespace.QName; 034import com.sun.identity.saml2.assertion.NameID; 035 036import org.w3c.dom.Element; 037 038/** 039 * This class implements the interface <code>SecurityTokenSpec</code> to 040 * create <code>SAML2</code> Assertions / Security tokens. 041 * 042 * @supported.all.api 043 */ 044public class SAML2TokenSpec implements SecurityTokenSpec { 045 046 private SecurityMechanism securityMechanism = null; 047 private String certAlias = null; 048 private NameID nameIdentifier = null; 049 private String issuer = null; 050 private String confirmationMethod = null; 051 private Map<QName, List<String>> claims = null; 052 private String appliesTo = null; 053 private long assertionInterval = 300000; 054 private String authnContextClassRef = null; 055 private String assertionID = null; 056 private String signingAlias = null; 057 private Element keyInfo = null; 058 059 public SAML2TokenSpec() { 060 061 } 062 063 /** 064 * Creates a new instance of SAML2TokenSpec 065 */ 066 public SAML2TokenSpec(NameID nameIdentifier, 067 SecurityMechanism securityMechanism, 068 String certAlias) { 069 070 this.nameIdentifier = nameIdentifier; 071 this.securityMechanism = securityMechanism; 072 this.certAlias = certAlias; 073 } 074 075 /** 076 * Returns the authenticated subject name identifier. 077 * 078 * @return the name identifier of the authenticated subject. 079 */ 080 public NameID getSenderIdentity() { 081 return nameIdentifier; 082 } 083 /** 084 * Sets the sender identity 085 * @param nameID the sender's name identifier. 086 */ 087 public void setSenderIdentity(NameID nameID) { 088 this.nameIdentifier = nameID; 089 } 090 091 /** 092 * Returns the security mechanism 093 * @return the security mechanism 094 */ 095 public SecurityMechanism getSecurityMechanism() { 096 return securityMechanism; 097 } 098 099 /** 100 * Returns the certficate alias of the subject. 101 * 102 * @return the certificate alias of the subject. 103 */ 104 public String getSubjectCertAlias() { 105 return certAlias; 106 } 107 108 /** 109 * Sets the certificate alias of the subject. 110 * @param certAlias the certificate alias of the subject. 111 */ 112 public void setSubjectCertAlias(String certAlias) { 113 this.certAlias = certAlias; 114 } 115 116 /** 117 * Returns the issuer name. 118 * @return the issuer name. 119 */ 120 public String getIssuer() { 121 return issuer; 122 } 123 124 /** 125 * Sets the issuer name. 126 * @param issuer the issuer name. 127 */ 128 public void setIssuer(String issuer) { 129 this.issuer = issuer; 130 } 131 132 /** 133 * Returns the cliamed attributes 134 * @return the cliamed attributes 135 */ 136 public Map<QName, List<String>> getClaimedAttributes() { 137 return claims; 138 } 139 140 /** 141 * Sets the claimed attributes 142 * @param attrs the claimed attributes 143 */ 144 public void setClaimedAttributes(Map attrs) { 145 this.claims = attrs; 146 } 147 148 /** 149 * Returns the confirmation method. 150 * @return the confirmation method. 151 */ 152 public String getConfirmationMethod() { 153 return confirmationMethod; 154 } 155 156 /** 157 * Sets the confirmation method 158 * @param confirmationMethod the confirmation method 159 */ 160 public void setConfirmationMethod(String confirmationMethod) { 161 this.confirmationMethod = confirmationMethod; 162 } 163 164 /** 165 * Returns the name of the service for which assertion needs to be issued 166 * @return the name of the service for which assertion needs to be issued 167 */ 168 public String getAppliesTo() { 169 return appliesTo; 170 } 171 172 /** 173 * Sets the name of the service for which the assertion needs to be issued. 174 * @param appliesTo the name of the service for which the assertion needs 175 * to be issued. 176 */ 177 public void setAppliesTo(String appliesTo) { 178 this.appliesTo = appliesTo; 179 } 180 181 /** 182 * Returns the assertion interval 183 * @return the assertion interval 184 */ 185 public long getAssertionInterval() { 186 return assertionInterval; 187 } 188 189 /** 190 * Sets the assertion interval 191 * @param interval the assertion interval. 192 */ 193 public void setAssertionInterval(long interval) { 194 this.assertionInterval = interval; 195 } 196 197 /** 198 * Returns the authentication context class ref 199 * @return the authentication context class ref 200 */ 201 public String getAuthnContextClassRef() { 202 return authnContextClassRef; 203 } 204 205 /** 206 * Sets the authentication context class ref. 207 * @param authnContextClassRef the authentication class ref. 208 */ 209 public void setAuthnContextClassRef(String authnContextClassRef) { 210 this.authnContextClassRef = authnContextClassRef; 211 } 212 213 /** 214 * Returns the assertion identifier. 215 * @return the assertion identifier. 216 */ 217 public String getAssertionID() { 218 return assertionID; 219 } 220 221 /** 222 * Sets the assertion identifier. 223 * @param assertionID the assertion identifier. 224 */ 225 public void setAssertionID(String assertionID) { 226 this.assertionID = assertionID; 227 } 228 229 /** 230 * Returns the signing alias 231 * @return the signing alias 232 */ 233 public String getSigningAlias() { 234 return signingAlias; 235 } 236 237 /** 238 * Sets the signing cert alias. 239 * @param alias the sigining cert alias. 240 */ 241 public void setSigningAlias(String alias) { 242 this.signingAlias = alias; 243 } 244 245 /** 246 * Returns the keyinfo element. 247 * @return the keyinfo element. 248 */ 249 public Element getKeyInfo() { 250 return keyInfo; 251 } 252 253 /** 254 * Sets the keyinfo element. 255 * @param keyInfo the keyinfo element. 256 */ 257 public void setKeyInfo(Element keyInfo) { 258 this.keyInfo = keyInfo; 259 } 260}