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: ECPFactory.java,v 1.2 2008/06/25 05:47:46 qcheng Exp $
026 *
027 */
028
029
030package com.sun.identity.saml2.ecp;
031
032import org.w3c.dom.Element;
033
034import com.sun.identity.saml2.common.SAML2Exception;
035import com.sun.identity.saml2.common.SAML2SDKUtils;
036import com.sun.identity.saml2.ecp.impl.ECPRelayStateImpl;
037import com.sun.identity.saml2.ecp.impl.ECPRequestImpl;
038import com.sun.identity.saml2.ecp.impl.ECPResponseImpl;
039
040/**
041 * This is the factory class to obtain object instances for concrete elements in
042 * the ecp schema. This factory class provides 3 methods for each element.
043 * <code>createElementName()</code>,
044 * <code>createElementName(String value)</code>,
045 * <code>createElementName(org.w3c.dom.Element value)</code>.
046 *
047 * @supported.all.api
048 */
049public class ECPFactory  {
050    
051    private static ECPFactory ecpInstance = new ECPFactory();
052    
053    /* Constructor for ECPFactory */
054    private ECPFactory() {
055    }
056    
057    /**
058     * Returns an instance of the <code>ECPFactory</code> Object.
059     *
060     * @return an instance of the <code>ECPFactory</code> object.
061     */
062    public static ECPFactory getInstance() {
063        return ecpInstance;
064    }
065    
066    /**
067     * Returns the <code>ECPRelayState</code> Object.
068     *
069     * @return the <code>ECPRelayState</code> object.
070     * @throws SAML2Exception if <code>ECPRelayState</code> cannot be created.
071     */
072    public ECPRelayState createECPRelayState() throws SAML2Exception {
073        Object obj = SAML2SDKUtils.getObjectInstance(
074            SAML2SDKUtils.ECP_RELAY_STATE);
075        if (obj == null) {
076            return new ECPRelayStateImpl();
077        } else {
078            return (ECPRelayState) obj;
079        }
080    }
081
082    /**
083     * Returns the <code>ECPRelayState</code> Object.
084     *
085     * @param value the Document Element of ECP <code>RelayState</code> object.
086     * @return the <code>ECPRelayState</code> object.
087     * @throws SAML2Exception if <code>ECPRelayState</code> cannot be created.
088     */
089    
090    public ECPRelayState createECPRelayState(Element value)
091        throws SAML2Exception {
092
093        Object obj = SAML2SDKUtils.getObjectInstance(
094            SAML2SDKUtils.ECP_RELAY_STATE, value);
095        if (obj == null) {
096            return new ECPRelayStateImpl(value);
097        } else {
098            return (ECPRelayState) obj;
099        }
100    }
101    
102    /**
103     * Returns the <code>ECPRelayState</code> Object.
104     *
105     * @param value ECP <code>RelayState</code> XML String.
106     * @return the <code>ECPRelayState</code> object.
107     * @throws SAML2Exception if <code>ECPRelayState</code> cannot be created.
108     */
109    public ECPRelayState createECPRelayState(String value)
110        throws SAML2Exception {
111        Object obj = SAML2SDKUtils.getObjectInstance(
112            SAML2SDKUtils.ECP_RELAY_STATE, value);
113        if (obj == null) {
114            return new ECPRelayStateImpl(value);
115        } else {
116            return (ECPRelayState) obj;
117        }
118    }
119
120    /**
121     * Returns the <code>ECPRequest</code> Object.
122     *
123     * @return the <code>ECPRequest</code> object.
124     * @throws SAML2Exception if <code>ECPRequest</code> cannot be created.
125     */
126    public ECPRequest createECPRequest() throws SAML2Exception {
127        Object obj = SAML2SDKUtils.getObjectInstance(
128            SAML2SDKUtils.ECP_REQUEST);
129        if (obj == null) {
130            return new ECPRequestImpl();
131        } else {
132            return (ECPRequest) obj;
133        }
134    }
135
136    /**
137     * Returns the <code>ECPRequest</code> Object.
138     *
139     * @param value the Document Element of ECP <code>Request</code> object.
140     * @return the <code>ECPRequest</code> object.
141     * @throws SAML2Exception if <code>ECPRequest</code> cannot be created.
142     */
143    
144    public ECPRequest createECPRequest(Element value)
145        throws SAML2Exception {
146
147        Object obj = SAML2SDKUtils.getObjectInstance(
148            SAML2SDKUtils.ECP_REQUEST, value);
149        if (obj == null) {
150            return new ECPRequestImpl(value);
151        } else {
152            return (ECPRequest) obj;
153        }
154    }
155    
156    /**
157     * Returns the <code>ECPRequest</code> Object.
158     *
159     * @param value ECP <code>Request</code> XML String.
160     * @return the <code>ECPRequest</code> object.
161     * @throws SAML2Exception if <code>ECPRequest</code> cannot be created.
162     */
163    public ECPRequest createECPRequest(String value)
164        throws SAML2Exception {
165        Object obj = SAML2SDKUtils.getObjectInstance(
166            SAML2SDKUtils.ECP_REQUEST, value);
167        if (obj == null) {
168            return new ECPRequestImpl(value);
169        } else {
170            return (ECPRequest) obj;
171        }
172    }
173
174    /**
175     * Returns the <code>ECPResponse</code> Object.
176     *
177     * @return the <code>ECPResponse</code> object.
178     * @throws SAML2Exception if <code>ECPResponse</code> cannot be created.
179     */
180    public ECPResponse createECPResponse() throws SAML2Exception {
181        Object obj = SAML2SDKUtils.getObjectInstance(
182            SAML2SDKUtils.ECP_RESPONSE);
183        if (obj == null) {
184            return new ECPResponseImpl();
185        } else {
186            return (ECPResponse) obj;
187        }
188    }
189
190    /**
191     * Returns the <code>ECPResponse</code> Object.
192     *
193     * @param value the Document Element of ECP <code>Response</code> object.
194     * @return the <code>ECPResponse</code> object.
195     * @throws SAML2Exception if <code>ECPResponse</code> cannot be created.
196     */
197    
198    public ECPResponse createECPResponse(Element value)
199        throws SAML2Exception {
200
201        Object obj = SAML2SDKUtils.getObjectInstance(
202            SAML2SDKUtils.ECP_RESPONSE, value);
203        if (obj == null) {
204            return new ECPResponseImpl(value);
205        } else {
206            return (ECPResponse) obj;
207        }
208    }
209    
210    /**
211     * Returns the <code>ECPResponse</code> Object.
212     *
213     * @param value ECP <code>Response</code> XML String.
214     * @return the <code>ECPResponse</code> object.
215     * @throws SAML2Exception if <code>ECPResponse</code> cannot be created.
216     */
217    public ECPResponse createECPResponse(String value)
218        throws SAML2Exception {
219        Object obj = SAML2SDKUtils.getObjectInstance(
220            SAML2SDKUtils.ECP_RESPONSE, value);
221        if (obj == null) {
222            return new ECPResponseImpl(value);
223        } else {
224            return (ECPResponse) obj;
225        }
226    }
227
228}
229




























































Copyright © 2010-2017, ForgeRock All Rights Reserved.