| /* |
| * This file is part of the QuickServer library |
| * Copyright (C) QuickServer.org |
| * |
| * Use, modification, copying and distribution of this software is subject to |
| * the terms and conditions of the GNU Lesser General Public License. |
| * You should have received a copy of the GNU LGP License along with this |
| * library; if not, you can download a copy from <http://www.quickserver.org/>. |
| * |
| * For questions, suggestions, bug-reports, enhancement-requests etc. |
| * visit http://www.quickserver.org |
| * |
| */ |
| |
| package org.quickserver.util.xmlreader; |
| |
| /** |
| * This class encapsulate Trust Store. |
| * The example xml is <pre> |
| .... |
| <trust-store-info> |
| <store-file>NONE</store-file> |
| <store-password></store-password> |
| </trust-store-info> |
| .... |
| </pre> |
| * @see KeyStoreInfo |
| * @see SecureStore |
| * @see Secure |
| * @author Akshathkumar Shetty |
| * @since 1.4 |
| */ |
| public class TrustStoreInfo implements java.io.Serializable { |
| private String storeFile = "NONE"; |
| private String storePassword = null; |
| private String type = null; |
| private String provider = null; |
| |
| /** |
| * Sets the store file path. This can be either absolute or |
| * relative(to config file) path to the store file. |
| * XML Tag: <store-file>NONE</store-file> |
| * @param storeFile store file. |
| * @see #getStoreFile |
| */ |
| public void setStoreFile(String storeFile) { |
| if(storeFile!=null && storeFile.trim().length()!=0) |
| this.storeFile = storeFile; |
| } |
| /** |
| * Returns the store file path. This can be either absolute or |
| * relative(to config file) path to the store file. |
| * @see #setStoreFile |
| */ |
| public String getStoreFile() { |
| return storeFile; |
| } |
| |
| /** |
| * Sets the store password. |
| * XML Tag: <store-password></store-password> |
| * @param storePassword store password |
| * @see #getStorePassword |
| */ |
| public void setStorePassword(String storePassword) { |
| if(storePassword!=null) |
| this.storePassword = storePassword; |
| } |
| /** |
| * Returns store password. |
| * @see #setStorePassword |
| */ |
| public String getStorePassword() { |
| return storePassword; |
| } |
| |
| /** |
| * Sets the type of trust store. |
| * If not set, it will use value from SecureStore<br/> |
| * XML Tag: <type>JKS</type> |
| * @param type of keystore. |
| * @see #getType |
| */ |
| public void setType(String type) { |
| if(type!=null && type.trim().length()!=0) |
| this.type = type; |
| } |
| /** |
| * Returns the type of truststore. |
| * @see #setType |
| */ |
| public String getType() { |
| return type; |
| } |
| |
| /** |
| * Sets the provider of trust store. If not set, it will use value from SecureStore<br/> |
| * XML Tag: <provider>SUN</provider> |
| * @param provider of keystore. |
| * @see #getProvider |
| */ |
| public void setProvider(String provider) { |
| if(provider!=null && provider.trim().length()!=0) |
| this.provider = provider; |
| } |
| /** |
| * Returns the provider of keystore. |
| * @see #setProvider |
| */ |
| public String getProvider() { |
| return provider; |
| } |
| |
| /** |
| * Returns XML config of this class. |
| */ |
| public String toXML(String pad) { |
| if(pad==null) pad=""; |
| StringBuilder sb = new StringBuilder(); |
| sb.append(pad).append("<trust-store-info>\n"); |
| sb.append(pad).append("\t<store-file>").append(getStoreFile()).append("</store-file>\n"); |
| if(getStorePassword()!=null) |
| sb.append(pad).append("\t<store-password>").append(getStorePassword()).append("</store-password>\n"); |
| else |
| sb.append(pad).append("\t</store-password>\n"); |
| if(getType()!=null) |
| sb.append(pad).append("\t<type>").append(getType()).append("</type>\n"); |
| if(getProvider()!=null) |
| sb.append(pad).append("\t<provider>").append(getProvider()).append("</provider>\n"); |
| sb.append(pad).append("</trust-store-info>\n"); |
| return sb.toString(); |
| } |
| } |