Search in sources :

Example 56 with ComponentRepresentation

use of org.keycloak.representations.idm.ComponentRepresentation in project keycloak by keycloak.

the class ClientStorageTest method addProvidersBeforeTest.

@Before
public void addProvidersBeforeTest() throws URISyntaxException, IOException {
    ComponentRepresentation provider = new ComponentRepresentation();
    provider.setName("client-storage-hardcoded");
    provider.setProviderId(HardcodedClientStorageProviderFactory.PROVIDER_ID);
    provider.setProviderType(ClientStorageProvider.class.getName());
    provider.setConfig(new MultivaluedHashMap<>());
    provider.getConfig().putSingle(HardcodedClientStorageProviderFactory.CLIENT_ID, "hardcoded-client");
    provider.getConfig().putSingle(HardcodedClientStorageProviderFactory.REDIRECT_URI, oauth.getRedirectUri());
    provider.getConfig().putSingle(HardcodedClientStorageProviderFactory.DELAYED_SEARCH, Boolean.toString(false));
    providerId = addComponent(provider);
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) ClientStorageProvider(org.keycloak.storage.client.ClientStorageProvider) Before(org.junit.Before)

Example 57 with ComponentRepresentation

use of org.keycloak.representations.idm.ComponentRepresentation in project keycloak by keycloak.

the class RoleStorageTest method addProvidersBeforeTest.

@Before
public void addProvidersBeforeTest() throws URISyntaxException, IOException {
    ComponentRepresentation provider = new ComponentRepresentation();
    provider.setName("role-storage-hardcoded");
    provider.setProviderId(HardcodedRoleStorageProviderFactory.PROVIDER_ID);
    provider.setProviderType(RoleStorageProvider.class.getName());
    provider.setConfig(new MultivaluedHashMap<>());
    provider.getConfig().putSingle(HardcodedRoleStorageProviderFactory.ROLE_NAME, "hardcoded-role");
    provider.getConfig().putSingle(HardcodedRoleStorageProviderFactory.DELAYED_SEARCH, Boolean.toString(false));
    providerId = addComponent(provider);
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) RoleStorageProvider(org.keycloak.storage.role.RoleStorageProvider) Before(org.junit.Before)

Example 58 with ComponentRepresentation

use of org.keycloak.representations.idm.ComponentRepresentation in project keycloak by keycloak.

the class LdapUserFederationTest method configureConnectionPooling.

@Test
public void configureConnectionPooling() {
    createLdapUserProvider.navigateTo();
    createLdapUserProvider.form().selectVendor(ACTIVE_DIRECTORY);
    createLdapUserProvider.form().setConsoleDisplayNameInput("ldap");
    createLdapUserProvider.form().selectEditMode(WRITABLE);
    createLdapUserProvider.form().setLdapConnectionUrlInput("ldap://localhost:389");
    createLdapUserProvider.form().setLdapBindDnInput("KEYCLOAK/Administrator");
    createLdapUserProvider.form().setLdapUserDnInput("ou=People,dc=keycloak,dc=org");
    createLdapUserProvider.form().setLdapBindCredentialInput("secret");
    createLdapUserProvider.form().connectionPoolingSettings();
    createLdapUserProvider.form().setConnectionPoolingAuthentication("none");
    createLdapUserProvider.form().setConnectionPoolingDebug("fine");
    createLdapUserProvider.form().setConnectionPoolingInitSize("10");
    createLdapUserProvider.form().setConnectionPoolingMaxSize("12");
    createLdapUserProvider.form().setConnectionPoolingPrefSize("11");
    createLdapUserProvider.form().setConnectionPoolingProtocol("ssl");
    createLdapUserProvider.form().setConnectionPoolingTimeout("500");
    createLdapUserProvider.form().save();
    assertAlertSuccess();
    ComponentRepresentation ufpr = testRealmResource().components().query(null, "org.keycloak.storage.UserStorageProvider").get(0);
    assertLdapConnectionPoolSettings(ufpr, "none", "fine", "10", "12", "11", "ssl", "500");
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) AbstractConsoleTest(org.keycloak.testsuite.console.AbstractConsoleTest) Test(org.junit.Test)

Example 59 with ComponentRepresentation

use of org.keycloak.representations.idm.ComponentRepresentation in project keycloak by keycloak.

the class LdapUserFederationTest method configureAdProvider.

@Test
public void configureAdProvider() {
    createLdapUserProvider.navigateTo();
    createLdapUserProvider.form().selectVendor(ACTIVE_DIRECTORY);
    createLdapUserProvider.form().setConsoleDisplayNameInput("ldap");
    createLdapUserProvider.form().selectEditMode(WRITABLE);
    createLdapUserProvider.form().setLdapConnectionUrlInput("ldap://localhost:389");
    createLdapUserProvider.form().setLdapBindDnInput("KEYCLOAK/Administrator");
    createLdapUserProvider.form().setLdapUserDnInput("ou=People,dc=keycloak,dc=org");
    createLdapUserProvider.form().setLdapBindCredentialInput("secret");
    // createLdapUserProvider.form().setAccountAfterPasswordUpdateEnabled(false);
    // enable kerberos
    createLdapUserProvider.form().uncollapseKerberosIntegrationHeader();
    createLdapUserProvider.form().setAllowKerberosAuthEnabled(true);
    createLdapUserProvider.form().setKerberosRealmInput("KEYCLOAK.ORG");
    createLdapUserProvider.form().setServerPrincipalInput("HTTP/localhost@KEYCLOAK.ORG");
    createLdapUserProvider.form().setKeyTabInput("http.keytab");
    createLdapUserProvider.form().setDebugEnabled(true);
    createLdapUserProvider.form().save();
    assertAlertSuccess();
    ComponentRepresentation ufpr = testRealmResource().components().query(null, "org.keycloak.storage.UserStorageProvider").get(0);
    assertLdapProviderSetting(ufpr, "ldap", "0", WRITABLE, "false", "ad", "1", "true", "true", "false");
    assertLdapBasicMapping(ufpr, "cn", "cn", "objectGUID", "person, organizationalPerson, user", "ou=People,dc=keycloak,dc=org");
    assertLdapSyncSetings(ufpr, "1000", "-1", "-1");
    assertLdapKerberosSetings(ufpr, "KEYCLOAK.ORG", "HTTP/localhost@KEYCLOAK.ORG", "http.keytab", "true", "false");
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) AbstractConsoleTest(org.keycloak.testsuite.console.AbstractConsoleTest) Test(org.junit.Test)

Example 60 with ComponentRepresentation

use of org.keycloak.representations.idm.ComponentRepresentation in project keycloak by keycloak.

the class RealmManager method generateNewRsaKey.

public String generateNewRsaKey(KeyPair keyPair, String name) {
    RealmRepresentation rep = realm.toRepresentation();
    Certificate certificate = CertificateUtils.generateV1SelfSignedCertificate(keyPair, "test");
    String certificatePem = PemUtils.encodeCertificate(certificate);
    ComponentRepresentation keyProviderRepresentation = new ComponentRepresentation();
    keyProviderRepresentation.setName(name);
    keyProviderRepresentation.setParentId(rep.getId());
    keyProviderRepresentation.setProviderId(ImportedRsaKeyProviderFactory.ID);
    keyProviderRepresentation.setProviderType(KeyProvider.class.getName());
    MultivaluedHashMap<String, String> config = new MultivaluedHashMap<>();
    config.putSingle(Attributes.PRIVATE_KEY_KEY, PemUtils.encodeKey(keyPair.getPrivate()));
    config.putSingle(Attributes.CERTIFICATE_KEY, certificatePem);
    config.putSingle(Attributes.PRIORITY_KEY, "100");
    keyProviderRepresentation.setConfig(config);
    Response response = realm.components().add(keyProviderRepresentation);
    String providerId = ApiUtil.getCreatedId(response);
    response.close();
    deactivateOtherRsaKeys(providerId);
    return providerId;
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) KeyProvider(org.keycloak.keys.KeyProvider) MultivaluedHashMap(org.keycloak.common.util.MultivaluedHashMap) Response(javax.ws.rs.core.Response) RealmRepresentation(org.keycloak.representations.idm.RealmRepresentation) X509Certificate(java.security.cert.X509Certificate) Certificate(java.security.cert.Certificate)

Aggregations

ComponentRepresentation (org.keycloak.representations.idm.ComponentRepresentation)120 Test (org.junit.Test)56 Response (javax.ws.rs.core.Response)44 UserStorageProvider (org.keycloak.storage.UserStorageProvider)22 KeyProvider (org.keycloak.keys.KeyProvider)17 AbstractKeycloakTest (org.keycloak.testsuite.AbstractKeycloakTest)13 Before (org.junit.Before)12 KeysMetadataRepresentation (org.keycloak.representations.idm.KeysMetadataRepresentation)12 RealmModel (org.keycloak.models.RealmModel)10 AuthServerContainerExclude (org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude)10 KeyPair (java.security.KeyPair)9 UserModel (org.keycloak.models.UserModel)9 AbstractAuthenticationTest (org.keycloak.testsuite.admin.authentication.AbstractAuthenticationTest)8 RealmResource (org.keycloak.admin.client.resource.RealmResource)7 MultivaluedHashMap (org.keycloak.common.util.MultivaluedHashMap)7 ComponentModel (org.keycloak.component.ComponentModel)7 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)7 OIDCClientRepresentation (org.keycloak.representations.oidc.OIDCClientRepresentation)6 AbstractAuthTest (org.keycloak.testsuite.AbstractAuthTest)6 List (java.util.List)5