Skip to content

Commit

Permalink
Merge pull request #12350 from shnrndk/certificateIssue
Browse files Browse the repository at this point in the history
Change to java.security.cert.X509Certificate class
  • Loading branch information
tharikaGitHub authored Mar 24, 2024
2 parents f30e18a + 79fa543 commit e549a76
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

package org.wso2.carbon.apimgt.common.gateway.dto;

import java.security.cert.Certificate;
import java.util.HashMap;
import java.util.Map;
import javax.security.cert.Certificate;

/**
* Holds data related to token issuers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.security.cert.X509Certificate;
import java.security.cert.X509Certificate;

/**
* This is a factory class.you have to use this when you need to initiate classes by reading config file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
import javax.cache.CacheConfiguration;
import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.security.cert.X509Certificate;
import java.security.cert.X509Certificate;
import javax.validation.constraints.NotNull;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
Expand Down Expand Up @@ -9283,8 +9283,9 @@ public static X509Certificate retrieveCertificateFromURLEncodedContent(String ba
base64EncodedCertificate = APIUtil.getX509certificateContent(base64EncodedCertificate);
byte[] bytes = Base64.decodeBase64(base64EncodedCertificate);
try (InputStream inputStream = new ByteArrayInputStream(bytes)) {
return X509Certificate.getInstance(inputStream);
} catch (IOException | javax.security.cert.CertificateException e) {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
return (X509Certificate) cf.generateCertificate(inputStream);
} catch (IOException | CertificateException e) {
String msg = "Error while converting into X509Certificate";
log.error(msg, e);
throw new APIManagementException(msg, e);
Expand All @@ -9307,8 +9308,9 @@ public static X509Certificate retrieveCertificateFromContent(String base64Encode
base64EncodedCertificate = APIUtil.getX509certificateContent(base64EncodedCertificate);
byte[] bytes = Base64.decodeBase64(base64EncodedCertificate.getBytes());
try (InputStream inputStream = new ByteArrayInputStream(bytes)) {
return X509Certificate.getInstance(inputStream);
} catch (IOException | javax.security.cert.CertificateException e) {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
return (X509Certificate) cf.generateCertificate(inputStream);
} catch (IOException | CertificateException e) {
String msg = "Error while converting into X509Certificate";
log.error(msg, e);
throw new APIManagementException(msg, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;

import javax.security.cert.X509Certificate;
import java.security.cert.X509Certificate;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
Expand Down

0 comments on commit e549a76

Please sign in to comment.