[KEYCLOAK-5175] Importing certificate to saml client takes too long
This commit is contained in:
parent
f939818252
commit
0a9055e112
9 changed files with 214 additions and 2 deletions
|
@ -0,0 +1,88 @@
|
|||
package org.keycloak.testsuite.console.page.clients.credentials;
|
||||
|
||||
import org.keycloak.testsuite.page.Form;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.Select;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.keycloak.services.resources.admin.ClientAttributeCertificateResource.CERTIFICATE_PEM;
|
||||
import static org.keycloak.common.util.KeystoreUtil.KeystoreFormat.JKS;
|
||||
import static org.keycloak.common.util.KeystoreUtil.KeystoreFormat.PKCS12;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bruno@abstractj.org">Bruno Oliveira</a>
|
||||
*/
|
||||
public class SAMLClientCredentialsForm extends Form {
|
||||
|
||||
private static final String PATH_PREFIX = "saml-keys" + File.separator;
|
||||
|
||||
@FindBy(linkText = "SAML Keys")
|
||||
private WebElement samlKeysLink;
|
||||
|
||||
@FindBy(xpath = "//button[@data-ng-click='importSigningKey()']")
|
||||
private WebElement importButton;
|
||||
|
||||
@FindBy(id = "uploadKeyFormat")
|
||||
private Select uploadKeyFormat;
|
||||
|
||||
@FindBy(id = "import-file")
|
||||
private WebElement selectFileButton;
|
||||
|
||||
@FindBy(xpath = "//button[@data-ng-click='uploadFile()']")
|
||||
private WebElement uploadButton;
|
||||
|
||||
@FindBy(xpath = "//div[contains(@class, 'alert-success')]")
|
||||
private WebElement success;
|
||||
|
||||
@FindBy(id = "uploadKeyAlias")
|
||||
private WebElement uploadKeyAlias;
|
||||
|
||||
@FindBy(id = "uploadStorePassword")
|
||||
private WebElement uploadStorePassword;
|
||||
|
||||
public void importPemCertificateKey() {
|
||||
navigateToImport();
|
||||
uploadKeyFormat.selectByVisibleText(CERTIFICATE_PEM);
|
||||
uploadFile(PATH_PREFIX + "client.pem");
|
||||
}
|
||||
|
||||
public void importJKSKey() {
|
||||
navigateToImport();
|
||||
uploadKeyFormat.selectByVisibleText(JKS.toString());
|
||||
fillCredentials();
|
||||
uploadFile(PATH_PREFIX + "client.jks");
|
||||
}
|
||||
|
||||
public void importPKCS12Key() {
|
||||
navigateToImport();
|
||||
uploadKeyFormat.selectByVisibleText(PKCS12.toString());
|
||||
fillCredentials();
|
||||
uploadFile(PATH_PREFIX + "client.p12");
|
||||
}
|
||||
|
||||
public String getSuccessMessage() {
|
||||
return success.getText();
|
||||
}
|
||||
|
||||
private void uploadFile(String file) {
|
||||
URL fileUrl = (getClass().getClassLoader().getResource(file));
|
||||
selectFileButton.sendKeys(fileUrl.getFile());
|
||||
uploadButton.click();
|
||||
}
|
||||
|
||||
private void fillCredentials() {
|
||||
uploadKeyAlias.clear();
|
||||
uploadKeyAlias.sendKeys("samlKey");
|
||||
|
||||
uploadStorePassword.clear();
|
||||
uploadStorePassword.sendKeys("secret");
|
||||
}
|
||||
|
||||
private void navigateToImport() {
|
||||
samlKeysLink.click();
|
||||
importButton.click();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
# Generate the Key
|
||||
openssl genrsa -out client.key 2048
|
||||
|
||||
# Create a signing request
|
||||
openssl req -new -key client.key -out certificate.csr -subj "/C=US/ST=MA/L=Boston/O=Red Hat/OU=Keyloak/CN=saml.client.local"
|
||||
|
||||
# PEM
|
||||
openssl x509 -req -in certificate.csr -signkey client.key -out client.pem
|
||||
|
||||
# PKCS12
|
||||
openssl pkcs12 -export -passin pass:secret -password pass:secret -in client.pem -inkey client.key -out client.p12 -name "samlKey"
|
||||
|
||||
# JKS
|
||||
keytool -importkeystore -destkeystore client.jks -deststorepass secret -srckeystore client.p12 -srcstoretype PKCS12 -srcstorepass secret
|
|
@ -0,0 +1,18 @@
|
|||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIIC2TCCAcECAQAwazELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk1BMQ8wDQYDVQQH
|
||||
DAZCb3N0b24xEDAOBgNVBAoMB1JlZCBIYXQxEDAOBgNVBAsMB0tleWxvYWsxGjAY
|
||||
BgNVBAMMEXNhbWwuY2xpZW50LmxvY2FsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
|
||||
MIIBCgKCAQEAvQxRKR+sLTUXACPxZjKjBDctmpG8O6Y8RwGTP768rD3PE1octkMv
|
||||
7KhYIojRIeqd30p9bY0J4BGDkK5f5wGAbBQkTEH0LbS50zynAiDvnRaZToglyriE
|
||||
tkzWOhuAgXBHgAp0xCSBZ4HiRHsKKG0frnX+1m6/MYrDd4rYOl4OYkSZ3e+MZ7Aa
|
||||
boDJeOrFmFSvJQfERvG+oqYhiUNNr1G4/VdG7miG4Do4U3m7nZW3D7xKAtRRdurW
|
||||
gulkEeJlI4ugQtuwCwUzmjChzps/wnfsCGthZm2m9dOINyj9au4OWxC4qgP+yknT
|
||||
OEy/O3vozYdnikfuElZX45J1XgeWsISe9wIDAQABoCkwJwYJKoZIhvcNAQkOMRow
|
||||
GDAJBgNVHRMEAjAAMAsGA1UdDwQEAwIF4DANBgkqhkiG9w0BAQsFAAOCAQEArRfs
|
||||
B5clOjfU9TjBJ6bkFP+cNSVp/tTcl/7u6MDEzLjTy3eBGXWZTq6x85bLqyVg+PYa
|
||||
hlhMO1ddE3iU01SY0X/NPOl7zfVpfGaJh0kCknyFel+MzKLoUpG1EAVf3ivgVFRF
|
||||
dfle8M1HTu3TdnadlxPIilXaDf1EcDVomxXU9xk/lBDMQ8QuJMznVDKuFRvk0S4z
|
||||
M+ZFRLRFdWLkyQ05xfgwGi/mH8xwxAua1CIs4710WTeEIGv0GBy1Yp7M2FgH9xw+
|
||||
0uveKO+OV/d421/eIUb5zZ7jyr+V54yK34gqccfU/zvBcxdCvl7ot883jwTLrfat
|
||||
WD0QBbbKrgOoRKlkgw==
|
||||
-----END CERTIFICATE REQUEST-----
|
Binary file not shown.
|
@ -0,0 +1,27 @@
|
|||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEAvQxRKR+sLTUXACPxZjKjBDctmpG8O6Y8RwGTP768rD3PE1oc
|
||||
tkMv7KhYIojRIeqd30p9bY0J4BGDkK5f5wGAbBQkTEH0LbS50zynAiDvnRaZTogl
|
||||
yriEtkzWOhuAgXBHgAp0xCSBZ4HiRHsKKG0frnX+1m6/MYrDd4rYOl4OYkSZ3e+M
|
||||
Z7AaboDJeOrFmFSvJQfERvG+oqYhiUNNr1G4/VdG7miG4Do4U3m7nZW3D7xKAtRR
|
||||
durWgulkEeJlI4ugQtuwCwUzmjChzps/wnfsCGthZm2m9dOINyj9au4OWxC4qgP+
|
||||
yknTOEy/O3vozYdnikfuElZX45J1XgeWsISe9wIDAQABAoIBADmCoroQ8Y77JJkd
|
||||
VhWR9/eTVaM9DHdU9edf+kydGMaJMxKfCjcEL3MeL1mqJ3za49YG0iteiY+JpG2C
|
||||
LpiW41t9sSElu0OgRBuXyvKh1GMEefTjBCQsh+rxawZYUXqPDqFMDQOSW2+CmrPc
|
||||
flWYBNhM+w5+uFk47ofSTD9NV7DayZ7rP2h2oH4Lp+cWO3jRDoeAqMU50jNftEAa
|
||||
tIppaalP+7PWM1Lzty0pzO2b19AeoOIdgRmmBJODg5knqeGOZMsjArEWxmC5clqB
|
||||
+27cKVVEyfM3Kt8Noycx2WXTOhn9nc17RGtJcFR1qDKZht3R90Cf57Q2I6rSzaSk
|
||||
n5NTXzkCgYEA6db0XZE/tQ2dSq2nXBTXedB3yLYJmTNB/zklZjuLcGofWEDzQz2i
|
||||
44h7oom3831XswgLNZkyJwqJdoOt7mX5DThYUEAiRRhfvTagkZEmNdnNPhAu8eeI
|
||||
04ef1ZW+dJiH67oiIYheR8YlqVPZQ0wrJCWIQ2yGaO4jqCl9eHS8T+MCgYEAzvaz
|
||||
gN27YoGkiguoDGTiLmBfi4WS7nm6mz8rAYRQSqvtlgD18vgvX5FQRpDo07Z4CwJb
|
||||
QY0Eh/QNgPFAtpFLj+1HKuN7lfP0/IdiksEwUvISzbQybkAyNB3POyy2FF7bjApI
|
||||
Bi+MF/+uJVKp/DmpV/GKzFo1rsUR1KwyPDq+ON0CgYAcXbT6/LmrruEbxAD/TI/u
|
||||
+Pju4hY7/VnOKhJ9Wk/J7TWsMQTRbVKrI01MJESqRtQypZEmiVTqI38VX1fkCX6y
|
||||
udkMsxr1IsXKYCwOPHtUIP2iv7fSJHIWpuces7GM10v1rnihdLdrIYBEECXU4hKB
|
||||
qgPjmfCcHfc5WP8dc5u8XQKBgQC7dPhhYHS5ZHOEFcrAbx/uoZvo47OSDO/Ybf6m
|
||||
ARI4kEFB/NzIlcNS7Gupftdj64IPdrLxTKkt+v/AKsRSmIe4dVJgpmrqB21+zaGb
|
||||
CyCaAGjHqM+EzOCsE9P/5R+Gk+SHk0hpUeeyVQOHCrisnA2mekEdlxfIlPbxioZ1
|
||||
xz9EgQKBgQCS6ZZP6z5uU7AboQrjcWJHMarVCBO9UzqVe+q5nV/XoGKw0VWlnPav
|
||||
kt4cz8IPIIj5yBRKw0JzQnzX4Isxie37s+RVVdPbuAYFCi1yzmlx6n64ZEMMC3gt
|
||||
ppS/NZUNXjomqSt97ofV2jqAVekSiJnnU6NNsP8vHEcea8B32A/PnA==
|
||||
-----END RSA PRIVATE KEY-----
|
Binary file not shown.
|
@ -0,0 +1,20 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIIDUjCCAjoCCQDPbXztCwHGhzANBgkqhkiG9w0BAQsFADBrMQswCQYDVQQGEwJV
|
||||
UzELMAkGA1UECAwCTUExDzANBgNVBAcMBkJvc3RvbjEQMA4GA1UECgwHUmVkIEhh
|
||||
dDEQMA4GA1UECwwHS2V5bG9hazEaMBgGA1UEAwwRc2FtbC5jbGllbnQubG9jYWww
|
||||
HhcNMTcxMjAxMTU0OTA2WhcNMTcxMjMxMTU0OTA2WjBrMQswCQYDVQQGEwJVUzEL
|
||||
MAkGA1UECAwCTUExDzANBgNVBAcMBkJvc3RvbjEQMA4GA1UECgwHUmVkIEhhdDEQ
|
||||
MA4GA1UECwwHS2V5bG9hazEaMBgGA1UEAwwRc2FtbC5jbGllbnQubG9jYWwwggEi
|
||||
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9DFEpH6wtNRcAI/FmMqMENy2a
|
||||
kbw7pjxHAZM/vrysPc8TWhy2Qy/sqFgiiNEh6p3fSn1tjQngEYOQrl/nAYBsFCRM
|
||||
QfQttLnTPKcCIO+dFplOiCXKuIS2TNY6G4CBcEeACnTEJIFngeJEewoobR+udf7W
|
||||
br8xisN3itg6Xg5iRJnd74xnsBpugMl46sWYVK8lB8RG8b6ipiGJQ02vUbj9V0bu
|
||||
aIbgOjhTebudlbcPvEoC1FF26taC6WQR4mUji6BC27ALBTOaMKHOmz/Cd+wIa2Fm
|
||||
bab104g3KP1q7g5bELiqA/7KSdM4TL87e+jNh2eKR+4SVlfjknVeB5awhJ73AgMB
|
||||
AAEwDQYJKoZIhvcNAQELBQADggEBALTMqJnh+jame47hqx1uLpxb1GTgUMTFI692
|
||||
D7Hj5MqQil6yR38pWW39NO0te4DFAyjPWFlI9aSlurpYL7x5mo/dpJA/wDnqkQ/U
|
||||
f86AxK7oBrEsGmWNe1QCTWcamlZyj/faJk7zVRhqwQfwvtbJ47HKLa/XVYx4eFZW
|
||||
wcz3SBu2mikDyAOSegdIBpUmgKuolBF/4zQpv3defxCiG4vtt5R513lnqFiX1Q2L
|
||||
YdX0bhNk/vkvFd4WNOXgOvRv142ec+oc3CMt9QukIQjJFjbJu0GNaVh6uiMVOxas
|
||||
wkoXls/c+rWa19hTdhyzRM8P5xtXCj3ErdREFarwnqBfF0XdEz0=
|
||||
-----END CERTIFICATE-----
|
|
@ -0,0 +1,45 @@
|
|||
package org.keycloak.testsuite.console.clients;
|
||||
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.testsuite.console.page.clients.credentials.SAMLClientCredentialsForm;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.keycloak.testsuite.auth.page.login.Login.SAML;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bruno@abstractj.org">Bruno Oliveira</a>
|
||||
*/
|
||||
public class ClientSAMLKeysTest extends AbstractClientTest {
|
||||
|
||||
private ClientRepresentation newClient;
|
||||
|
||||
@Page
|
||||
private SAMLClientCredentialsForm samlForm;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
newClient = createClientRep("client-saml", SAML);
|
||||
createClient(newClient);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importSAMLKeyPEM() {
|
||||
samlForm.importPemCertificateKey();
|
||||
assertEquals("Expected key upload", "Success! Keystore uploaded successfully.", samlForm.getSuccessMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importSAMLKeyJKS() {
|
||||
samlForm.importJKSKey();
|
||||
assertEquals("Expected key upload", "Success! Keystore uploaded successfully.", samlForm.getSuccessMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importSAMLKeyPKCS12() {
|
||||
samlForm.importPKCS12Key();
|
||||
assertEquals("Expected key upload", "Success! Keystore uploaded successfully.", samlForm.getSuccessMessage());
|
||||
}
|
||||
}
|
|
@ -434,10 +434,10 @@ module.controller('ClientCertificateImportCtrl', function($scope, $location, $ht
|
|||
//fileFormDataName: myFile,
|
||||
/* customize how data is added to formData. See #40#issuecomment-28612000 for example */
|
||||
//formDataAppender: function(formData, key, val){}
|
||||
}).success(function(data, status, headers) {
|
||||
}).then(function(data, status, headers) {
|
||||
Notifications.success("Keystore uploaded successfully.");
|
||||
$location.url(redirectLocation);
|
||||
});
|
||||
})
|
||||
//.then(success, error, progress);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue