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      protected T load() throws StoreConfigurationException {
56          return null;
57      }
58  
59      @Override
60      public int hashCode() {
61          final int prime = 31;
62          int result = 1;
63          result = prime * result + ((this.location == null) ? 0 : this.location.hashCode());
64          result = prime * result + ((this.password == null) ? 0 : this.password.hashCode());
65          return result;
66      }
67  
68      @Override
69      public boolean equals(final Object obj) {
70          if (this == obj) {
71              return true;
72          }
73          if (obj == null) {
74              return false;
75          }
76          if (!(obj instanceof StoreConfiguration)) {
77              return false;
78          }
79          final StoreConfiguration<?> other = (StoreConfiguration<?>) obj;
80          if (this.location == null) {
81              if (other.location != null) {
82                  return false;
83              }
84          } else if (!this.location.equals(other.location)) {
85              return false;
86          }
87          if (this.password == null) {
88              if (other.password != null) {
89                  return false;
90              }
91          } else if (!this.password.equals(other.password)) {
92              return false;
93          }
94          return true;
95      }    
96  }