001: /*
002: * This file is part of the QuickServer library
003: * Copyright (C) 2003-2005 QuickServer.org
004: *
005: * Use, modification, copying and distribution of this software is subject to
006: * the terms and conditions of the GNU Lesser General Public License.
007: * You should have received a copy of the GNU LGP License along with this
008: * library; if not, you can download a copy from <http://www.quickserver.org/>.
009: *
010: * For questions, suggestions, bug-reports, enhancement-requests etc.
011: * visit http://www.quickserver.org
012: *
013: */
014:
015: package org.quickserver.util.xmlreader;
016:
017: /**
018: * This class encapsulate Trust Store.
019: * The example xml is <pre>
020: ....
021: <trust-store-info>
022: <store-file>NONE</store-file>
023: <store-password></store-password>
024: </trust-store-info>
025: ....
026: </pre>
027: * @see KeyStoreInfo
028: * @see SecureStore
029: * @see Secure
030: * @author Akshathkumar Shetty
031: * @since 1.4
032: */
033: public class TrustStoreInfo implements java.io.Serializable {
034: private String storeFile = "NONE";
035: private String storePassword = null;
036: private String type = null;
037: private String provider = null;
038:
039: /**
040: * Sets the store file path. This can be either absolute or
041: * relative(to config file) path to the store file.
042: * XML Tag: <store-file>NONE</store-file>
043: * @param storeFile store file.
044: * @see #getStoreFile
045: */
046: public void setStoreFile(String storeFile) {
047: if (storeFile != null && storeFile.trim().length() != 0)
048: this .storeFile = storeFile;
049: }
050:
051: /**
052: * Returns the store file path. This can be either absolute or
053: * relative(to config file) path to the store file.
054: * @see #setStoreFile
055: */
056: public String getStoreFile() {
057: return storeFile;
058: }
059:
060: /**
061: * Sets the store password.
062: * XML Tag: <store-password></store-password>
063: * @param storePassword store password
064: * @see #getStorePassword
065: */
066: public void setStorePassword(String storePassword) {
067: if (storePassword != null)
068: this .storePassword = storePassword;
069: }
070:
071: /**
072: * Returns store password.
073: * @see #setStorePassword
074: */
075: public String getStorePassword() {
076: return storePassword;
077: }
078:
079: /**
080: * Sets the type of trust store.
081: * If not set, it will use value from SecureStore<br/>
082: * XML Tag: <type>JKS</type>
083: * @param type of keystore.
084: * @see #getType
085: */
086: public void setType(String type) {
087: if (type != null && type.trim().length() != 0)
088: this .type = type;
089: }
090:
091: /**
092: * Returns the type of truststore.
093: * @see #setType
094: */
095: public String getType() {
096: return type;
097: }
098:
099: /**
100: * Sets the provider of trust store. If not set, it will use value from SecureStore<br/>
101: * XML Tag: <provider>SUN</provider>
102: * @param provider of keystore.
103: * @see #getProvider
104: */
105: public void setProvider(String provider) {
106: if (provider != null && provider.trim().length() != 0)
107: this .provider = provider;
108: }
109:
110: /**
111: * Returns the provider of keystore.
112: * @see #setProvider
113: */
114: public String getProvider() {
115: return provider;
116: }
117:
118: /**
119: * Returns XML config of this class.
120: */
121: public String toXML(String pad) {
122: if (pad == null)
123: pad = "";
124: StringBuffer sb = new StringBuffer();
125: sb.append(pad + "<trust-store-info>\n");
126: sb.append(pad + "\t<store-file>").append(getStoreFile())
127: .append("</store-file>\n");
128: if (getStorePassword() != null)
129: sb.append(pad).append("\t<store-password>").append(
130: getStorePassword()).append("</store-password>\n");
131: else
132: sb.append(pad).append("\t</store-password>\n");
133: if (getType() != null)
134: sb.append(pad).append("\t<type>").append(getType()).append(
135: "</type>\n");
136: if (getProvider() != null)
137: sb.append(pad).append("\t<provider>").append(getProvider())
138: .append("</provider>\n");
139: sb.append(pad + "</trust-store-info>\n");
140: return sb.toString();
141: }
142: }
|