KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > request > DiscardAuthToken


1 /*
2  * The source code contained herein is licensed under the IBM Public License
3  * Version 1.0, which has been approved by the Open Source Initiative.
4  * Copyright (C) 2001, International Business Machines Corporation
5  * All Rights Reserved.
6  *
7  */

8
9 package org.uddi4j.request;
10
11 import org.uddi4j.UDDIElement;
12 import org.uddi4j.UDDIException;
13 import org.uddi4j.util.AuthInfo;
14 import org.w3c.dom.Element JavaDoc;
15 import org.w3c.dom.NodeList JavaDoc;
16
17 /**
18  * Represents the discard_authToken element within the UDDI version 2.0 schema.
19  * This class contains the following types of methods:
20  *
21  * <ul>
22  * <li>A constructor that passes the required fields.
23  * <li>A Constructor that will instantiate the object from an appropriate XML
24  * DOM element.
25  * <li>Get/set methods for each attribute that this element can contain.
26  * <li>A get/setVector method is provided for sets of attributes.
27  * <li>A SaveToXML method that serializes this class within a passed in
28  * element.
29  * </ul>
30  *
31  * Typically, this class is used to construct parameters for, or interpret
32  * responses from, methods in the UDDIProxy class.
33  *
34  * <p><b>Element description:</b>
35  * <p>This optional message is used to deactivate an authentication token
36  * that was obtained by a call to get_authToken.
37  *
38  * @author David Melgar (dmelgar@us.ibm.com)
39  */

40 public class DiscardAuthToken extends UDDIElement {
41    public static final String JavaDoc UDDI_TAG = "discard_authToken";
42
43    protected Element base = null;
44
45    AuthInfo authInfo = null;
46
47    /**
48     * Default constructor.
49     * Avoid using the default constructor for validation. It does not validate
50     * required fields. Instead, use the required fields constructor to perform
51     * validation.
52     */

53    public DiscardAuthToken() {
54    }
55
56    /**
57     * Construct the object with required fields.
58     *
59     * @param authInfo String
60     */

61    public DiscardAuthToken(String JavaDoc authInfo) {
62       this.authInfo = new AuthInfo( authInfo );
63    }
64
65    /**
66     * Construct the object from a DOM tree. Used by
67     * UDDIProxy to construct an object from a received UDDI
68     * message.
69     *
70     * @param base Element with the name appropriate for this class.
71     *
72     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
73     * or a disposition report indicating a UDDI error.
74     */

75    public DiscardAuthToken(Element base) throws UDDIException {
76       // Check if it is a fault. Throws an exception if it is.
77
super(base);
78       NodeList JavaDoc nl = null;
79       nl = getChildElementsByTagName(base, AuthInfo.UDDI_TAG);
80       if (nl.getLength() > 0) {
81          authInfo = new AuthInfo((Element)nl.item(0));
82       }
83    }
84
85    public void setAuthInfo(AuthInfo s) {
86       authInfo = s;
87    }
88    public void setAuthInfo(String JavaDoc s) {
89       authInfo = new AuthInfo();
90       authInfo.setText(s);
91    }
92
93    public AuthInfo getAuthInfo() {
94       return authInfo;
95    }
96
97    public String JavaDoc getAuthInfoString() {
98       return authInfo.getText();
99    }
100
101    /**
102     * Save an object to the DOM tree. Used to serialize an object
103     * to a DOM tree, usually to send a UDDI message.
104     *
105     * <BR>Used by UDDIProxy.
106     *
107     * @param parent Object will serialize as a child element under the
108     * passed in parent element.
109     */

110    public void saveToXML(Element parent) {
111       base = parent.getOwnerDocument().createElement(UDDI_TAG);
112       // Save attributes.
113
base.setAttribute("generic", UDDIElement.GENERIC);
114       base.setAttribute("xmlns", UDDIElement.XMLNS);
115       if (authInfo!=null) {
116          authInfo.saveToXML(base);
117       }
118       parent.appendChild(base);
119    }
120 }
121
Popular Tags