001/**
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2006 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: AssertionFactory.java,v 1.3 2008/06/25 05:47:39 qcheng Exp $
026 *
027 */
028
029
030package com.sun.identity.saml2.assertion;
031
032import org.w3c.dom.Element;
033import com.sun.identity.saml2.assertion.impl.ActionImpl;
034import com.sun.identity.saml2.assertion.impl.AssertionIDRefImpl;
035import com.sun.identity.saml2.assertion.impl.AttributeImpl;
036import com.sun.identity.saml2.assertion.impl.EncryptedAttributeImpl;
037import com.sun.identity.saml2.assertion.impl.AttributeStatementImpl;
038import com.sun.identity.saml2.assertion.impl.AuthnContextImpl;
039import com.sun.identity.saml2.assertion.impl.AuthnStatementImpl;
040import com.sun.identity.saml2.assertion.impl.EncryptedAssertionImpl;
041import com.sun.identity.saml2.assertion.impl.EncryptedIDImpl;
042import com.sun.identity.saml2.assertion.impl.KeyInfoConfirmationDataImpl;
043import com.sun.identity.saml2.assertion.impl.SubjectConfirmationDataImpl;
044import com.sun.identity.saml2.assertion.impl.SubjectLocalityImpl;
045import com.sun.identity.saml2.assertion.impl.AdviceImpl;
046import com.sun.identity.saml2.assertion.impl.AudienceRestrictionImpl;
047import com.sun.identity.saml2.assertion.impl.BaseIDImpl;
048import com.sun.identity.saml2.assertion.impl.AssertionImpl;
049import com.sun.identity.saml2.assertion.impl.ConditionImpl;
050import com.sun.identity.saml2.assertion.impl.ConditionsImpl;
051import com.sun.identity.saml2.assertion.impl.IssuerImpl;
052import com.sun.identity.saml2.assertion.impl.NameIDImpl;
053import com.sun.identity.saml2.assertion.impl.OneTimeUseImpl;
054import com.sun.identity.saml2.assertion.impl.ProxyRestrictionImpl;
055import com.sun.identity.saml2.assertion.impl.SubjectImpl;
056import com.sun.identity.saml2.assertion.impl.SubjectConfirmationImpl;
057import com.sun.identity.saml2.common.SAML2Exception;
058import com.sun.identity.saml2.common.SAML2SDKUtils;
059
060/**
061 * This is the factory class to obtain instances of the objects defined
062 * in assertion schema.
063 * There are three ways to obtain an instance of a object type:
064 * with no parameters, with a DOM tree element, or with an XML String.
065 *
066 * @supported.all.api
067 */
068public class AssertionFactory {
069
070    private static AssertionFactory instance = new AssertionFactory();
071
072    /**
073     * Sole Constructor.
074     */
075    private AssertionFactory() {
076    }
077
078    /**
079     * Returns the instance of <code>AssertionFactory</code>.
080     * 
081     * @return <code>AssertionFactory</code>.
082     * 
083     */
084    public static AssertionFactory getInstance() {
085        return instance;
086    }
087
088    /**
089     * Returns a new instance of <code>Advice</code>.
090     *
091     * @return a new instance of <code>Advice</code>
092     * 
093     */
094    public Advice createAdvice() {
095        Object obj = SAML2SDKUtils.getObjectInstance(SAML2SDKUtils.ADVICE);
096        if (obj == null) {
097            return new AdviceImpl();
098        } else {
099            return (Advice) obj;
100        }
101    }
102
103    /**
104     * Returns a new instance of <code>Advice</code>.
105     * The return object is immutable.
106     *
107     * @param elem a DOM Element representation of <code>Advice</code>
108     * @return a new instance of <code>Advice</code>
109     * @throws SAML2Exception if error occurs while processing the 
110     *    DOM Element 
111     * 
112     */
113    public Advice createAdvice(Element elem)
114        throws SAML2Exception {
115        Object obj = SAML2SDKUtils.getObjectInstance(
116            SAML2SDKUtils.ADVICE, elem);
117        if (obj == null) {
118            return new AdviceImpl(elem);
119        } else {
120            return (Advice) obj;
121        }
122    }
123
124    /**
125     * Returns a new instance of <code>Advice</code>
126     * The return object is immutable.
127     *
128     * @param xml a XML string representation of <code>Advice</code>
129     * @return a new instance of <code>Advice</code>
130     * @throws SAML2Exception if error occurs while processing the 
131     *    XML string
132     * 
133     */
134    public Advice createAdvice(String xml)
135        throws SAML2Exception {
136        Object obj = SAML2SDKUtils.getObjectInstance(
137            SAML2SDKUtils.ADVICE, xml);
138        if (obj == null) {
139            return new AdviceImpl(xml);
140        } else {
141            return (Advice) obj;
142        }
143    }
144
145    /**
146     * Returns a new instance of <code>Assertion</code>.
147     *
148     * @return a new instance of <code>Assertion</code>
149     * 
150     */
151    public Assertion createAssertion() {
152        Object obj = SAML2SDKUtils.getObjectInstance(SAML2SDKUtils.ASSERTION);
153        if (obj == null) {
154            return new AssertionImpl();
155        } else {
156            return (Assertion) obj;
157        }
158    }
159
160    /**
161     * Returns a new instance of <code>Assertion</code>.
162     * The return object is immutable.
163     *
164     * @param elem a DOM Element representation of <code>Assertion</code>
165     * @return a new instance of <code>Assertion</code>
166     * @throws SAML2Exception if error occurs while processing the 
167     *    DOM Element 
168     * 
169     */
170    public Assertion createAssertion(Element elem)
171        throws SAML2Exception {
172        Object obj = SAML2SDKUtils.getObjectInstance(
173            SAML2SDKUtils.ASSERTION, elem);
174        if (obj == null) {
175            return new AssertionImpl(elem);
176        } else {
177            return (Assertion) obj;
178        }
179    }
180
181    /**
182     * Returns a new instance of <code>Assertion</code>.
183     * The return object is immutable.
184     *
185     * @param xml a XML string representation of <code>Assertion</code>
186     * @return a new instance of <code>Assertion</code>
187     * @throws SAML2Exception if error occurs while processing the 
188     *    XML string
189     * 
190     */
191    public Assertion createAssertion(String xml)
192        throws SAML2Exception {
193        Object obj = SAML2SDKUtils.getObjectInstance(
194            SAML2SDKUtils.ASSERTION, xml);
195        if (obj == null) {
196            return new AssertionImpl(xml);
197        } else {
198            return (Assertion) obj;
199        }
200    }
201
202    /**
203     * Returns a new instance of <code>AssertionIDRef</code>.
204     *
205     * @return a new instance of <code>AssertionIDRef</code>
206     * 
207     */
208    public AssertionIDRef createAssertionIDRef() {
209        Object obj = SAML2SDKUtils.getObjectInstance(
210            SAML2SDKUtils.ASSERTION_ID_REF);
211        if (obj == null) {
212            return new AssertionIDRefImpl();
213        } else {
214            return (AssertionIDRef) obj;
215        }
216    }
217
218    /**
219     * Returns a new instance of <code>AssertionIDRef</code>.
220     * The return object is immutable.
221     *
222     * @param elem a DOM Element representation of <code>AssertionIDRef</code>
223     * @return a new instance of <code>AssertionIDRef</code>
224     * @throws SAML2Exception if error occurs while processing the 
225     *    DOM Element 
226     * 
227     */
228    public AssertionIDRef createAssertionIDRef(Element elem)
229        throws SAML2Exception {
230        Object obj = SAML2SDKUtils.getObjectInstance(
231            SAML2SDKUtils.ASSERTION_ID_REF, elem);
232        if (obj == null) {
233            return new AssertionIDRefImpl(elem);
234        } else {
235            return (AssertionIDRef) obj;
236        }
237    }
238
239    /**
240     * Returns a new instance of <code>AssertionIDRef</code>.
241     * The return object is immutable.
242     *
243     * @param xml a XML string representation of <code>AssertionIDRef</code>
244     * @return a new instance of <code>AssertionIDRef</code>
245     * @throws SAML2Exception if error occurs while processing the 
246     *    XML string
247     * 
248     */
249    public AssertionIDRef createAssertionIDRef(String xml)
250        throws SAML2Exception {
251        Object obj = SAML2SDKUtils.getObjectInstance(
252            SAML2SDKUtils.ASSERTION_ID_REF, xml);
253        if (obj == null) {
254            return new AssertionIDRefImpl(xml);
255        } else {
256            return (AssertionIDRef) obj;
257        }
258    }
259
260    /**
261     * Returns a new instance of <code>AudienceRestriction</code>.
262     *
263     * @return a new instance of <code>AudienceRestriction</code>
264     * 
265     */
266    public AudienceRestriction createAudienceRestriction() {
267        Object obj = SAML2SDKUtils.getObjectInstance(
268            SAML2SDKUtils.AUDIENCE_RESTRICTION);
269        if (obj == null) {
270            return new AudienceRestrictionImpl();
271        } else {
272            return (AudienceRestriction) obj;
273        }
274    }
275
276    /**
277     * Returns a new instance of <code>AudienceRestriction</code>.
278     * The return object is immutable.
279     *
280     * @param elem a DOM Element representation of 
281     *        <code>AudienceRestriction</code>
282     * @return a new instance of <code>AudienceRestriction</code>
283     * @throws SAML2Exception if error occurs while processing the 
284     *    DOM Element 
285     * 
286     */
287    public AudienceRestriction createAudienceRestriction(Element elem)
288        throws SAML2Exception {
289        Object obj = SAML2SDKUtils.getObjectInstance(
290            SAML2SDKUtils.AUDIENCE_RESTRICTION, elem);
291        if (obj == null) {
292            return new AudienceRestrictionImpl(elem);
293        } else {
294            return (AudienceRestriction) obj;
295        }
296    }
297
298    /**
299     * Returns a new instance of <code>AudienceRestriction</code>.
300     * The return object is immutable.
301     *
302     * @param xml a XML string representation of
303     *        <code>AudienceRestriction</code>
304     * @return a new instance of <code>AudienceRestriction</code>
305     * @throws SAML2Exception if error occurs while processing the 
306     *    XML string
307     * 
308     */
309    public AudienceRestriction createAudienceRestriction(String xml)
310        throws SAML2Exception {
311        Object obj = SAML2SDKUtils.getObjectInstance(
312            SAML2SDKUtils.AUDIENCE_RESTRICTION, xml);
313        if (obj == null) {
314            return new AudienceRestrictionImpl(xml);
315        } else {
316            return (AudienceRestriction) obj;
317        }
318    }
319
320    /**
321     * Returns a new instance of <code>BaseID</code>.
322     *
323     * @return a new instance of <code>BaseID</code>
324     * 
325     */
326    public BaseID createBaseID() {
327        Object obj = SAML2SDKUtils.getObjectInstance(SAML2SDKUtils.BASEID);
328        if (obj == null) {
329            return new BaseIDImpl();
330        } else {
331            return (BaseID) obj;
332        }
333    }
334
335    /**
336     * Returns a new instance of <code>BaseID</code>.
337     * The return object is immutable.
338     *
339     * @param elem a DOM Element representation of <code>BaseID</code>
340     * @return a new instance of <code>BaseID</code>
341     * @throws SAML2Exception if error occurs while processing the 
342     *    DOM Element 
343     * 
344     */
345    public BaseID createBaseID(Element elem)
346        throws SAML2Exception {
347        Object obj = SAML2SDKUtils.getObjectInstance(
348            SAML2SDKUtils.BASEID, elem);
349        if (obj == null) {
350            return new BaseIDImpl(elem);
351        } else {
352            return (BaseID) obj;
353        }
354    }
355
356    /**
357     * Returns a new instance of <code>BaseID</code>.
358     * The return object is immutable.
359     *
360     * @param xml a XML string representation of <code>BaseID</code>
361     * @return a new instance of <code>BaseID</code>
362     * @throws SAML2Exception if error occurs while processing the 
363     *    XML string
364     * 
365     */
366    public BaseID createBaseID(String xml)
367        throws SAML2Exception {
368        Object obj = SAML2SDKUtils.getObjectInstance(
369            SAML2SDKUtils.BASEID, xml);
370        if (obj == null) {
371            return new BaseIDImpl(xml);
372        } else {
373            return (BaseID) obj;
374        }
375    }
376
377    /**
378     * Returns a new instance of <code>Condition</code>.
379     *
380     * @return a new instance of <code>Condition</code>
381     * 
382     */
383    public Condition createCondition() {
384        Object obj = SAML2SDKUtils.getObjectInstance(SAML2SDKUtils.CONDITION);
385        if (obj == null) {
386            return new ConditionImpl();
387        } else {
388            return (Condition) obj;
389        }
390    }
391
392    /**
393     * Returns a new instance of <code>Condition</code>.
394     * The return object is immutable.
395     *
396     * @param elem a DOM Element representation of <code>Condition</code>
397     * @return a new instance of <code>Condition</code>
398     * @throws SAML2Exception if error occurs while processing the 
399     *    DOM Element 
400     *   
401     */
402    public Condition createCondition(Element elem)
403        throws SAML2Exception {
404        Object obj = SAML2SDKUtils.getObjectInstance(
405            SAML2SDKUtils.CONDITION, elem);
406        if (obj == null) {
407            return new ConditionImpl(elem);
408        } else {
409            return (Condition) obj;
410        }
411    }
412
413    /**
414     * Returns a new instance of <code>Condition</code>.
415     * The return object is immutable.
416     *
417     * @param xml a XML string representation of <code>Condition</code>
418     * @return a new instance of <code>Condition</code>
419     * @throws SAML2Exception if error occurs while processing the 
420     *    XML string
421     * 
422     */
423    public Condition createCondition(String xml)
424        throws SAML2Exception {
425        Object obj = SAML2SDKUtils.getObjectInstance(
426            SAML2SDKUtils.CONDITION, xml);
427        if (obj == null) {
428            return new ConditionImpl(xml);
429        } else {
430            return (Condition) obj;
431        }
432    }
433
434    /**
435     * Returns a new instance of <code>Conditions</code>.
436     *
437     * @return a new instance of <code>Conditions</code>
438     * 
439     */
440    public Conditions createConditions() {
441        Object obj = SAML2SDKUtils.getObjectInstance(SAML2SDKUtils.CONDITIONS);
442        if (obj == null) {
443            return new ConditionsImpl();
444        } else {
445            return (Conditions) obj;
446        }
447    }
448
449    /**
450     * Returns a new instance of <code>Conditions</code>.
451     * The return object is immutable.
452     *
453     * @param elem a DOM Element representation of <code>Conditions</code>
454     * @return a new instance of <code>Conditions</code>
455     * @throws SAML2Exception if error occurs while processing the 
456     *    DOM Element 
457     * 
458     */
459    public Conditions createConditions(Element elem)
460        throws SAML2Exception {
461        Object obj = SAML2SDKUtils.getObjectInstance(
462            SAML2SDKUtils.CONDITIONS, elem);
463        if (obj == null) {
464            return new ConditionsImpl(elem);
465        } else {
466            return (Conditions) obj;
467        }
468    }
469
470    /**
471     * Returns a new instance of <code>Conditions</code>.
472     * The return object is immutable.
473     *
474     * @param xml a XML string representation of <code>Conditions</code>
475     * @return a new instance of <code>Conditions</code>
476     * @throws SAML2Exception if error occurs while processing the 
477     *    XML string
478     * 
479     */
480    public Conditions createConditions(String xml)
481        throws SAML2Exception {
482        Object obj = SAML2SDKUtils.getObjectInstance(
483            SAML2SDKUtils.CONDITIONS, xml);
484        if (obj == null) {
485            return new ConditionsImpl(xml);
486        } else {
487            return (Conditions) obj;
488        }
489    }
490
491    /**
492     * Returns a new instance of <code>EncryptedAssertion</code>.
493     * The return object is immutable.
494     *
495     * @param elem a DOM Element representation of
496     *        <code>EncryptedAssertion</code>
497     * @return a new instance of <code>EncryptedAssertion</code>
498     * @throws SAML2Exception if error occurs while processing the 
499     *    DOM Element 
500     * 
501     */
502    public EncryptedAssertion createEncryptedAssertion(Element elem)
503        throws SAML2Exception {
504        Object obj = SAML2SDKUtils.getObjectInstance(
505            SAML2SDKUtils.ENCRYPTED_ASSERTION, elem);
506        if (obj == null) {
507            return new EncryptedAssertionImpl(elem);
508        } else {
509            return (EncryptedAssertion) obj;
510        }
511    }
512
513    /**
514     * Returns a new instance of <code>EncryptedAssertion</code>.
515     * The return object is immutable.
516     *
517     * @param xml a XML string representation of <code>EncryptedAssertion</code>
518     * @return a new instance of <code>EncryptedAssertion</code>
519     * @throws SAML2Exception if error occurs while processing the 
520     *    XML string
521     * 
522     */
523    public EncryptedAssertion createEncryptedAssertion(String xml)
524        throws SAML2Exception {
525        Object obj = SAML2SDKUtils.getObjectInstance(
526            SAML2SDKUtils.ENCRYPTED_ASSERTION, xml);
527        if (obj == null) {
528            return new EncryptedAssertionImpl(xml);
529        } else {
530            return (EncryptedAssertion) obj;
531        }
532    }
533
534    /**
535     * Returns a new instance of <code>EncryptedID</code>.
536     * The return object is immutable.
537     *
538     * @param elem a DOM Element representation of <code>EncryptedID</code>
539     * @return a new instance of <code>EncryptedID</code>
540     * @throws SAML2Exception if error occurs while processing the 
541     *    DOM Element 
542     * 
543     */
544    public EncryptedID createEncryptedID(Element elem)
545        throws SAML2Exception {
546        Object obj = SAML2SDKUtils.getObjectInstance(
547            SAML2SDKUtils.ENCRYPTEDID, elem);
548        if (obj == null) {
549            return new EncryptedIDImpl(elem);
550        } else {
551            return (EncryptedID) obj;
552        }
553    }
554
555    /**
556     * Returns a new instance of <code>EncryptedID</code>.
557     * The return object is immutable.
558     *
559     * @param xml a XML string representation of <code>EncryptedID</code>
560     * @return a new instance of <code>EncryptedID</code>
561     * @throws SAML2Exception if error occurs while processing the 
562     *    XML string
563     * 
564     */
565    public EncryptedID createEncryptedID(String xml)
566        throws SAML2Exception {
567        Object obj = SAML2SDKUtils.getObjectInstance(
568            SAML2SDKUtils.ENCRYPTEDID, xml);
569        if (obj == null) {
570            return new EncryptedIDImpl(xml);
571        } else {
572            return (EncryptedID) obj;
573        }
574    }
575
576    /**
577     * Returns a new instance of <code>Issuer</code>.
578     *
579     * @return a new instance of <code>Issuer</code>
580     * 
581     */
582    public Issuer createIssuer() {
583        Object obj = SAML2SDKUtils.getObjectInstance(SAML2SDKUtils.ISSUER);
584        if (obj == null) {
585            return new IssuerImpl();
586        } else {
587            return (Issuer) obj;
588        }
589    }
590
591    /**
592     * Returns a new instance of <code>Issuer</code>.
593     * The return object is immutable.
594     *
595     * @param elem a DOM Element representation of <code>Issuer</code>
596     * @return a new instance of <code>Issuer</code>
597     * @throws SAML2Exception if error occurs while processing the 
598     *    DOM Element 
599     * 
600     */
601    public Issuer createIssuer(Element elem)
602        throws SAML2Exception {
603        Object obj = SAML2SDKUtils.getObjectInstance(
604            SAML2SDKUtils.ISSUER, elem);
605        if (obj == null) {
606            return new IssuerImpl(elem);
607        } else {
608            return (Issuer) obj;
609        }
610    }
611
612    /**
613     * Returns a new instance of <code>Issuer</code>.
614     * The return object is immutable.
615     *
616     * @param xml a XML string representation of <code>Issuer</code>
617     * @return a new instance of <code>Issuer</code>
618     * @throws SAML2Exception if error occurs while processing the 
619     *    XML string
620     * 
621     */
622    public Issuer createIssuer(String xml)
623        throws SAML2Exception {
624        Object obj = SAML2SDKUtils.getObjectInstance(
625            SAML2SDKUtils.ISSUER, xml);
626        if (obj == null) {
627            return new IssuerImpl(xml);
628        } else {
629            return (Issuer) obj;
630        }
631    }
632
633    /**
634     * Returns a new instance of <code>KeyInfoConfirmationData</code>.
635     *
636     * @return a new instance of <code>KeyInfoConfirmationData</code>
637     * 
638     */
639    public KeyInfoConfirmationData createKeyInfoConfirmationData() {
640        Object obj = SAML2SDKUtils.getObjectInstance(
641            SAML2SDKUtils.KEYINFO_CONFIRMATION_DATA);
642        if (obj == null) {
643            return new KeyInfoConfirmationDataImpl();
644        } else {
645            return (KeyInfoConfirmationData) obj;
646        }
647    }
648
649    /**
650     * Returns a new instance of <code>KeyInfoConfirmationData</code>.
651     * The return object is immutable.
652     *
653     * @param elem a DOM Element representation of
654     *        <code>KeyInfoConfirmationData</code>
655     * @return a new instance of <code>KeyInfoConfirmationData</code>
656     * @throws SAML2Exception if error occurs while processing the 
657     *    DOM Element 
658     * 
659     */
660    public KeyInfoConfirmationData createKeyInfoConfirmationData(Element elem)
661        throws SAML2Exception {
662        Object obj = SAML2SDKUtils.getObjectInstance(
663            SAML2SDKUtils.KEYINFO_CONFIRMATION_DATA, elem);
664        if (obj == null) {
665            return new KeyInfoConfirmationDataImpl(elem);
666        } else {
667            return (KeyInfoConfirmationData) obj;
668        }
669    }
670
671    /**
672     * Returns a new instance of <code>KeyInfoConfirmationData</code>.
673     * The return object is immutable.
674     *
675     * @param xml a XML string representation of
676     *        <code>KeyInfoConfirmationData</code>
677     * @return a new instance of <code>KeyInfoConfirmationData</code>
678     * @throws SAML2Exception if error occurs while processing the 
679     *    XML string
680     * 
681     */
682    public KeyInfoConfirmationData createKeyInfoConfirmationData(String xml)
683        throws SAML2Exception {
684        Object obj = SAML2SDKUtils.getObjectInstance(
685            SAML2SDKUtils.KEYINFO_CONFIRMATION_DATA, xml);
686        if (obj == null) {
687            return new KeyInfoConfirmationDataImpl(xml);
688        } else {
689            return (KeyInfoConfirmationData) obj;
690        }
691    }
692
693    /**
694     * Returns a new instance of <code>NameID</code>.
695     *
696     * @return a new instance of <code>NameID</code>
697     * 
698     */
699    public NameID createNameID() {
700        Object obj = SAML2SDKUtils.getObjectInstance(SAML2SDKUtils.NAMEID);
701        if (obj == null) {
702            return new NameIDImpl();
703        } else {
704            return (NameID) obj;
705        }
706    }
707
708    /**
709     * Returns a new instance of <code>NameID</code>.
710     * The return object is immutable.
711     *
712     * @param elem a DOM Element representation of <code>NameID</code>
713     * @return a new instance of <code>NameID</code>
714     * @throws SAML2Exception if error occurs while processing the 
715     *    DOM Element 
716     * 
717     */
718    public NameID createNameID(Element elem)
719        throws SAML2Exception {
720        Object obj = SAML2SDKUtils.getObjectInstance(
721            SAML2SDKUtils.NAMEID, elem);
722        if (obj == null) {
723            return new NameIDImpl(elem);
724        } else {
725            return (NameID) obj;
726        }
727    }
728
729    /**
730     * Returns a new instance of <code>NameID</code>.
731     * The return object is immutable.
732     *
733     * @param xml a XML string representation of <code>NameID</code>
734     * @return a new instance of <code>NameID</code>
735     * @throws SAML2Exception if error occurs while processing the 
736     *    XML string
737     * 
738     */
739    public NameID createNameID(String xml)
740        throws SAML2Exception {
741        Object obj = SAML2SDKUtils.getObjectInstance(
742            SAML2SDKUtils.NAMEID, xml);
743        if (obj == null) {
744            return new NameIDImpl(xml);
745        } else {
746            return (NameID) obj;
747        }
748    }
749
750    /**
751     * Returns a new instance of <code>OneTimeUse</code>.
752     *
753     * @return a new instance of <code>OneTimeUse</code>
754     * 
755     */
756    public OneTimeUse createOneTimeUse() {
757        Object obj = SAML2SDKUtils.getObjectInstance(
758            SAML2SDKUtils.ONE_TIME_USE);
759        if (obj == null) {
760            return new OneTimeUseImpl();
761        } else {
762            return (OneTimeUse) obj;
763        }
764    }
765
766    /**
767     * Returns a new instance of <code>OneTimeUse</code>.
768     * The return object is immutable.
769     *
770     * @param elem a DOM Element representation of <code>OneTimeUse</code>
771     * @return a new instance of <code>OneTimeUse</code>
772     * @throws SAML2Exception if error occurs while processing the 
773     *    DOM Element 
774     * 
775     */
776    public OneTimeUse createOneTimeUse(Element elem)
777        throws SAML2Exception {
778        Object obj = SAML2SDKUtils.getObjectInstance(
779            SAML2SDKUtils.ONE_TIME_USE, elem);
780        if (obj == null) {
781            return new OneTimeUseImpl(elem);
782        } else {
783            return (OneTimeUse) obj;
784        }
785    }
786
787    /**
788     * Returns a new instance of <code>OneTimeUse</code>.
789     * The return object is immutable.
790     *
791     * @param xml a XML string representation of <code>OneTimeUse</code>
792     * @return a new instance of <code>OneTimeUse</code>
793     * @throws SAML2Exception if error occurs while processing the 
794     *    XML string
795     * 
796     */
797    public OneTimeUse createOneTimeUse(String xml)
798        throws SAML2Exception {
799        Object obj = SAML2SDKUtils.getObjectInstance(
800            SAML2SDKUtils.ONE_TIME_USE, xml);
801        if (obj == null) {
802            return new OneTimeUseImpl(xml);
803        } else {
804            return (OneTimeUse) obj;
805        }
806    }
807
808    /**
809     * Returns a new instance of <code>ProxyRestriction</code>.
810     *
811     * @return a new instance of <code>ProxyRestriction</code>
812     * 
813     */
814    public ProxyRestriction createProxyRestriction() {
815        Object obj = SAML2SDKUtils.getObjectInstance(
816            SAML2SDKUtils.PROXY_RESTRICTION);
817        if (obj == null) {
818            return new ProxyRestrictionImpl();
819        } else {
820            return (ProxyRestriction) obj;
821        }
822    }
823
824    /**
825     * Returns a new instance of <code>ProxyRestriction</code>.
826     * The return object is immutable.
827     *
828     * @param elem a DOM Element representation of <code>ProxyRestriction</code>
829     * @return a new instance of <code>ProxyRestriction</code>
830     * @throws SAML2Exception if error occurs while processing the 
831     *    DOM Element 
832     * 
833     */
834    public ProxyRestriction createProxyRestriction(Element elem)
835        throws SAML2Exception {
836        Object obj = SAML2SDKUtils.getObjectInstance(
837            SAML2SDKUtils.PROXY_RESTRICTION, elem);
838        if (obj == null) {
839            return new ProxyRestrictionImpl(elem);
840        } else {
841            return (ProxyRestriction) obj;
842        }
843    }
844
845    /**
846     * Returns a new instance of <code>ProxyRestriction</code>.
847     * The return object is immutable.
848     *
849     * @param xml a XML string representation of <code>ProxyRestriction</code>
850     * @return a new instance of <code>ProxyRestriction</code>
851     * @throws SAML2Exception if error occurs while processing the 
852     *    XML string
853     * 
854     */
855    public ProxyRestriction createProxyRestriction(String xml)
856        throws SAML2Exception {
857        Object obj = SAML2SDKUtils.getObjectInstance(
858            SAML2SDKUtils.PROXY_RESTRICTION, xml);
859        if (obj == null) {
860            return new ProxyRestrictionImpl(xml);
861        } else {
862            return (ProxyRestriction) obj;
863        }
864    }
865
866    /**
867     * Returns a new instance of <code>Subject</code>.
868     *
869     * @return a new instance of <code>Subject</code>
870     * 
871     */
872    public Subject createSubject() {
873        Object obj = SAML2SDKUtils.getObjectInstance(SAML2SDKUtils.SUBJECT);
874        if (obj == null) {
875            return new SubjectImpl();
876        } else {
877            return (Subject) obj;
878        }
879    }
880
881    /**
882     * Returns a new instance of <code>Subject</code>.
883     * The return object is immutable.
884     *
885     * @param elem a DOM Element representation of <code>Subject</code>
886     * @return a new instance of <code>Subject</code>
887     * @throws SAML2Exception if error occurs while processing the 
888     *    DOM Element 
889     * 
890     */
891    public Subject createSubject(Element elem)
892        throws SAML2Exception {
893        Object obj = SAML2SDKUtils.getObjectInstance(
894            SAML2SDKUtils.SUBJECT, elem);
895        if (obj == null) {
896            return new SubjectImpl(elem);
897        } else {
898            return (Subject) obj;
899        }
900    }
901
902    /**
903     * Returns a new instance of <code>Subject</code>.
904     * The return object is immutable.
905     *
906     * @param xml a XML string representation of <code>Subject</code>
907     * @return a new instance of <code>Subject</code>
908     * @throws SAML2Exception if error occurs while processing the 
909     *    XML string
910     * 
911     */
912    public Subject createSubject(String xml)
913        throws SAML2Exception {
914        Object obj = SAML2SDKUtils.getObjectInstance(
915            SAML2SDKUtils.SUBJECT, xml);
916        if (obj == null) {
917            return new SubjectImpl(xml);
918        } else {
919            return (Subject) obj;
920        }
921    }
922
923    /**
924     * Returns a new instance of <code>SubjectConfirmation</code>.
925     *
926     * @return a new instance of <code>SubjectConfirmation</code>
927     * 
928     */
929    public SubjectConfirmation createSubjectConfirmation() {
930        Object obj = SAML2SDKUtils.getObjectInstance(
931            SAML2SDKUtils.SUBJECT_CONFIRMATION);
932        if (obj == null) {
933            return new SubjectConfirmationImpl();
934        } else {
935            return (SubjectConfirmation) obj;
936        }
937    }
938
939    /**
940     * Returns a new instance of <code>SubjectConfirmation</code>.
941     * The return object is immutable.
942     *
943     * @param elem a DOM Element representation of
944     *        <code>SubjectConfirmation</code>
945     * @return a new instance of <code>SubjectConfirmation</code>
946     * @throws SAML2Exception if error occurs while processing the 
947     *    DOM Element 
948     * 
949     */
950    public SubjectConfirmation createSubjectConfirmation(Element elem)
951        throws SAML2Exception {
952        Object obj = SAML2SDKUtils.getObjectInstance(
953            SAML2SDKUtils.SUBJECT_CONFIRMATION, elem);
954        if (obj == null) {
955            return new SubjectConfirmationImpl(elem);
956        } else {
957            return (SubjectConfirmation) obj;
958        }
959    }
960
961    /**
962     * Returns a new instance of <code>SubjectConfirmation</code>. The return
963     * object is immutable.
964     *
965     * @param xml a XML string representation of 
966     *        <code>SubjectConfirmation</code>
967     * @return a new instance of <code>SubjectConfirmation</code>
968     * @throws SAML2Exception if error occurs while processing the 
969     *    XML string
970     * 
971     */
972    public SubjectConfirmation createSubjectConfirmation(String xml)
973        throws SAML2Exception {
974        Object obj = SAML2SDKUtils.getObjectInstance(
975            SAML2SDKUtils.SUBJECT_CONFIRMATION, xml);
976        if (obj == null) {
977            return new SubjectConfirmationImpl(xml);
978        } else {
979            return (SubjectConfirmation) obj;
980        }
981    }
982
983    /**
984     * Returns a new instance of <code>SubjectConfirmationData</code>.
985     *
986     * @return a new instance of <code>SubjectConfirmationData</code>
987     * 
988     */
989    public SubjectConfirmationData createSubjectConfirmationData() {
990        Object obj = SAML2SDKUtils.getObjectInstance(
991            SAML2SDKUtils.SUBJECT_CONFIRMATION_DATA);
992        if (obj == null) {
993            return new SubjectConfirmationDataImpl();
994        } else {
995            return (SubjectConfirmationData) obj;
996        }
997    }
998
999    /**
1000     * Returns a new instance of <code>SubjectConfirmationData</code>. The
1001     * return object is immutable.
1002     *
1003     * @param elem a DOM Element representation of
1004     *        <code>SubjectConfirmationData</code>
1005     * @return a new instance of <code>SubjectConfirmationData</code>
1006     * @throws SAML2Exception if error occurs while processing the 
1007     *    DOM Element 
1008     * 
1009     */
1010    public SubjectConfirmationData createSubjectConfirmationData(Element elem)
1011        throws SAML2Exception {
1012        Object obj = SAML2SDKUtils.getObjectInstance(
1013            SAML2SDKUtils.SUBJECT_CONFIRMATION_DATA, elem);
1014        if (obj == null) {
1015            return new SubjectConfirmationDataImpl(elem);
1016        } else {
1017            return (SubjectConfirmationData) obj;
1018        }
1019    }
1020
1021    /**
1022     * Returns a new instance of <code>SubjectConfirmationData</code>. The
1023     * return object is immutable.
1024     *
1025     * @param xml a XML string representation of
1026     *        <code>SubjectConfirmationData</code>
1027     * @return a new instance of <code>SubjectConfirmationData</code>
1028     * @throws SAML2Exception if error occurs while processing the 
1029     *    XML string
1030     * 
1031     */
1032    public SubjectConfirmationData createSubjectConfirmationData(String xml)
1033        throws SAML2Exception {
1034        Object obj = SAML2SDKUtils.getObjectInstance(
1035            SAML2SDKUtils.SUBJECT_CONFIRMATION_DATA, xml);
1036        if (obj == null) {
1037            return new SubjectConfirmationDataImpl(xml);
1038        } else {
1039            return (SubjectConfirmationData) obj;
1040        }
1041    }
1042
1043    /**
1044     * Returns a new instance of <code>Action</code>.
1045     * Caller may need to call setters of the class to populate the object.
1046     *
1047     * @return a new instance of <code>Action</code>.
1048     * 
1049     */
1050    public Action createAction() {
1051        Object obj = SAML2SDKUtils.getObjectInstance(SAML2SDKUtils.ACTION);
1052        if (obj == null) {
1053            return new ActionImpl();
1054        } else {
1055            return (Action) obj;
1056        }
1057    }
1058
1059    /**
1060     * Returns a new instance of <code>Action</code>. The return object
1061     * is immutable.
1062     *
1063     * @param elem an <code>Element</code> representing <code>Action</code>.
1064     * @return a new instance of <code>Action</code>.
1065     * @throws SAML2Exception if error occurs while processing the
1066     *                <code>Element</code>.
1067     * 
1068     */
1069    public Action createAction(org.w3c.dom.Element elem)
1070                throws SAML2Exception
1071    {
1072        Object obj = SAML2SDKUtils.getObjectInstance(
1073            SAML2SDKUtils.ACTION, elem);
1074        if (obj == null) {
1075            return new ActionImpl(elem);
1076        } else {
1077            return (Action) obj;
1078        }
1079    }
1080
1081    /**
1082     * Returns a new instance of <code>Action</code>. The return object
1083     * is immutable.
1084     *
1085     * @param xml an XML String representing <code>Action</code>.
1086     * @return a new instance of <code>Action</code>.
1087     * @throws SAML2Exception if error occurs while processing the XML string.
1088     * 
1089     */
1090    public Action createAction(String xml)
1091                throws SAML2Exception
1092    {
1093        Object obj = SAML2SDKUtils.getObjectInstance(
1094            SAML2SDKUtils.ACTION, xml);
1095        if (obj == null) {
1096            return new ActionImpl(xml);
1097        } else {
1098            return (Action) obj;
1099        }
1100    }
1101
1102    /**
1103     * Returns a new instance of <code>Attribute</code>.
1104     * Caller may need to call setters of the class to populate the object.
1105     *
1106     * @return a new instance of <code>Attribute</code>.
1107     * 
1108     */
1109    public Attribute createAttribute() {
1110        Object obj = SAML2SDKUtils.getObjectInstance(SAML2SDKUtils.ATTRIBUTE);
1111        if (obj == null) {
1112            return new AttributeImpl();
1113        } else {
1114            return (Attribute) obj;
1115        }
1116    }
1117
1118    /**
1119     * Returns a new instance of <code>Attribute</code>. The return object
1120     * is immutable.
1121     *
1122     * @param elem an <code>Element</code> representation of
1123     *                <code>Attribute</code>.
1124     * @return a new instance of <code>Attribute</code>.
1125     * @throws SAML2Exception if error occurs while processing the
1126     *                <code>Element</code>.
1127     * 
1128     */
1129    public Attribute createAttribute(org.w3c.dom.Element elem)
1130                throws SAML2Exception
1131    {
1132        Object obj = SAML2SDKUtils.getObjectInstance(
1133            SAML2SDKUtils.ATTRIBUTE, elem);
1134        if (obj == null) {
1135            return new AttributeImpl(elem);
1136        } else {
1137            return (Attribute) obj;
1138        }
1139    }
1140
1141    /**
1142     * Returns a new instance of <code>Attribute</code>. The return object
1143     * is immutable.
1144     *
1145     * @param xml an XML String representing <code>Attribute</code>.
1146     * @return a new instance of <code>Attribute</code>.
1147     * @throws SAML2Exception if error occurs while processing the XML string.
1148     * 
1149     */
1150    public Attribute createAttribute(String xml)
1151                throws SAML2Exception
1152    {
1153        Object obj = SAML2SDKUtils.getObjectInstance(
1154            SAML2SDKUtils.ATTRIBUTE, xml);
1155        if (obj == null) {
1156            return new AttributeImpl(xml);
1157        } else {
1158            return (Attribute) obj;
1159        }
1160    }
1161
1162    /**
1163     * Returns a new instance of <code>AttributeStatement</code>.
1164     * Caller may need to call setters of the class to populate the object.
1165     *
1166     * @return a new instance of <code>AttributeStatement</code>.
1167     * 
1168     */
1169    public AttributeStatement createAttributeStatement() {
1170        Object obj = SAML2SDKUtils.getObjectInstance(
1171            SAML2SDKUtils.ATTRIBUTE_STATEMENT);
1172        if (obj == null) {
1173            return new AttributeStatementImpl();
1174        } else {
1175            return (AttributeStatement) obj;
1176        }
1177    }
1178
1179    /**
1180     * Returns a new instance of <code>AttributeStatement</code>. The return
1181     * object is immutable.
1182     *
1183     * @param elem an <code>Element</code> representation of
1184     *          <code>AttributeStatement</code>.
1185     * @return a new instance of <code>AttributeStatement</code>.
1186     * @throws SAML2Exception if error occurs while processing the
1187     *                <code>Element</code>.
1188     * 
1189     */
1190    public AttributeStatement createAttributeStatement(
1191                org.w3c.dom.Element elem)
1192                throws SAML2Exception
1193    {
1194        Object obj = SAML2SDKUtils.getObjectInstance(
1195            SAML2SDKUtils.ATTRIBUTE_STATEMENT, elem);
1196        if (obj == null) {
1197            return new AttributeStatementImpl(elem);
1198        } else {
1199            return (AttributeStatement) obj;
1200        }
1201    }
1202
1203    /**
1204     * Returns a new instance of <code>AttributeStatement</code>. The return
1205     * object is immutable.
1206     *
1207     * @param xml an XML String representing <code>AttributeStatement</code>.
1208     * @return a new instance of <code>AttributeStatement</code>.
1209     * @throws SAML2Exception if error occurs while processing the XML string.
1210     * 
1211     */
1212    public AttributeStatement createAttributeStatement(String xml)
1213                throws SAML2Exception
1214    {
1215        Object obj = SAML2SDKUtils.getObjectInstance(
1216            SAML2SDKUtils.ATTRIBUTE_STATEMENT, xml);
1217        if (obj == null) {
1218            return new AttributeStatementImpl(xml);
1219        } else {
1220            return (AttributeStatement) obj;
1221        }
1222    }
1223
1224    /**
1225     * Returns a new instance of <code>AuthnContext</code>.
1226     * Caller may need to call setters of the class to populate the object.
1227     *
1228     * @return a new instance of <code>AuthnContext</code>.
1229     * 
1230     */
1231    public AuthnContext createAuthnContext() {
1232        Object obj = SAML2SDKUtils.getObjectInstance(
1233            SAML2SDKUtils.AUTHN_CONTEXT);
1234        if (obj == null) {
1235            return new AuthnContextImpl();
1236        } else {
1237            return (AuthnContext) obj;
1238        }
1239    }
1240
1241    /**
1242     * Returns a new instance of <code>AuthnContext</code>. The return object
1243     * is immutable.
1244     *
1245     * @param elem an <code>Element</code> representation of
1246     *                <code>AuthnContext</code>.
1247     * @return a new instance of <code>AuthnContext</code>.
1248     * @throws SAML2Exception if error occurs
1249     *          while processing the <code>Element</code>.
1250     * 
1251     */
1252    public AuthnContext createAuthnContext(org.w3c.dom.Element elem)
1253                throws SAML2Exception
1254    {
1255        Object obj = SAML2SDKUtils.getObjectInstance(
1256            SAML2SDKUtils.AUTHN_CONTEXT, elem);
1257        if (obj == null) {
1258            return new AuthnContextImpl(elem);
1259        } else {
1260            return (AuthnContext) obj;
1261        }
1262    }
1263
1264    /**
1265     * Returns a new instance of <code>AuthnContext</code>. The return object
1266     * is immutable.
1267     *
1268     * @param xml an XML String representing <code>AuthnContext</code>.
1269     * @return a new instance of <code>AuthnContext</code>.
1270     * @throws SAML2Exception if error occurs while processing the XML string.
1271     * 
1272     */
1273    public AuthnContext createAuthnContext(String xml)
1274                throws SAML2Exception
1275    {
1276        Object obj = SAML2SDKUtils.getObjectInstance(
1277            SAML2SDKUtils.AUTHN_CONTEXT, xml);
1278        if (obj == null) {
1279            return new AuthnContextImpl(xml);
1280        } else {
1281            return (AuthnContext) obj;
1282        }
1283    }
1284
1285    /**
1286     * Returns a new instance of <code>AuthnStatement</code>.
1287     * Caller may need to call setters of the class to populate the object.
1288     *
1289     * @return a new instance of <code>AuthnStatement</code>.
1290     * 
1291     */
1292    public AuthnStatement createAuthnStatement() {
1293        Object obj = SAML2SDKUtils.getObjectInstance(
1294            SAML2SDKUtils.AUTHN_STATEMENT);
1295        if (obj == null) {
1296            return new AuthnStatementImpl();
1297        } else {
1298            return (AuthnStatement) obj;
1299        }
1300    }
1301
1302    /**
1303     * Returns a new instance of <code>AuthnStatement</code>. The return object
1304     * is immutable.
1305     *
1306     * @param elem an <code>Element</code> representation of
1307     *                <code>AuthnStatement</code>.
1308     * @return a new instance of <code>AuthnStatement</code>.
1309     * @throws SAML2Exception if error occurs while processing the
1310     *                <code>Element</code>.
1311     * 
1312     */
1313    public AuthnStatement createAuthnStatement(org.w3c.dom.Element elem)
1314                throws SAML2Exception
1315    {
1316        Object obj = SAML2SDKUtils.getObjectInstance(
1317            SAML2SDKUtils.AUTHN_STATEMENT, elem);
1318        if (obj == null) {
1319            return new AuthnStatementImpl(elem);
1320        } else {
1321            return (AuthnStatement) obj;
1322        }
1323    }
1324
1325    /**
1326     * Returns a new instance of <code>AuthnStatement</code>. The return
1327     * object is immutable.
1328     *
1329     * @param xml an XML String representing <code>AuthnStatement</code>.
1330     * @return a new instance of <code>AuthnStatement</code>.
1331     * @throws SAML2Exception if error occurs while processing the XML string.
1332     * 
1333     */
1334    public AuthnStatement createAuthnStatement(String xml)
1335                throws SAML2Exception
1336    {
1337        Object obj = SAML2SDKUtils.getObjectInstance(
1338            SAML2SDKUtils.AUTHN_STATEMENT, xml);
1339        if (obj == null) {
1340            return new AuthnStatementImpl(xml);
1341        } else {
1342            return (AuthnStatement) obj;
1343        }
1344    }
1345
1346    /**
1347     * Returns a new instance of <code>AuthzDecisionStatement</code>.
1348     * Caller may need to call setters of the class to populate the object.
1349     *
1350     * @return a new instance of <code>AuthzDecisionStatement</code>.
1351     * 
1352     */
1353    public AuthzDecisionStatement createAuthzDecisionStatement() {
1354        Object obj = SAML2SDKUtils.getObjectInstance(
1355            SAML2SDKUtils.AUTHZ_DECISION_STATEMENT);
1356        if (obj == null) {
1357            return null;
1358        } else {
1359            return (AuthzDecisionStatement) obj;
1360        }
1361    }
1362
1363    /**
1364     * Returns a new instance of <code>AuthzDecisionStatement</code>. The return
1365     * object is immutable.
1366     *
1367     * @param elem an <code>Element</code> representation of
1368     *          <code>AuthzDecisionStatement</code>.
1369     * @return a new instance of <code>AuthzDecisionStatement</code>.
1370     * @throws SAML2Exception if error occurs while processing the
1371     *                <code>Element</code>.
1372     * 
1373     */
1374    public AuthzDecisionStatement createAuthzDecisionStatement(
1375                org.w3c.dom.Element elem)
1376                throws SAML2Exception
1377    {
1378        Object obj = SAML2SDKUtils.getObjectInstance(
1379            SAML2SDKUtils.AUTHZ_DECISION_STATEMENT, elem);
1380        if (obj == null) {
1381            return null;
1382        } else {
1383            return (AuthzDecisionStatement) obj;
1384        }
1385    }
1386
1387    /**
1388     * Returns a new instance of <code>AuthzDecisionStatement</code>. The return
1389     * object is immutable.
1390     *
1391     * @param xml an XML String representing
1392     *                <code>AuthzDecisionStatement</code>.
1393     * @return a new instance of <code>AuthzDecisionStatement</code>.
1394     * @throws SAML2Exception if error occurs while processing the XML string.
1395     * 
1396     */
1397    public AuthzDecisionStatement createAuthzDecisionStatement(String xml)
1398                throws SAML2Exception
1399    {
1400        Object obj = SAML2SDKUtils.getObjectInstance(
1401            SAML2SDKUtils.AUTHZ_DECISION_STATEMENT, xml);
1402        if (obj == null) {
1403            return null;
1404        } else {
1405            return (AuthzDecisionStatement) obj;
1406        }
1407    }
1408
1409    /**
1410     * Returns a new instance of <code>EncryptedAttribute</code>. The return
1411     * object is immutable.
1412     *
1413     * @param elem an <code>Element</code> representation of
1414     *          <code>EncryptedAttribute</code>.
1415     * @return a new instance of <code>EncryptedAttribute</code>.
1416     * @throws SAML2Exception if error occurs
1417     *          while processing the <code>Element</code>.
1418     * 
1419     */
1420    public EncryptedAttribute createEncryptedAttribute(
1421                org.w3c.dom.Element elem)
1422                throws SAML2Exception
1423    {
1424        Object obj = SAML2SDKUtils.getObjectInstance(
1425            SAML2SDKUtils.ENCRYPTED_ATTRIBUTE, elem);
1426        if (obj == null) {
1427            return new EncryptedAttributeImpl(elem);
1428        } else {
1429            return (EncryptedAttribute) obj;
1430        }
1431    }
1432
1433    /**
1434     * Returns a new instance of <code>EncryptedAttribute</code>. The return
1435     * object is immutable.
1436     *
1437     * @param xml an XML String representing <code>EncryptedAttribute</code>.
1438.
1439     * @return a new instance of <code>EncryptedAttribute</code>.
1440     * @throws SAML2Exception if error occurs while processing the XML string.
1441     * 
1442     */
1443    public EncryptedAttribute createEncryptedAttribute(String xml)
1444                throws SAML2Exception
1445    {
1446        Object obj = SAML2SDKUtils.getObjectInstance(
1447            SAML2SDKUtils.ENCRYPTED_ATTRIBUTE, xml);
1448        if (obj == null) {
1449            return new EncryptedAttributeImpl(xml);
1450        } else {
1451            return (EncryptedAttribute) obj;
1452        }
1453    }
1454
1455    /**
1456     * Returns a new instance of <code>Evidence</code>.
1457     * Caller may need to call setters of the class to populate the object.
1458     *
1459     * @return a new instance of <code>Evidence</code>.
1460     * 
1461     */
1462    public Evidence createEvidence() {
1463        Object obj = SAML2SDKUtils.getObjectInstance(
1464            SAML2SDKUtils.EVIDENCE);
1465        if (obj == null) {
1466            return null;
1467        } else {
1468            return (Evidence) obj;
1469        }
1470    }
1471
1472    /**
1473     * Returns a new instance of <code>Evidence</code>. The return object is
1474     * immutable.
1475     *
1476     * @param elem a <code>Element</code> representation of
1477     *                <code>Evidence</code>.
1478     * @return a new instance of <code>Evidence</code>.
1479     * @throws SAML2Exception if error occurs
1480     *          while processing the <code>Element</code>.
1481     * 
1482     */
1483    public Evidence createEvidence(org.w3c.dom.Element elem)
1484                throws SAML2Exception
1485    {
1486        Object obj = SAML2SDKUtils.getObjectInstance(
1487            SAML2SDKUtils.EVIDENCE, elem);
1488        if (obj == null) {
1489            return null;
1490        } else {
1491            return (Evidence) obj;
1492        }
1493    }
1494
1495    /**
1496     * Returns a new instance of <code>Evidence</code>. The return object
1497     * is immutable.
1498     *
1499     * @param xml an XML String representing <code>Evidence</code>.
1500     * @return a new instance of <code>Evidence</code>.
1501     * @throws SAML2Exception if error occurs while processing the XML string.
1502     * 
1503     */
1504    public Evidence createEvidence(String xml) throws SAML2Exception
1505    {
1506        Object obj = SAML2SDKUtils.getObjectInstance(
1507            SAML2SDKUtils.EVIDENCE, xml);
1508        if (obj == null) {
1509            return null;
1510        } else {
1511            return (Evidence) obj;
1512        }
1513    }
1514
1515    /**
1516     * Returns a new instance of <code>SubjectLocality</code>.
1517     * Caller may need to call setters of the class to populate the object.
1518     *
1519     * @return a new instance of <code>SubjectLocality</code>.
1520     * 
1521     */
1522    public SubjectLocality createSubjectLocality() {
1523        Object obj = SAML2SDKUtils.getObjectInstance(
1524            SAML2SDKUtils.SUBJECT_LOCALITY);
1525        if (obj == null) {
1526            return new SubjectLocalityImpl();
1527        } else {
1528            return (SubjectLocality) obj;
1529        }
1530    }
1531
1532    /**
1533     * Returns a new instance of <code>SubjectLocality</code>. The return object
1534     * is immutable.
1535     *
1536     * @param elem an <code>Element</code> representing
1537     *                <code>SubjectLocality</code>.
1538     * @return a new instance of <code>SubjectLocality</code>.
1539     * @throws SAML2Exception if error occurs
1540     *          while processing the <code>Element</code>.
1541     * 
1542     */
1543    public SubjectLocality createSubjectLocality(org.w3c.dom.Element elem)
1544                throws SAML2Exception
1545    {
1546        Object obj = SAML2SDKUtils.getObjectInstance(
1547            SAML2SDKUtils.SUBJECT_LOCALITY, elem);
1548        if (obj == null) {
1549            return new SubjectLocalityImpl(elem);
1550        } else {
1551            return (SubjectLocality) obj;
1552        }
1553    }
1554
1555    /**
1556     * Returns a new instance of <code>SubjectLocality</code>. The return object
1557     * is immutable.
1558     *
1559     * @param xml an XML String representing <code>SubjectLocality</code>.
1560     * @return a new instance of <code>SubjectLocality</code>.
1561     * @throws SAML2Exception if error occurs while processing the XML string.
1562     * 
1563     */
1564    public SubjectLocality createSubjectLocality(String xml)
1565                throws SAML2Exception
1566    {
1567        Object obj = SAML2SDKUtils.getObjectInstance(
1568            SAML2SDKUtils.SUBJECT_LOCALITY, xml);
1569        if (obj == null) {
1570            return new SubjectLocalityImpl(xml);
1571        } else {
1572            return (SubjectLocality) obj;
1573        }
1574    }
1575}