CertificateFactory factory = CertificateFactory.getInstance(certificateMatch(valueType));
InputStream certStream = new ByteArrayInputStream(certBytes);
if (X509PKIPATHV1.equals(valueType)) {
CertPath path = factory.generateCertPath(certStream);
for (Certificate certificate : path.getCertificates()) {
credentials.add(new CertificateCredential(certificate));
}
} else if (X509V3.equals(valueType)) {
Certificate certificate = factory.generateCertificate(certStream);
credentials.add(new CertificateCredential(certificate));
} else if (PKCS7.equals(valueType)) {
throw BaseSecurityMessages.MESSAGES.valueTypeRecognizedNotImplemented(valueType);
} else {
throw BaseSecurityMessages.MESSAGES.valueTypeNotImplemented(valueType);
}