[LOG4J2-1896] Update org.apache.logging.log4j.core.net.ssl.StoreConfiguration from a String to char[] to represent its password.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/422d0902 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/422d0902 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/422d0902 Branch: refs/heads/LOG4J2-1442 Commit: 422d09022acfe3f34e3dbcf32d87ac50198ad560 Parents: afe9295 Author: Gary Gregory <[email protected]> Authored: Sat May 6 12:46:03 2017 -0700 Committer: Gary Gregory <[email protected]> Committed: Sat May 6 12:46:03 2017 -0700 ---------------------------------------------------------------------- .../log4j/core/net/ssl/StoreConfiguration.java | 44 ++++++++------------ src/changes/changes.xml | 3 ++ 2 files changed, 21 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/422d0902/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/StoreConfiguration.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/StoreConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/StoreConfiguration.java index f342fd5..8002287 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/StoreConfiguration.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/StoreConfiguration.java @@ -16,6 +16,8 @@ */ package org.apache.logging.log4j.core.net.ssl; +import java.util.Arrays; + import org.apache.logging.log4j.status.StatusLogger; /** @@ -25,11 +27,11 @@ public class StoreConfiguration<T> { protected static final StatusLogger LOGGER = StatusLogger.getLogger(); private String location; - private String password; + private char[] password; public StoreConfiguration(final String location, final String password) { this.location = location; - this.password = password; + this.password = password == null ? null : password.toCharArray(); } public String getLocation() { @@ -41,15 +43,15 @@ public class StoreConfiguration<T> { } public String getPassword() { - return this.password; + return String.valueOf(this.password); } public char[] getPasswordAsCharArray() { - return this.password == null ? null : this.password.toCharArray(); + return this.password; } public void setPassword(final String password) { - this.password = password; + this.password = password == null ? null : password.toCharArray(); } /** @@ -63,37 +65,27 @@ public class StoreConfiguration<T> { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((this.location == null) ? 0 : this.location.hashCode()); - result = prime * result + ((this.password == null) ? 0 : this.password.hashCode()); + result = prime * result + ((location == null) ? 0 : location.hashCode()); + result = prime * result + Arrays.hashCode(password); return result; } @Override - public boolean equals(final Object obj) { - if (this == obj) { + public boolean equals(Object obj) { + if (this == obj) return true; - } - if (obj == null) { + if (obj == null) return false; - } - if (!(obj instanceof StoreConfiguration)) { + if (getClass() != obj.getClass()) return false; - } - final StoreConfiguration<?> other = (StoreConfiguration<?>) obj; - if (this.location == null) { - if (other.location != null) { + StoreConfiguration other = (StoreConfiguration) obj; + if (location == null) { + if (other.location != null) return false; - } - } else if (!this.location.equals(other.location)) { + } else if (!location.equals(other.location)) return false; - } - if (this.password == null) { - if (other.password != null) { - return false; - } - } else if (!this.password.equals(other.password)) { + if (!Arrays.equals(password, other.password)) return false; - } return true; } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/422d0902/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 379c21e..c40d3bb 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -76,6 +76,9 @@ <action issue="LOG4J2-1877" dev="ggregory" type="update" due-to="Chandra Tungathurthi"> Missing documentation for Max index limit in DefaultRolloverStrategy. </action> + <action issue="LOG4J2-1896" dev="ggregory" type="update"> + Update org.apache.logging.log4j.core.net.ssl.StoreConfiguration from a String to char[] to represent its password. + </action> </release> <release version="2.8.2" date="2017-04-02" description="GA Release 2.8.2"> <action issue="LOG4J2-1861" dev="mattsicker" type="fix">
