View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements. See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache license, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the license for the specific language governing permissions and
15   * limitations under the license.
16   */
17  package org.apache.logging.log4j.core.net.ssl;
18  
19  import org.apache.logging.log4j.status.StatusLogger;
20  
21  /**
22   *
23   */
24  public class StoreConfiguration<T> {
25      protected static final StatusLogger LOGGER = StatusLogger.getLogger();
26  
27      private String location;
28      private String password;
29  
30      public StoreConfiguration(final String location, final String password) {
31          this.location = location;
32          this.password = password;
33      }
34  
35      public String getLocation() {
36          return this.location;
37      }
38  
39      public void setLocation(final String location) {
40          this.location = location;
41      }
42  
43      public String getPassword() {
44          return this.password;
45      }
46  
47      public char[] getPasswordAsCharArray() {
48          return this.password == null ? null : this.password.toCharArray();
49      }
50  
51      public void setPassword(final String password) {
52          this.password = password;
53      }
54  
55      /**
56       * @throws StoreConfigurationException May be thrown by subclasses 
57       */
58      protected T load() throws StoreConfigurationException {
59          return null;
60      }
61  
62      @Override
63      public int hashCode() {
64          final int prime = 31;
65          int result = 1;
66          result = prime * result + ((this.location == null) ? 0 : this.location.hashCode());
67          result = prime * result + ((this.password == null) ? 0 : this.password.hashCode());
68          return result;
69      }
70  
71      @Override
72      public boolean equals(final Object obj) {
73          if (this == obj) {
74              return true;
75          }
76          if (obj == null) {
77              return false;
78          }
79          if (!(obj instanceof StoreConfiguration)) {
80              return false;
81          }
82          final StoreConfiguration<?> other = (StoreConfiguration<?>) obj;
83          if (this.location == null) {
84              if (other.location != null) {
85                  return false;
86              }
87          } else if (!this.location.equals(other.location)) {
88              return false;
89          }
90          if (this.password == null) {
91              if (other.password != null) {
92                  return false;
93              }
94          } else if (!this.password.equals(other.password)) {
95              return false;
96          }
97          return true;
98      }    
99  }