KickJava   Java API By Example, From Geeks To Geeks.

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


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.w3c.dom.Element JavaDoc;
14
15 /**
16  * Represents the get_authToken element within the UDDI version 2.0 schema.
17  * This class contains the following types of methods:
18  *
19  * <ul>
20  * <li>A constructor that passes the required fields.
21  * <li>A Constructor that will instantiate the object from an appropriate XML
22  * DOM element.
23  * <li>Get/set methods for each attribute that this element can contain.
24  * <li>A get/setVector method is provided for sets of attributes.
25  * <li>A SaveToXML method that serializes this class within a passed in
26  * element.
27  * </ul>
28  *
29  * Typically, this class is used to construct parameters for, or interpret
30  * responses from, methods in the UDDIProxy class.
31  *
32  * <p><b>Element description:</b>
33  * <p>This optional message is used to request an authentication token. The
34  * response is an authToken message.
35  *
36  * @author David Melgar (dmelgar@us.ibm.com)
37  */

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

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

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

77    public GetAuthToken(Element base) throws UDDIException {
78       // Check if it is a fault. Throws an exception if it is.
79
super(base);
80       userID = base.getAttribute("userID");
81       cred = base.getAttribute("cred");
82    }
83
84    public void setUserID(String JavaDoc s) {
85       userID = s;
86    }
87
88    public void setCred(String JavaDoc s) {
89       cred = s;
90    }
91
92    public String JavaDoc getUserID() {
93       return userID;
94    }
95
96
97    public String JavaDoc getCred() {
98       return cred;
99    }
100
101
102    /**
103     * Save an object to the DOM tree. Used to serialize an object
104     * to a DOM tree, usually to send a UDDI message.
105     *
106     * <BR>Used by UDDIProxy.
107     *
108     * @param parent Object will serialize as a child element under the
109     * passed in parent element.
110     */

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