From eea40cb88a3dff54ec44395554fe2d0ec70dde3d Mon Sep 17 00:00:00 2001 From: Xiaoyu Yao Date: Fri, 1 Mar 2019 10:49:39 -0800 Subject: [PATCH] HDDS-1204. Fix ClassNotFound issue with javax.xml.bind.DatatypeConverter used by DefaultProfile. Contributed by Xiaoyu Yao. --- .../certificate/authority/PKIProfiles/DefaultProfile.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/PKIProfiles/DefaultProfile.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/PKIProfiles/DefaultProfile.java index a9f55596c9e..13319d16572 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/PKIProfiles/DefaultProfile.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/PKIProfiles/DefaultProfile.java @@ -20,6 +20,8 @@ package org.apache.hadoop.hdds.security.x509.certificate.authority.PKIProfiles; import com.google.common.base.Preconditions; +import org.apache.commons.codec.DecoderException; +import org.apache.commons.codec.binary.Hex; import org.apache.commons.validator.routines.DomainValidator; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.x500.RDN; @@ -32,7 +34,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.bind.DatatypeConverter; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.AbstractMap.SimpleEntry; @@ -234,10 +235,10 @@ public boolean validateGeneralName(int type, String value) { // TODO: Fail? if we cannot resolve the Hostname? try { final InetAddress byAddress = InetAddress.getByAddress( - DatatypeConverter.parseHexBinary(value.substring(1))); + Hex.decodeHex(value.substring(1))); LOG.debug("Host Name/IP Address : {}", byAddress.toString()); return true; - } catch (UnknownHostException e) { + } catch (UnknownHostException | DecoderException e) { return false; } case GeneralName.dNSName: