KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quickserver > util > xmlreader > TrustStoreInfo


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
10  * For questions, suggestions, bug-reports, enhancement-requests etc.
11  * visit http://www.quickserver.org
12  *
13  */

14
15 package org.quickserver.util.xmlreader;
16
17 /**
18  * This class encapsulate Trust Store.
19  * The example xml is <pre>
20     ....
21     &lt;trust-store-info&gt;
22         &lt;store-file&gt;NONE&lt;/store-file&gt;
23         &lt;store-password&gt;&lt;/store-password&gt;
24     &lt;/trust-store-info&gt;
25     ....
26  </pre>
27  * @see KeyStoreInfo
28  * @see SecureStore
29  * @see Secure
30  * @author Akshathkumar Shetty
31  * @since 1.4
32  */

33 public class TrustStoreInfo implements java.io.Serializable JavaDoc {
34     private String JavaDoc storeFile = "NONE";
35     private String JavaDoc storePassword = null;
36     private String JavaDoc type = null;
37     private String JavaDoc provider = null;
38
39     /**
40      * Sets the store file path. This can be either absolute or
41      * relative(to config file) path to the store file.
42      * XML Tag: &lt;store-file&gt;NONE&lt;/store-file&gt;
43      * @param storeFile store file.
44      * @see #getStoreFile
45      */

46     public void setStoreFile(String JavaDoc storeFile) {
47         if(storeFile!=null && storeFile.trim().length()!=0)
48             this.storeFile = storeFile;
49     }
50     /**
51      * Returns the store file path. This can be either absolute or
52      * relative(to config file) path to the store file.
53      * @see #setStoreFile
54      */

55     public String JavaDoc getStoreFile() {
56         return storeFile;
57     }
58
59     /**
60      * Sets the store password.
61      * XML Tag: &lt;store-password&gt;&lt;/store-password&gt;
62      * @param storePassword store password
63      * @see #getStorePassword
64      */

65     public void setStorePassword(String JavaDoc storePassword) {
66         if(storePassword!=null)
67             this.storePassword = storePassword;
68     }
69     /**
70      * Returns store password.
71      * @see #setStorePassword
72      */

73     public String JavaDoc getStorePassword() {
74         return storePassword;
75     }
76
77     /**
78      * Sets the type of trust store.
79      * If not set, it will use value from SecureStore<br/>
80      * XML Tag: &lt;type&gt;JKS&lt;/type&gt;
81      * @param type of keystore.
82      * @see #getType
83      */

84     public void setType(String JavaDoc type) {
85         if(type!=null && type.trim().length()!=0)
86             this.type = type;
87     }
88     /**
89      * Returns the type of truststore.
90      * @see #setType
91      */

92     public String JavaDoc getType() {
93         return type;
94     }
95
96     /**
97      * Sets the provider of trust store. If not set, it will use value from SecureStore<br/>
98      * XML Tag: &lt;provider&gt;SUN&lt;/provider&gt;
99      * @param provider of keystore.
100      * @see #getProvider
101      */

102     public void setProvider(String JavaDoc provider) {
103         if(provider!=null && provider.trim().length()!=0)
104             this.provider = provider;
105     }
106     /**
107      * Returns the provider of keystore.
108      * @see #setProvider
109      */

110     public String JavaDoc getProvider() {
111         return provider;
112     }
113
114     /**
115      * Returns XML config of this class.
116      */

117     public String JavaDoc toXML(String JavaDoc pad) {
118         if(pad==null) pad="";
119         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
120         sb.append(pad+"<trust-store-info>\n");
121         sb.append(pad+"\t<store-file>").append(getStoreFile()).append("</store-file>\n");
122         if(getStorePassword()!=null)
123             sb.append(pad).append("\t<store-password>").append(getStorePassword()).append("</store-password>\n");
124         else
125             sb.append(pad).append("\t</store-password>\n");
126         if(getType()!=null)
127             sb.append(pad).append("\t<type>").append(getType()).append("</type>\n");
128         if(getProvider()!=null)
129             sb.append(pad).append("\t<provider>").append(getProvider()).append("</provider>\n");
130         sb.append(pad+"</trust-store-info>\n");
131         return sb.toString();
132     }
133 }
134
Popular Tags