001: /*
002: * The contents of this file are subject to the terms
003: * of the Common Development and Distribution License
004: * (the License). You may not use this file except in
005: * compliance with the License.
006: *
007: * You can obtain a copy of the license at
008: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
009: * See the License for the specific language governing
010: * permissions and limitations under the License.
011: *
012: * When distributing Covered Code, include this CDDL
013: * Header Notice in each file and include the License file
014: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
015: * If applicable, add the following below the CDDL Header,
016: * with the fields enclosed by brackets [] replaced by
017: * you own identifying information:
018: * "Portions Copyrighted [year] [name of copyright owner]"
019: *
020: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
021: */
022:
023: /*
024: * SAMLAssertion2_2FactoryImpl.java
025: *
026: * Created on August 18, 2005, 12:34 PM
027: *
028: * To change this template, choose Tools | Options and locate the template under
029: * the Source Creation and Management node. Right-click the template and choose
030: * Open. You can then make changes to the template in the Source Editor.
031: */
032:
033: package com.sun.xml.wss.saml.impl;
034:
035: //import com.sun.xml.ws.security.opt.crypto.dsig.keyinfo.KeyInfo;
036: //import com.sun.xml.wss.crypto.dsig.keyinfo.KeyInfo;
037: import com.sun.xml.ws.security.opt.crypto.dsig.keyinfo.KeyInfo;
038: import com.sun.xml.wss.XWSSecurityException;
039: import java.util.GregorianCalendar;
040: import java.util.List;
041: import javax.xml.datatype.DatatypeConfigurationException;
042: import javax.xml.datatype.DatatypeFactory;
043: import javax.xml.namespace.QName;
044: import org.w3c.dom.Element;
045: import com.sun.xml.wss.saml.*;
046: import com.sun.xml.wss.saml.util.SAMLUtil;
047: import javax.xml.stream.XMLStreamException;
048: import javax.xml.stream.XMLStreamReader;
049:
050: /**
051: *
052: * @author root
053: */
054: public class SAMLAssertion2_2FactoryImpl extends SAMLAssertionFactory {
055: DatatypeFactory dataTypeFac = null;
056:
057: /** Creates a new instance of SAMLAssertion2_2FactoryImpl */
058: public SAMLAssertion2_2FactoryImpl() {
059: try {
060: dataTypeFac = DatatypeFactory.newInstance();
061: } catch (DatatypeConfigurationException ex) {
062: //ignore
063: }
064:
065: }
066:
067: public Action createAction(Element actionElement) {
068: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.Action(
069: actionElement);
070: }
071:
072: public Action createAction(String action, String namespace) {
073: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.Action(
074: action, namespace);
075: }
076:
077: public Advice createAdvice(List assertionidreference,
078: List assertion, List otherelement) {
079: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.Advice(
080: assertionidreference, assertion, otherelement);
081: }
082:
083: public AnyType createAnyType() {
084: return null;
085: }
086:
087: public Assertion createAssertion(org.w3c.dom.Element element)
088: throws SAMLException {
089: return null;
090: }
091:
092: public Assertion createAssertion(String assertionID,
093: java.lang.String issuer, GregorianCalendar issueInstant,
094: Conditions conditions, Advice advice, List statements)
095: throws SAMLException {
096:
097: return null;
098: }
099:
100: public Assertion createAssertion(String ID, NameID issuer,
101: GregorianCalendar issueInstant, Conditions conditions,
102: Advice advice, Subject subject, List statements)
103: throws SAMLException {
104:
105: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.Assertion(
106: ID,
107: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.NameID) issuer,
108: issueInstant,
109: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.Conditions) conditions,
110: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.Advice) advice,
111: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.Subject) subject,
112: statements);
113: }
114:
115: public AssertionIDReference createAssertionIDReference() {
116: return null;
117: }
118:
119: public AssertionIDRef createAssertionIDRef() {
120: return null;
121: }
122:
123: public AssertionIDReference createAssertionIDReference(String id) {
124: return null;
125: }
126:
127: public AssertionIDRef createAssertionIDRef(String id) {
128: return null;
129: }
130:
131: public Attribute createAttribute(String name, String nameSpace,
132: List values) {
133: return null;
134: }
135:
136: public Attribute createAttribute(String name, List values) {
137: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.Attribute(
138: name, values);
139: }
140:
141: public AttributeDesignator createAttributeDesignator(String name,
142: String nameSpace) {
143: return null;
144: }
145:
146: public AttributeStatement createAttributeStatement(Subject subj,
147: List attr) {
148: return null;
149: }
150:
151: public AttributeStatement createAttributeStatement(List attr) {
152: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.AttributeStatement(
153: attr);
154: }
155:
156: public AudienceRestrictionCondition createAudienceRestrictionCondition(
157: List audience) {
158: return null;
159: }
160:
161: public AudienceRestriction createAudienceRestriction(List audience) {
162: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.AudienceRestriction(
163: audience);
164: }
165:
166: public AuthenticationStatement createAuthenticationStatement(
167: String authMethod, GregorianCalendar authInstant,
168: Subject subject, SubjectLocality subjectLocality,
169: List authorityBinding) {
170:
171: return null;
172: }
173:
174: public AuthnStatement createAuthnStatement(
175: GregorianCalendar authInstant,
176: SubjectLocality subjectLocality, AuthnContext authnContext) {
177:
178: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.AuthnStatement(
179: authInstant,
180: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.SubjectLocality) subjectLocality,
181: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.AuthnContext) authnContext);
182: }
183:
184: public AuthorityBinding createAuthorityBinding(QName authKind,
185: String location, String binding) {
186: return null;
187: }
188:
189: public AuthnContext createAuthnContext() {
190: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.AuthnContext();
191: }
192:
193: public AuthorizationDecisionStatement createAuthorizationDecisionStatement(
194: Subject subject, String resource, String decision,
195: List action, Evidence evidence) {
196:
197: return null;
198: }
199:
200: public AuthnDecisionStatement createAuthnDecisionStatement(
201: String resource, String decision, List action,
202: Evidence evidence) {
203:
204: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.AuthzDecisionStatement(
205: resource,
206: decision,
207: action,
208: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.Evidence) evidence);
209: }
210:
211: public Conditions createConditions() {
212: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.Conditions();
213: }
214:
215: public Conditions createConditions(GregorianCalendar notBefore,
216: GregorianCalendar notOnOrAfter, List condition, List arc,
217: List doNotCacheCnd) {
218:
219: return null;
220: }
221:
222: public Conditions createConditions(GregorianCalendar notBefore,
223: GregorianCalendar notOnOrAfter, List condition, List ar,
224: List oneTimeUse, List proxyRestriction) {
225:
226: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.Conditions(
227: notBefore, notOnOrAfter, condition, ar, oneTimeUse,
228: proxyRestriction);
229: }
230:
231: public DoNotCacheCondition createDoNotCacheCondition() {
232: return null;
233: }
234:
235: public OneTimeUse createOneTimeUse() {
236: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.OneTimeUse();
237: }
238:
239: public Evidence createEvidence(List assertionIDRef, List assertion) {
240: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.Evidence(
241: assertionIDRef, assertion);
242: }
243:
244: public NameIdentifier createNameIdentifier(String name,
245: String nameQualifier, String format) {
246: return null;
247: }
248:
249: public NameID createNameID(String name, String nameQualifier,
250: String format) {
251: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.NameID(
252: name, nameQualifier, format);
253: }
254:
255: public Subject createSubject(NameIdentifier nameIdentifier,
256: SubjectConfirmation subjectConfirmation) {
257: return null;
258: }
259:
260: public Subject createSubject(NameID nameID,
261: SubjectConfirmation subjectConfirmation) {
262: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.Subject(
263: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.NameID) nameID,
264: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.SubjectConfirmation) subjectConfirmation);
265: }
266:
267: public SubjectConfirmation createSubjectConfirmation(
268: String confirmationMethod) {
269: return null;
270: }
271:
272: public SubjectConfirmation createSubjectConfirmation(NameID nameID,
273: String method) {
274: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.SubjectConfirmation(
275: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.NameID) nameID,
276: method);
277: }
278:
279: public SubjectConfirmation createSubjectConfirmation(
280: List confirmationMethods, SubjectConfirmationData scd,
281: KeyInfo keyInfo) throws SAMLException {
282: com.sun.xml.wss.saml.assertion.saml11.jaxb20.SubjectConfirmation sc = new com.sun.xml.wss.saml.assertion.saml11.jaxb20.SubjectConfirmation();
283:
284: try {
285: if (keyInfo != null) {
286: sc.setKeyInfo(keyInfo);
287: }
288: if (scd != null) {
289: sc.setSubjectConfirmationData(scd);
290: }
291: } catch (Exception ex) {
292: // log here
293: throw new SAMLException(ex);
294: }
295: sc.setConfirmationMethod(confirmationMethods);
296: return sc;
297: }
298:
299: public SubjectConfirmation createSubjectConfirmation(
300: List confirmationMethods, Element subjectConfirmationData,
301: Element keyInfo) throws SAMLException {
302:
303: return null;
304: }
305:
306: public SubjectConfirmation createSubjectConfirmation(NameID nameID,
307: SubjectConfirmationData subjectConfirmationData,
308: String confirmationMethod) throws SAMLException {
309:
310: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.SubjectConfirmation(
311: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.NameID) nameID,
312: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.SubjectConfirmationData) subjectConfirmationData,
313: confirmationMethod);
314: }
315:
316: public SubjectConfirmation createSubjectConfirmation(NameID nameID,
317: KeyInfoConfirmationData keyInfoConfirmationData,
318: String confirmationMethod) throws SAMLException {
319:
320: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.SubjectConfirmation(
321: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.NameID) nameID,
322: (com.sun.xml.wss.saml.assertion.saml20.jaxb20.KeyInfoConfirmationData) keyInfoConfirmationData,
323: confirmationMethod);
324: }
325:
326: public SubjectConfirmationData createSubjectConfirmationData(
327: String address, String inResponseTo,
328: GregorianCalendar notBefore,
329: GregorianCalendar notOnOrAfter, String recipient,
330: Element keyInfo) throws SAMLException {
331:
332: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.SubjectConfirmationData(
333: address, inResponseTo, notBefore, notOnOrAfter,
334: recipient, keyInfo);
335: }
336:
337: public SubjectConfirmationData createSubjectConfirmationData(
338: String address, String inResponseTo,
339: GregorianCalendar notBefore,
340: GregorianCalendar notOnOrAfter, String recipient,
341: KeyInfo keyInfo) throws SAMLException {
342: com.sun.xml.wss.saml.internal.saml20.jaxb20.SubjectConfirmationDataType scd = new com.sun.xml.wss.saml.assertion.saml20.jaxb20.SubjectConfirmationData();
343: scd.setAddress(address);
344: scd.setInResponseTo(inResponseTo);
345: if (notBefore != null) {
346: scd.setNotBefore(dataTypeFac
347: .newXMLGregorianCalendar(notBefore));
348: }
349:
350: if (notOnOrAfter != null) {
351: scd.setNotOnOrAfter(dataTypeFac
352: .newXMLGregorianCalendar(notOnOrAfter));
353: }
354:
355: scd.setRecipient(recipient);
356:
357: if (keyInfo != null) {
358: scd.getContent().add(keyInfo);
359: }
360: return (SubjectConfirmationData) scd;
361: }
362:
363: public KeyInfoConfirmationData createKeyInfoConfirmationData(
364: Element keyInfo) throws SAMLException {
365:
366: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.KeyInfoConfirmationData(
367: keyInfo);
368: }
369:
370: public SubjectLocality createSubjectLocality() {
371: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.SubjectLocality();
372: }
373:
374: public SubjectLocality createSubjectLocality(String ipAddress,
375: String dnsAddress) {
376: return new com.sun.xml.wss.saml.assertion.saml20.jaxb20.SubjectLocality(
377: ipAddress, dnsAddress);
378: }
379:
380: public Assertion createAssertion(XMLStreamReader reader)
381: throws SAMLException {
382: try {
383: Element samlElement = SAMLUtil.createSAMLAssertion(reader);
384: Assertion samlAssertion = (Assertion) (Assertion) com.sun.xml.wss.saml.assertion.saml20.jaxb20.Assertion
385: .fromElement(samlElement);
386: return samlAssertion;
387: } catch (XWSSecurityException ex) {
388: throw new SAMLException(ex);
389: } catch (XMLStreamException ex) {
390: throw new SAMLException(ex);
391: }
392: }
393:
394: }
|