Merge pull request #542 from xiaoyuyao/HDDS-1204

HDDS-1204. Fix ClassNotFound issue with javax.xml.bind.DatatypeConver…
This commit is contained in:
Ajay Yadav 2019-03-01 12:18:29 -08:00 committed by GitHub
commit 8b72aea5c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -20,6 +20,8 @@
package org.apache.hadoop.hdds.security.x509.certificate.authority.PKIProfiles; package org.apache.hadoop.hdds.security.x509.certificate.authority.PKIProfiles;
import com.google.common.base.Preconditions; 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.apache.commons.validator.routines.DomainValidator;
import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.x500.RDN; import org.bouncycastle.asn1.x500.RDN;
@ -32,7 +34,6 @@
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.xml.bind.DatatypeConverter;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.AbstractMap.SimpleEntry; import java.util.AbstractMap.SimpleEntry;
@ -234,10 +235,10 @@ public boolean validateGeneralName(int type, String value) {
// TODO: Fail? if we cannot resolve the Hostname? // TODO: Fail? if we cannot resolve the Hostname?
try { try {
final InetAddress byAddress = InetAddress.getByAddress( final InetAddress byAddress = InetAddress.getByAddress(
DatatypeConverter.parseHexBinary(value.substring(1))); Hex.decodeHex(value.substring(1)));
LOG.debug("Host Name/IP Address : {}", byAddress.toString()); LOG.debug("Host Name/IP Address : {}", byAddress.toString());
return true; return true;
} catch (UnknownHostException e) { } catch (UnknownHostException | DecoderException e) {
return false; return false;
} }
case GeneralName.dNSName: case GeneralName.dNSName: