diff --git a/components/apimgt/org.wso2.carbon.apimgt.common.gateway/src/main/java/org/wso2/carbon/apimgt/common/gateway/dto/TokenIssuerDto.java b/components/apimgt/org.wso2.carbon.apimgt.common.gateway/src/main/java/org/wso2/carbon/apimgt/common/gateway/dto/TokenIssuerDto.java index a9aea891309f..216d2e958f2b 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.common.gateway/src/main/java/org/wso2/carbon/apimgt/common/gateway/dto/TokenIssuerDto.java +++ b/components/apimgt/org.wso2.carbon.apimgt.common.gateway/src/main/java/org/wso2/carbon/apimgt/common/gateway/dto/TokenIssuerDto.java @@ -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. diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/factory/KeyManagerHolder.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/factory/KeyManagerHolder.java index 2aa3891f3115..b5ec7ff146b6 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/factory/KeyManagerHolder.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/factory/KeyManagerHolder.java @@ -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. diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java index 9e4798aa3fb7..896f9d34b562 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java @@ -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; @@ -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); @@ -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); diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.util/src/main/java/org/wso2/carbon/apimgt/rest/api/util/impl/OAuthJwtAuthenticatorImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.util/src/main/java/org/wso2/carbon/apimgt/rest/api/util/impl/OAuthJwtAuthenticatorImpl.java index 04cb49a34cf7..9e6d760f5a85 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.util/src/main/java/org/wso2/carbon/apimgt/rest/api/util/impl/OAuthJwtAuthenticatorImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.util/src/main/java/org/wso2/carbon/apimgt/rest/api/util/impl/OAuthJwtAuthenticatorImpl.java @@ -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;