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: ContextFactory.java,v 1.3 2008/06/25 05:48:11 qcheng Exp $
026 *
027 */
028
029
030package com.sun.identity.xacml.context;
031
032import org.w3c.dom.Element;
033import com.sun.identity.saml2.common.SAML2Exception;
034import com.sun.identity.xacml.common.XACMLException;
035import com.sun.identity.xacml.common.XACMLSDKUtils;
036import com.sun.identity.xacml.common.XACMLConstants;
037import com.sun.identity.xacml.context.impl.ActionImpl;
038import com.sun.identity.xacml.context.impl.AttributeImpl;
039import com.sun.identity.xacml.context.impl.EnvironmentImpl;
040import com.sun.identity.xacml.context.impl.RequestImpl;
041import com.sun.identity.xacml.context.impl.ResourceImpl;
042import com.sun.identity.xacml.context.impl.SubjectImpl;
043import com.sun.identity.xacml.context.impl.DecisionImpl;
044import com.sun.identity.xacml.context.impl.StatusCodeImpl;
045import com.sun.identity.xacml.context.impl.StatusDetailImpl;
046import com.sun.identity.xacml.context.impl.StatusImpl;
047import com.sun.identity.xacml.context.impl.StatusMessageImpl;
048import com.sun.identity.xacml.context.impl.ResponseImpl;
049import com.sun.identity.xacml.context.impl.ResultImpl;
050import com.sun.identity.xacml.saml2.XACMLAuthzDecisionQuery;
051import com.sun.identity.xacml.saml2.XACMLAuthzDecisionQuery;
052import com.sun.identity.xacml.saml2.impl.XACMLAuthzDecisionQueryImpl;
053import com.sun.identity.xacml.saml2.XACMLAuthzDecisionStatement;
054import com.sun.identity.xacml.saml2.impl.XACMLAuthzDecisionStatementImpl;
055
056/**
057 * This is the factory class to obtain instances of the objects defined
058 * in xacml context schema.
059 * There are three ways to obtain an instance of a object type:
060 * with no parameters, with a DOM tree element, or with an XML String.
061 *
062 * @supported.all.api
063 */
064public class ContextFactory {
065
066    private static ContextFactory instance = new ContextFactory();
067
068    /**
069     * Sole Constructor.
070     */
071    private ContextFactory() {
072    }
073
074    /**
075     * Returns the instance of <code>ContextSchemaFactory</code>.
076     * 
077     * @return <code>ContextSchemaFactory</code>.
078     * 
079     */
080    public static ContextFactory getInstance() {
081        return instance;
082    }
083
084    /**
085     * Returns a new instance of <code>Request</code>.
086     *
087     * @return a new instance of <code>Request</code>
088     * 
089     */
090    public Request createRequest() {
091        Object obj = XACMLSDKUtils.getObjectInstance(XACMLConstants.REQUEST);
092        if (obj == null) {
093            return new RequestImpl();
094        } else {
095            return (Request) obj;
096        }
097    }
098
099    /**
100     * Returns a new instance of <code>Request</code>.
101     * The return object is immutable.
102     *
103     * @param elem a DOM Element representation of <code>Request</code>
104     * @return a new instance of <code>Request</code>
105     * @throws XACMLException if error occurs while processing the 
106     *    DOM Element 
107     * 
108     */
109    public Request createRequest(Element elem)
110        throws XACMLException {
111        Object obj = XACMLSDKUtils.getObjectInstance(
112            XACMLConstants.REQUEST, elem);
113        if (obj == null) {
114            return new RequestImpl(elem);
115        } else {
116            return (Request) obj;
117        }
118    }
119
120    /**
121     * Returns a new instance of <code>Request</code>
122     * The return object is immutable.
123     *
124     * @param xml a XML string representation of <code>Request</code>
125     * @return a new instance of <code>Resource</code>
126     * @throws XACMLException if error occurs while processing the 
127     *    XML string
128     * 
129     */
130    public Request createRequest(String xml)
131        throws XACMLException {
132        Object obj = XACMLSDKUtils.getObjectInstance(
133            XACMLConstants.REQUEST, xml);
134        if (obj == null) {
135            return new RequestImpl(xml);
136        } else {
137            return (Request) obj;
138        }
139    }
140
141    
142    /**
143     * Returns a new instance of <code>Resource</code>.
144     *
145     * @return a new instance of <code>Resource</code>
146     * 
147     */
148    public Resource createResource() {
149        Object obj = XACMLSDKUtils.getObjectInstance(XACMLConstants.RESOURCE);
150        if (obj == null) {
151            return new ResourceImpl();
152        } else {
153            return (Resource) obj;
154        }
155    }
156
157    /**
158     * Returns a new instance of <code>Resource</code>.
159     * The return object is immutable.
160     *
161     * @param elem a DOM Element representation of <code>Resource</code>
162     * @return a new instance of <code>Resource</code>
163     * @throws XACMLException if error occurs while processing the 
164     *    DOM Element 
165     * 
166     */
167    public Resource createResource(Element elem)
168        throws XACMLException {
169        Object obj = XACMLSDKUtils.getObjectInstance(
170            XACMLConstants.RESOURCE, elem);
171        if (obj == null) {
172            return new ResourceImpl(elem);
173        } else {
174            return (Resource) obj;
175        }
176    }
177
178    /**
179     * Returns a new instance of <code>Resource</code>
180     * The return object is immutable.
181     *
182     * @param xml a XML string representation of <code>Resource</code>
183     * @return a new instance of <code>Resource</code>
184     * @throws XACMLException if error occurs while processing the 
185     *    XML string
186     * 
187     */
188    public Resource createResource(String xml)
189        throws XACMLException {
190        Object obj = XACMLSDKUtils.getObjectInstance(
191            XACMLConstants.RESOURCE, xml);
192        if (obj == null) {
193            return new ResourceImpl(xml);
194        } else {
195            return (Resource) obj;
196        }
197    }
198
199    /**
200     * Returns a new instance of <code>Subject</code>.
201     *
202     * @return a new instance of <code>Subject</code>
203     * 
204     */
205    public Subject createSubject() {
206        Object obj = XACMLSDKUtils.getObjectInstance(XACMLConstants.SUBJECT);
207        if (obj == null) {
208            return new SubjectImpl();
209        } else {
210            return (Subject) obj;
211        }
212    }
213
214    /**
215     * Returns a new instance of <code>Subject</code>.
216     * The return object is immutable.
217     *
218     * @param elem a DOM Element representation of <code>Subject</code>
219     * @return a new instance of <code>Subject</code>
220     * @throws XACMLException if error occurs while processing the 
221     *    DOM Element 
222     * 
223     */
224    public Subject createSubject(Element elem)
225        throws XACMLException {
226        Object obj = XACMLSDKUtils.getObjectInstance(
227            XACMLConstants.SUBJECT, elem);
228        if (obj == null) {
229            return new SubjectImpl(elem);
230        } else {
231            return (Subject) obj;
232        }
233    }
234
235    /**
236     * Returns a new instance of <code>Subject</code>.
237     * The return object is immutable.
238     *
239     * @param xml a XML string representation of <code>Subject</code>
240     * @return a new instance of <code>Subject</code>
241     * @throws XACMLException if error occurs while processing the 
242     *    XML string
243     * 
244     */
245    public Subject createSubject(String xml)
246        throws XACMLException {
247        Object obj = XACMLSDKUtils.getObjectInstance(
248            XACMLConstants.SUBJECT, xml);
249        if (obj == null) {
250            return new SubjectImpl(xml);
251        } else {
252            return (Subject) obj;
253        }
254    }
255    
256    /**
257     * Returns a new instance of <code>Action</code>.
258     *
259     * @return a new instance of <code>Action</code>
260     * 
261     */
262    public Action createAction() {
263        Object obj = XACMLSDKUtils.getObjectInstance(XACMLConstants.ACTION);
264        if (obj == null) {
265            return new ActionImpl();
266        } else {
267            return (Action) obj;
268        }
269    }
270
271    /**
272     * Returns a new instance of <code>Action</code>.
273     * The return object is immutable.
274     *
275     * @param elem a DOM Element representation of <code>Action</code>
276     * @return a new instance of <code>Action</code>
277     * @throws XACMLException if error occurs while processing the 
278     *    DOM Element 
279     * 
280     */
281    public Action createAction(Element elem)
282        throws XACMLException {
283        Object obj = XACMLSDKUtils.getObjectInstance(
284            XACMLConstants.ACTION, elem);
285        if (obj == null) {
286            return new ActionImpl(elem);
287        } else {
288            return (Action) obj;
289        }
290    }
291
292    /**
293     * Returns a new instance of <code>Action</code>.
294     * The return object is immutable.
295     *
296     * @param xml a XML string representation of <code>Action</code>
297     * @return a new instance of <code>Action</code>
298     * @throws XACMLException if error occurs while processing the 
299     *    XML string
300     * 
301     */
302    public Action createAction(String xml)
303        throws XACMLException {
304        Object obj = XACMLSDKUtils.getObjectInstance(
305            XACMLConstants.ACTION, xml);
306        if (obj == null) {
307            return new ActionImpl(xml);
308        } else {
309            return (Action) obj;
310        }
311    }
312    
313    /**
314     * Returns a new instance of <code>Environment</code>.
315     *
316     * @return a new instance of <code>Environment</code>
317     * 
318     */
319    public Environment createEnvironment() {
320        Object obj = XACMLSDKUtils.getObjectInstance(XACMLConstants.
321            ENVIRONMENT);
322        if (obj == null) {
323            return new EnvironmentImpl();
324        } else {
325            return (Environment) obj;
326        }
327    }
328
329    /**
330     * Returns a new instance of <code>Environment</code>.
331     * The return object is immutable.
332     *
333     * @param elem a DOM Element representation of <code>Environment</code>
334     * @return a new instance of <code>Environment</code>
335     * @throws XACMLException if error occurs while processing the 
336     *    DOM Element 
337     * 
338     */
339    public Environment createEnvironment(Element elem)
340        throws XACMLException {
341        Object obj = XACMLSDKUtils.getObjectInstance(
342            XACMLConstants.ENVIRONMENT, elem);
343        if (obj == null) {
344            return new EnvironmentImpl(elem);
345        } else {
346            return (Environment) obj;
347        }
348    }
349
350    /**
351     * Returns a new instance of <code>Environment</code>.
352     * The return object is immutable.
353     *
354     * @param xml a XML string representation of <code>Environment</code>
355     * @return a new instance of <code>Environment</code>
356     * @throws XACMLException if error occurs while processing the 
357     *    XML string
358     * 
359     */
360    public Environment createEnvironment(String xml)
361        throws XACMLException {
362        Object obj = XACMLSDKUtils.getObjectInstance(
363            XACMLConstants.ENVIRONMENT, xml);
364        if (obj == null) {
365            return new EnvironmentImpl(xml);
366        } else {
367            return (Environment) obj;
368        }
369    }
370
371
372    /**
373     * Returns a new instance of <code>Attribute</code>.
374     * Caller may need to call setters of the class to populate the object.
375     *
376     * @return a new instance of <code>Attribute</code>.
377     * 
378     */
379    public Attribute createAttribute() {
380        Object obj = XACMLSDKUtils.getObjectInstance(XACMLConstants.
381            ATTRIBUTE);
382        if (obj == null) {
383            return new AttributeImpl();
384        } else {
385            return (Attribute) obj;
386        }
387    }
388
389    /**
390     * Returns a new instance of <code>Attribute</code>. The return object
391     * is immutable.
392     *
393     * @param elem an <code>Element</code> representation of
394     *                <code>Attribute</code>.
395     * @return a new instance of <code>Attribute</code>.
396     * @throws XACMLException if error occurs while processing the
397     *                <code>Element</code>.
398     * 
399     */
400    public Attribute createAttribute(Element elem)
401                throws XACMLException
402    {
403        Object obj = XACMLSDKUtils.getObjectInstance(
404            XACMLConstants.ATTRIBUTE, elem);
405        if (obj == null) {
406            return new AttributeImpl(elem);
407        } else {
408            return (Attribute) obj;
409        }
410    }
411
412    /**
413     * Returns a new instance of <code>Attribute</code>. The return object
414     * is immutable.
415     *
416     * @param xml an XML String representing <code>Attribute</code>.
417     * @return a new instance of <code>Attribute</code>.
418     * @throws XACMLException if error occurs while processing the XML string.
419     * 
420     */
421    public Attribute createAttribute(String xml)
422                throws XACMLException
423    {
424        Object obj = XACMLSDKUtils.getObjectInstance(
425            XACMLConstants.ATTRIBUTE, xml);
426        if (obj == null) {
427            return new AttributeImpl(xml);
428        } else {
429            return (Attribute) obj;
430        }
431    }
432
433    /**
434     * Returns a new instance of <code>XACMLAuthzDecisionQuery</code>.
435     * Caller may need to call setters of the class to populate the object.
436     *
437     * @return a new instance of <code>XACMLAuthzDecisionQuery</code>.
438     * 
439     */
440    public XACMLAuthzDecisionQuery createXACMLAuthzDecisionQuery() {
441        Object obj = XACMLSDKUtils.getObjectInstance(
442                XACMLConstants.XACML_AUTHZ_DECISION_QUERY);
443        if (obj == null) {
444            return new XACMLAuthzDecisionQueryImpl();
445        } else {
446            return (XACMLAuthzDecisionQuery) obj;
447        }
448    }
449
450    /**
451     * Returns a new instance of <code>XACMLAuthzDecisionQuery</code>. 
452     * The return object is immutable.
453     *
454     * @param elem an <code>Element</code> representation of
455     *                <code>XACMLAuthzDecisionQuery</code>.
456     * @return a new instance of <code>XACMLAuthzDecisionQuery</code>.
457     * @throws XACMLException if error occurs while processing the
458     *                <code>Element</code>.
459     * @throws SAML2Exception if not able to create the base saml
460     * <code>RequestAbstract</code>
461     * 
462     */
463    public XACMLAuthzDecisionQuery createXACMLAuthzDecisionQuery(Element elem)
464                throws XACMLException, SAML2Exception
465    {
466        Object obj = XACMLSDKUtils.getObjectInstance(
467            XACMLConstants.XACML_AUTHZ_DECISION_QUERY, elem);
468        if (obj == null) {
469            return new XACMLAuthzDecisionQueryImpl(elem);
470        } else {
471            return (XACMLAuthzDecisionQuery) obj;
472        }
473    }
474
475    /**
476     * Returns a new instance of <code>XACMLAuthzDecisionQuery</code>. 
477     * The return object is immutable.
478     *
479     * @param xml an XML String representing 
480     * <code>XACMLAuthzDecisionQuery</code>.
481     * @return a new instance of <code>XACMLAuthzDecisionQuery</code>.
482     * @throws XACMLException if error occurs while processing the XML string.
483     * @throws SAML2Exception if not able to create the base saml
484     * <code>RequestAbstract</code>
485     * 
486     */
487    public XACMLAuthzDecisionQuery createXACMLAuthzDecisionQuery(String xml)
488                throws XACMLException, SAML2Exception
489    {
490        Object obj = XACMLSDKUtils.getObjectInstance(
491            XACMLConstants.XACML_AUTHZ_DECISION_QUERY, xml);
492        if (obj == null) {
493            return new XACMLAuthzDecisionQueryImpl(xml);
494        } else {
495            return (XACMLAuthzDecisionQuery) obj;
496        }
497    }
498
499    /**
500     * Returns a new instance of <code>XACMLAuthzDecisionStatement</code>.
501     * Caller may need to call setters of the class to populate the object.
502     *
503     * @return a new instance of <code>XACMLAuthzDecisionStatement</code>.
504     * 
505     */
506    public XACMLAuthzDecisionStatement createXACMLAuthzDecisionStatement() {
507        Object obj = XACMLSDKUtils.getObjectInstance(
508                XACMLConstants.XACML_AUTHZ_DECISION_STATEMENT);
509        if (obj == null) {
510            return new XACMLAuthzDecisionStatementImpl();
511        } else {
512            return (XACMLAuthzDecisionStatement) obj;
513        }
514    }
515
516    /**
517     * Returns a new instance of <code>XACMLAuthzDecisionStatement</code>. 
518     * The return object is immutable.
519     *
520     * @param elem an <code>Element</code> representation of
521     *                <code>XACMLAuthzDecisionStatement</code>.
522     * @return a new instance of <code>XACMLAuthzDecisionStatement</code>.
523     * @throws XACMLException if error occurs while processing the
524     *                <code>Element</code>.
525     * 
526     */
527    public XACMLAuthzDecisionStatement createXACMLAuthzDecisionStatement(
528            Element elem) throws XACMLException {
529        Object obj = XACMLSDKUtils.getObjectInstance(
530            XACMLConstants.XACML_AUTHZ_DECISION_STATEMENT, elem);
531        if (obj == null) {
532            return new XACMLAuthzDecisionStatementImpl(elem);
533        } else {
534            return (XACMLAuthzDecisionStatement) obj;
535        }
536    }
537
538    /**
539     * Returns a new instance of <code>XACMLAuthzDecisionStatement</code>. 
540     * The return object is immutable.
541     *
542     * @param xml an XML String representing 
543     * <code>XACMLAuthzDecisionStatement</code>.
544     * @return a new instance of <code>XACMLAuthzDecisionStatement</code>.
545     * @throws XACMLException if error occurs while processing the XML string.
546     * 
547     */
548    public XACMLAuthzDecisionStatement createXACMLAuthzDecisionStatement(String xml)
549            throws XACMLException {
550        Object obj = XACMLSDKUtils.getObjectInstance(
551            XACMLConstants.XACML_AUTHZ_DECISION_STATEMENT, xml);
552        if (obj == null) {
553            return new XACMLAuthzDecisionStatementImpl(xml);
554        } else {
555            return (XACMLAuthzDecisionStatement) obj;
556        }
557    }
558
559    /**
560     * Returns a new instance of <code>Response</code>.
561     *
562     * @return a new instance of <code>Response</code>
563     * 
564     */
565    public Response createResponse() throws XACMLException {
566        Object object = XACMLSDKUtils.getObjectInstance(
567                XACMLConstants.RESPONSE);
568        if (object == null) {
569            return new ResponseImpl();
570        } else {
571            return (Response)object;
572        }
573    }
574
575    /**
576     * Returns a new instance of <code>Response</code>.
577     * The return object is immutable.
578     *
579     * @param elem a DOM Element representation of <code>Response</code>
580     * @return a new instance of <code>Response</code>
581     * @throws XACMLException if error occurs while processing the 
582     *    DOM Element 
583     * 
584     */
585    public Response createResponse(Element elem)throws XACMLException {
586        Object object = XACMLSDKUtils.getObjectInstance(
587                XACMLConstants.RESPONSE, elem);
588        if (object == null) {
589            return new ResponseImpl(elem);
590        } else {
591            return (Response)object;
592        }
593    }
594
595    /**
596     * Returns a new instance of <code>Response</code>
597     * The return object is immutable.
598     *
599     * @param xml a XML string representation of <code>Response</code>
600     * @return a new instance of <code>Response</code>
601     * @throws XACMLException if error occurs while processing the 
602     *    XML string
603     * 
604     */
605    public Response createResponse(String xml)throws XACMLException {
606        Object object = XACMLSDKUtils.getObjectInstance(
607                XACMLConstants.RESPONSE, xml);
608        if (object == null) {
609            return new ResponseImpl(xml);
610        } else {
611            return (Response)object;
612        }
613    }
614
615    /**
616     * Returns a new instance of <code>Result</code>.
617     *
618     * @return a new instance of <code>Result</code>
619     * 
620     */
621    public Result createResult() throws XACMLException {
622        Object object = XACMLSDKUtils.getObjectInstance(
623                XACMLConstants.RESULT);
624        if (object == null) {
625            return new ResultImpl();
626        } else {
627            return (Result)object;
628        }
629    }
630
631    /**
632     * Returns a new instance of <code>Result</code>.
633     * The return object is immutable.
634     *
635     * @param elem a DOM Element representation of <code>Result</code>
636     * @return a new instance of <code>Result</code>
637     * @throws XACMLException if error occurs while processing the 
638     *    DOM Element 
639     * 
640     */
641    public Result createResult(Element elem)throws XACMLException {
642        Object object = XACMLSDKUtils.getObjectInstance(
643                XACMLConstants.RESULT, elem);
644        if (object == null) {
645            return new ResultImpl(elem);
646        } else {
647            return (Result)object;
648        }
649    }
650
651    /**
652     * Returns a new instance of <code>Result</code>
653     * The return object is immutable.
654     *
655     * @param xml a XML string representation of <code>Result</code>
656     * @return a new instance of <code>Result</code>
657     * @throws XACMLException if error occurs while processing the 
658     *    XML string
659     * 
660     */
661    public Result createResult(String xml)throws XACMLException {
662        Object object = XACMLSDKUtils.getObjectInstance(
663                XACMLConstants.RESULT, xml);
664        if (object == null) {
665            return new ResultImpl(xml);
666        } else {
667            return (Result)object;
668        }
669    }
670
671    /**
672     * Returns a new instance of <code>Decision</code>.
673     *
674     * @return a new instance of <code>Decision</code>
675     * 
676     */
677    public Decision createDecision() throws XACMLException {
678        Object object = XACMLSDKUtils.getObjectInstance(
679                XACMLConstants.DECISION);
680        if (object == null) {
681            return new DecisionImpl();
682        } else {
683            return (Decision)object;
684        }
685    }
686
687    /**
688     * Returns a new instance of <code>Decision</code>.
689     * The return object is immutable.
690     *
691     * @param elem a DOM Element representation of <code>Decision</code>
692     * @return a new instance of <code>Decision</code>
693     * @throws XACMLException if error occurs while processing the 
694     *    DOM Element 
695     * 
696     */
697    public Decision createDecision(Element elem)throws XACMLException {
698        Object object = XACMLSDKUtils.getObjectInstance(
699                XACMLConstants.DECISION, elem);
700        if (object == null) {
701            return new DecisionImpl(elem);
702        } else {
703            return (Decision)object;
704        }
705    }
706
707    /**
708     * Returns a new instance of <code>Decision</code>
709     * The return object is immutable.
710     *
711     * @param xml a XML string representation of <code>Decision</code>
712     * @return a new instance of <code>Decision</code>
713     * @throws XACMLException if error occurs while processing the 
714     *    XML string
715     * 
716     */
717    public Decision createDecision(String xml)throws XACMLException {
718        Object object = XACMLSDKUtils.getObjectInstance(
719                XACMLConstants.DECISION, xml);
720        if (object == null) {
721            return new DecisionImpl(xml);
722        } else {
723            return (Decision)object;
724        }
725    }
726
727    /**
728     * Returns a new instance of <code>Status</code>.
729     *
730     * @return a new instance of <code>Status</code>
731     * 
732     */
733    public Status createStatus() throws XACMLException {
734        Object object = XACMLSDKUtils.getObjectInstance(
735                XACMLConstants.STATUS);
736        if (object == null) {
737            return new StatusImpl();
738        } else {
739            return (Status)object;
740        }
741    }
742
743    /**
744     * Returns a new instance of <code>Status</code>.
745     * The return object is immutable.
746     *
747     * @param elem a DOM Element representation of <code>Status</code>
748     * @return a new instance of <code>Status</code>
749     * @throws XACMLException if error occurs while processing the 
750     *    DOM Element 
751     * 
752     */
753    public Status createStatus(Element elem)throws XACMLException {
754        Object object = XACMLSDKUtils.getObjectInstance(
755                XACMLConstants.STATUS, elem);
756        if (object == null) {
757            return new StatusImpl(elem);
758        } else {
759            return (Status)object;
760        }
761    }
762
763    /**
764     * Returns a new instance of <code>Status</code>
765     * The return object is immutable.
766     *
767     * @param xml a XML string representation of <code>Status</code>
768     * @return a new instance of <code>Status</code>
769     * @throws XACMLException if error occurs while processing the 
770     *    XML string
771     * 
772     */
773    public Status createStatus(String xml)throws XACMLException {
774        Object object = XACMLSDKUtils.getObjectInstance(
775                XACMLConstants.STATUS, xml);
776        if (object == null) {
777            return new StatusImpl(xml);
778        } else {
779            return (Status)object;
780        }
781    }
782
783    /**
784     * Returns a new instance of <code>StatusCode</code>.
785     *
786     * @return a new instance of <code>StatusCode</code>
787     * 
788     */
789    public StatusCode createStatusCode() throws XACMLException {
790        Object object = XACMLSDKUtils.getObjectInstance(
791                XACMLConstants.STATUS_CODE);
792        if (object == null) {
793            return new StatusCodeImpl();
794        } else {
795            return (StatusCode)object;
796        }
797    }
798
799    /**
800     * Returns a new instance of <code>StatusCode</code>.
801     * The return object is immutable.
802     *
803     * @param elem a DOM Element representation of <code>StatusCode</code>
804     * @return a new instance of <code>StatusCode</code>
805     * @throws XACMLException if error occurs while processing the 
806     *    DOM Element 
807     * 
808     */
809    public StatusCode createStatusCode(Element elem)throws XACMLException {
810        Object object = XACMLSDKUtils.getObjectInstance(
811                XACMLConstants.STATUS_CODE, elem);
812        if (object == null) {
813            return new StatusCodeImpl(elem);
814        } else {
815            return (StatusCode)object;
816        }
817    }
818
819    /**
820     * Returns a new instance of <code>StatusCode</code>
821     * The return object is immutable.
822     *
823     * @param xml a XML string representation of <code>StatusCode</code>
824     * @return a new instance of <code>StatusCode</code>
825     * @throws XACMLException if error occurs while processing the 
826     *    XML string
827     * 
828     */
829    public StatusCode createStatusCode(String xml)throws XACMLException {
830        Object object = XACMLSDKUtils.getObjectInstance(
831                XACMLConstants.STATUS_CODE, xml);
832        if (object == null) {
833            return new StatusCodeImpl(xml);
834        } else {
835            return (StatusCode)object;
836        }
837    }
838
839    /**
840     * Returns a new instance of <code>StatusMessage</code>.
841     *
842     * @return a new instance of <code>StatusMessage</code>
843     * 
844     */
845    public StatusMessage createStatusMessage() throws XACMLException {
846        Object object = XACMLSDKUtils.getObjectInstance(
847                XACMLConstants.STATUS_MESSAGE);
848        if (object == null) {
849            return new StatusMessageImpl();
850        } else {
851            return (StatusMessage)object;
852        }
853    }
854
855    /**
856     * Returns a new instance of <code>StatusMessage</code>.
857     * The return object is immutable.
858     *
859     * @param elem a DOM Element representation of <code>StatusMessage</code>
860     * @return a new instance of <code>StatusMessage</code>
861     * @throws XACMLException if error occurs while processing the 
862     *    DOM Element 
863     * 
864     */
865    public StatusMessage createStatusMessage(Element elem)
866            throws XACMLException {
867        Object object = XACMLSDKUtils.getObjectInstance(
868                XACMLConstants.STATUS_MESSAGE, elem);
869        if (object == null) {
870            return new StatusMessageImpl(elem);
871        } else {
872            return (StatusMessage)object;
873        }
874    }
875
876    /**
877     * Returns a new instance of <code>StatusMessage</code>
878     * The return object is immutable.
879     *
880     * @param xml a XML string representation of <code>StatusMessage</code>
881     * @return a new instance of <code>StatusMessage</code>
882     * @throws XACMLException if error occurs while processing the 
883     *    XML string
884     * 
885     */
886    public StatusMessage createStatusMessage(String xml)throws XACMLException {
887        Object object = XACMLSDKUtils.getObjectInstance(
888                XACMLConstants.STATUS_MESSAGE, xml);
889        if (object == null) {
890            return new StatusMessageImpl(xml);
891        } else {
892            return (StatusMessage)object;
893        }
894    }
895
896    /**
897     * Returns a new instance of <code>StatusDetail</code>.
898     *
899     * @return a new instance of <code>StatusDetail</code>
900     * 
901     */
902    public StatusDetail createStatusDetail() throws XACMLException {
903        Object object = XACMLSDKUtils.getObjectInstance(
904                XACMLConstants.STATUS_DETAIL);
905        if (object == null) {
906            return new StatusDetailImpl();
907        } else {
908            return (StatusDetail)object;
909        }
910    }
911    /**
912     * Returns a new instance of <code>StatusDetail</code>.
913     * The return object is immutable.
914     *
915     * @param elem a DOM Element representation of <code>StatusDetail</code>
916     * @return a new instance of <code>StatusDetail</code>
917     * @throws XACMLException if error occurs while processing the 
918     *    DOM Element 
919     * 
920     */
921    public StatusDetail createStatusDetail(Element elem)throws XACMLException {
922        Object object = XACMLSDKUtils.getObjectInstance(
923                XACMLConstants.STATUS_DETAIL, elem);
924        if (object == null) {
925            return new StatusDetailImpl(elem);
926        } else {
927            return (StatusDetail)object;
928        }
929    }
930
931    /**
932     * Returns a new instance of <code>StatusDetail</code>
933     * The return object is immutable.
934     *
935     * @param xml a XML string representation of <code>StatusDetail</code>
936     * @return a new instance of <code>StatusDetail</code>
937     * @throws XACMLException if error occurs while processing the 
938     *    XML string
939     * 
940     */
941    public StatusDetail createStatusDetail(String xml)throws XACMLException {
942        Object object = XACMLSDKUtils.getObjectInstance(
943                XACMLConstants.STATUS_DETAIL, xml);
944        if (object == null) {
945            return new StatusDetailImpl(xml);
946        } else {
947            return (StatusDetail)object;
948        }
949    }
950
951}




























































Copyright © 2010-2017, ForgeRock All Rights Reserved.