KEYCLOAK-19410 Compile issues in IntelliJ due to imports of sun packages
This commit is contained in:
parent
b04236f7de
commit
12c7bc7350
9 changed files with 24 additions and 16 deletions
|
@ -35,6 +35,9 @@ import java.security.cert.X509Certificate;
|
||||||
*/
|
*/
|
||||||
public final class PemUtils {
|
public final class PemUtils {
|
||||||
|
|
||||||
|
public static final String BEGIN_CERT = "-----BEGIN CERTIFICATE-----";
|
||||||
|
public static final String END_CERT = "-----END CERTIFICATE-----";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BouncyIntegration.init();
|
BouncyIntegration.init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.keycloak.saml.processing.core.util;
|
package org.keycloak.saml.processing.core.util;
|
||||||
|
|
||||||
|
import org.keycloak.common.util.PemUtils;
|
||||||
import org.keycloak.dom.xmlsec.w3.xmldsig.DSAKeyValueType;
|
import org.keycloak.dom.xmlsec.w3.xmldsig.DSAKeyValueType;
|
||||||
import org.keycloak.dom.xmlsec.w3.xmldsig.KeyValueType;
|
import org.keycloak.dom.xmlsec.w3.xmldsig.KeyValueType;
|
||||||
import org.keycloak.dom.xmlsec.w3.xmldsig.RSAKeyValueType;
|
import org.keycloak.dom.xmlsec.w3.xmldsig.RSAKeyValueType;
|
||||||
|
@ -577,7 +578,7 @@ public class XMLSignatureUtil {
|
||||||
public static X509Certificate getX509CertificateFromKeyInfoString(String certificateString) throws ProcessingException {
|
public static X509Certificate getX509CertificateFromKeyInfoString(String certificateString) throws ProcessingException {
|
||||||
X509Certificate cert = null;
|
X509Certificate cert = null;
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("-----BEGIN CERTIFICATE-----\n").append(certificateString).append("\n-----END CERTIFICATE-----");
|
builder.append(PemUtils.BEGIN_CERT + "\n").append(certificateString).append("\n" + PemUtils.END_CERT);
|
||||||
|
|
||||||
String derFormattedString = builder.toString();
|
String derFormattedString = builder.toString();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.keycloak.protocol.docker.installation.compose;
|
package org.keycloak.protocol.docker.installation.compose;
|
||||||
|
|
||||||
|
import org.keycloak.common.util.PemUtils;
|
||||||
|
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
import java.security.cert.Certificate;
|
import java.security.cert.Certificate;
|
||||||
|
@ -7,8 +9,8 @@ import java.security.cert.CertificateEncodingException;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|
||||||
public final class DockerCertFileUtils {
|
public final class DockerCertFileUtils {
|
||||||
public static final String BEGIN_CERT = "-----BEGIN CERTIFICATE-----";
|
public static final String BEGIN_CERT = PemUtils.BEGIN_CERT;
|
||||||
public static final String END_CERT = "-----END CERTIFICATE-----";
|
public static final String END_CERT = PemUtils.END_CERT;
|
||||||
public static final String BEGIN_PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----";
|
public static final String BEGIN_PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----";
|
||||||
public static final String END_PRIVATE_KEY = "-----END PRIVATE KEY-----";
|
public static final String END_PRIVATE_KEY = "-----END PRIVATE KEY-----";
|
||||||
public static final String LINE_SEPERATOR = System.getProperty("line.separator");
|
public static final String LINE_SEPERATOR = System.getProperty("line.separator");
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class ApacheProxySslClientCertificateLookup extends AbstractClientCertifi
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String removeBeginEnd(String pem) {
|
private static String removeBeginEnd(String pem) {
|
||||||
pem = pem.replace("-----BEGIN CERTIFICATE-----", "");
|
pem = pem.replace(PemUtils.BEGIN_CERT, "");
|
||||||
pem = pem.replace("-----END CERTIFICATE-----", "");
|
pem = pem.replace(PemUtils.END_CERT, "");
|
||||||
pem = pem.replace("\r\n", "");
|
pem = pem.replace("\r\n", "");
|
||||||
pem = pem.replace("\n", "");
|
pem = pem.replace("\n", "");
|
||||||
return pem.trim();
|
return pem.trim();
|
||||||
|
@ -53,7 +53,7 @@ public class ApacheProxySslClientCertificateLookup extends AbstractClientCertifi
|
||||||
if (pem == null) {
|
if (pem == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (pem.startsWith("-----BEGIN CERTIFICATE-----")) {
|
if (pem.startsWith(PemUtils.BEGIN_CERT)) {
|
||||||
pem = removeBeginEnd(pem);
|
pem = removeBeginEnd(pem);
|
||||||
}
|
}
|
||||||
return PemUtils.decodeCertificate(pem);
|
return PemUtils.decodeCertificate(pem);
|
||||||
|
|
|
@ -87,8 +87,8 @@ public class NginxProxySslClientCertificateLookup extends AbstractClientCertific
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static String removeBeginEnd(String pem) {
|
private static String removeBeginEnd(String pem) {
|
||||||
pem = pem.replace("-----BEGIN CERTIFICATE-----", "");
|
pem = pem.replace(PemUtils.BEGIN_CERT, "");
|
||||||
pem = pem.replace("-----END CERTIFICATE-----", "");
|
pem = pem.replace(PemUtils.END_CERT, "");
|
||||||
pem = pem.replace("\r\n", "");
|
pem = pem.replace("\r\n", "");
|
||||||
pem = pem.replace("\n", "");
|
pem = pem.replace("\n", "");
|
||||||
return pem.trim();
|
return pem.trim();
|
||||||
|
@ -110,7 +110,7 @@ public class NginxProxySslClientCertificateLookup extends AbstractClientCertific
|
||||||
log.error("Cannot URL decode the end user TLS Certificate : " + pem,e);
|
log.error("Cannot URL decode the end user TLS Certificate : " + pem,e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pem.startsWith("-----BEGIN CERTIFICATE-----")) {
|
if (pem.startsWith(PemUtils.BEGIN_CERT)) {
|
||||||
pem = removeBeginEnd(pem);
|
pem = removeBeginEnd(pem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.admin.client.resource.ClientAttributeCertificateResource;
|
import org.keycloak.admin.client.resource.ClientAttributeCertificateResource;
|
||||||
import org.keycloak.admin.client.resource.ClientResource;
|
import org.keycloak.admin.client.resource.ClientResource;
|
||||||
|
import org.keycloak.common.util.PemUtils;
|
||||||
import org.keycloak.events.admin.OperationType;
|
import org.keycloak.events.admin.OperationType;
|
||||||
import org.keycloak.events.admin.ResourceType;
|
import org.keycloak.events.admin.ResourceType;
|
||||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||||
|
@ -170,7 +171,7 @@ public class CredentialsTest extends AbstractClientTest {
|
||||||
form = new MultipartFormDataOutput();
|
form = new MultipartFormDataOutput();
|
||||||
form.addFormData("keystoreFormat", "Certificate PEM", MediaType.TEXT_PLAIN_TYPE);
|
form.addFormData("keystoreFormat", "Certificate PEM", MediaType.TEXT_PLAIN_TYPE);
|
||||||
|
|
||||||
String certificate2WithHeaders = "-----BEGIN CERTIFICATE-----\n" + certificate2 + "\n-----END CERTIFICATE-----";
|
String certificate2WithHeaders = PemUtils.BEGIN_CERT + "\n" + certificate2 + "\n" + PemUtils.END_CERT;
|
||||||
|
|
||||||
form.addFormData("file", certificate2WithHeaders.getBytes(Charset.forName("ASCII")), MediaType.APPLICATION_OCTET_STREAM_TYPE);
|
form.addFormData("file", certificate2WithHeaders.getBytes(Charset.forName("ASCII")), MediaType.APPLICATION_OCTET_STREAM_TYPE);
|
||||||
cert = certRsc.uploadJks(form);
|
cert = certRsc.uploadJks(form);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.common.Profile;
|
import org.keycloak.common.Profile;
|
||||||
|
import org.keycloak.common.util.PemUtils;
|
||||||
import org.keycloak.representations.idm.KeysMetadataRepresentation;
|
import org.keycloak.representations.idm.KeysMetadataRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.testsuite.AbstractKeycloakTest;
|
import org.keycloak.testsuite.AbstractKeycloakTest;
|
||||||
|
@ -13,7 +14,6 @@ import org.testcontainers.containers.BindMode;
|
||||||
import org.testcontainers.containers.Container;
|
import org.testcontainers.containers.Container;
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
import org.testcontainers.containers.output.Slf4jLogConsumer;
|
import org.testcontainers.containers.output.Slf4jLogConsumer;
|
||||||
import sun.security.provider.X509Factory;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
@ -28,6 +28,7 @@ import static org.junit.Assume.assumeTrue;
|
||||||
import static org.keycloak.testsuite.util.ServerURLs.AUTH_SERVER_PORT;
|
import static org.keycloak.testsuite.util.ServerURLs.AUTH_SERVER_PORT;
|
||||||
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude;
|
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude;
|
||||||
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer;
|
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer;
|
||||||
|
|
||||||
import static org.keycloak.testsuite.util.WaitUtils.pause;
|
import static org.keycloak.testsuite.util.WaitUtils.pause;
|
||||||
|
|
||||||
@AuthServerContainerExclude(AuthServer.REMOTE)
|
@AuthServerContainerExclude(AuthServer.REMOTE)
|
||||||
|
@ -97,9 +98,9 @@ public class DockerClientTest extends AbstractKeycloakTest {
|
||||||
File tmpCertFile = File.createTempFile("keycloak-docker-realm-cert-", ".pem");
|
File tmpCertFile = File.createTempFile("keycloak-docker-realm-cert-", ".pem");
|
||||||
tmpCertFile.deleteOnExit();
|
tmpCertFile.deleteOnExit();
|
||||||
PrintWriter tmpCertWriter = new PrintWriter(tmpCertFile);
|
PrintWriter tmpCertWriter = new PrintWriter(tmpCertFile);
|
||||||
tmpCertWriter.println(X509Factory.BEGIN_CERT);
|
tmpCertWriter.println(PemUtils.BEGIN_CERT);
|
||||||
tmpCertWriter.println(realmCert);
|
tmpCertWriter.println(realmCert);
|
||||||
tmpCertWriter.println(X509Factory.END_CERT);
|
tmpCertWriter.println(PemUtils.END_CERT);
|
||||||
tmpCertWriter.close();
|
tmpCertWriter.close();
|
||||||
|
|
||||||
final Map<String, String> environment = new HashMap<>();
|
final Map<String, String> environment = new HashMap<>();
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.authentication.authenticators.x509.X509AuthenticatorConfigModel;
|
import org.keycloak.authentication.authenticators.x509.X509AuthenticatorConfigModel;
|
||||||
|
import org.keycloak.common.util.PemUtils;
|
||||||
import org.keycloak.representations.idm.AuthenticatorConfigRepresentation;
|
import org.keycloak.representations.idm.AuthenticatorConfigRepresentation;
|
||||||
import org.keycloak.testsuite.util.OAuthClient;
|
import org.keycloak.testsuite.util.OAuthClient;
|
||||||
|
|
||||||
|
@ -164,8 +165,8 @@ public class X509OCSPResponderTest extends AbstractX509AuthenticationTest {
|
||||||
.setOCSPResponder("http://" + OCSP_RESPONDER_HOST + ":" + OCSP_RESPONDER_PORT + "/oscp")
|
.setOCSPResponder("http://" + OCSP_RESPONDER_HOST + ":" + OCSP_RESPONDER_PORT + "/oscp")
|
||||||
.setOCSPResponderCertificate(
|
.setOCSPResponderCertificate(
|
||||||
IOUtils.toString(this.getClass().getResourceAsStream(OcspHandler.OCSP_RESPONDER_CERT_PATH), Charsets.UTF_8)
|
IOUtils.toString(this.getClass().getResourceAsStream(OcspHandler.OCSP_RESPONDER_CERT_PATH), Charsets.UTF_8)
|
||||||
.replace("-----BEGIN CERTIFICATE-----", "")
|
.replace(PemUtils.BEGIN_CERT, "")
|
||||||
.replace("-----END CERTIFICATE-----", ""))
|
.replace(PemUtils.END_CERT, ""))
|
||||||
.setUserIdentityMapperType(USERNAME_EMAIL);
|
.setUserIdentityMapperType(USERNAME_EMAIL);
|
||||||
AuthenticatorConfigRepresentation cfg = newConfig("x509-directgrant-config", config.getConfig());
|
AuthenticatorConfigRepresentation cfg = newConfig("x509-directgrant-config", config.getConfig());
|
||||||
String cfgId = createConfig(directGrantExecution.getId(), cfg);
|
String cfgId = createConfig(directGrantExecution.getId(), cfg);
|
||||||
|
|
|
@ -39,7 +39,6 @@ import org.w3c.dom.DOMException;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import sun.applet.AppletSecurity;
|
|
||||||
|
|
||||||
import static org.keycloak.testsuite.utils.io.IOUtil.modifyDocElementAttribute;
|
import static org.keycloak.testsuite.utils.io.IOUtil.modifyDocElementAttribute;
|
||||||
import static org.keycloak.testsuite.util.ServerURLs.getAppServerContextRoot;
|
import static org.keycloak.testsuite.util.ServerURLs.getAppServerContextRoot;
|
||||||
|
|
Loading…
Reference in a new issue