Java Code Examples for org.keycloak.representations.idm.ClientRepresentation#setEnabled()

The following examples show how to use org.keycloak.representations.idm.ClientRepresentation#setEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserTest.java    From keycloak with Apache License 2.0 7 votes vote down vote up
@Test
public void countUsersNotServiceAccount() {
    createUsers();

    Integer count = realm.users().count();
    assertEquals(9, count.intValue());

    ClientRepresentation client = new ClientRepresentation();

    client.setClientId("test-client");
    client.setPublicClient(false);
    client.setSecret("secret");
    client.setServiceAccountsEnabled(true);
    client.setEnabled(true);
    client.setRedirectUris(Arrays.asList("http://url"));

    getAdminClient().realm(REALM_NAME).clients().create(client);

    // KEYCLOAK-5660, should not consider service accounts
    assertEquals(9, realm.users().count().intValue());
}
 
Example 2
Source File: OAuth2OnlyTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void configureTestRealm(RealmRepresentation testRealm) {
    ClientRepresentation client = new ClientRepresentation();
    client.setClientId("more-uris-client");
    client.setEnabled(true);
    client.setRedirectUris(Arrays.asList("http://localhost:8180/auth/realms/master/app/auth", "http://localhost:8180/foo",
          "https://localhost:8543/auth/realms/master/app/auth", "https://localhost:8543/foo"));
    client.setBaseUrl("http://localhost:8180/auth/realms/master/app/auth");

    testRealm.getClients().add(client);

    ClientRepresentation testApp = testRealm.getClients().stream()
            .filter(cl -> cl.getClientId().equals("test-app"))
            .findFirst().get();
    testApp.setImplicitFlowEnabled(true);
    trimRedirectUris(testApp);
}
 
Example 3
Source File: DefaultHostnameTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private void assertInitialAccessTokenFromMasterRealm(Keycloak testAdminClient, String realm, String expectedBaseUrl) throws JWSInputException, ClientRegistrationException {
    ClientInitialAccessCreatePresentation rep = new ClientInitialAccessCreatePresentation();
    rep.setCount(1);
    rep.setExpiration(10000);

    ClientInitialAccessPresentation initialAccess = testAdminClient.realm(realm).clientInitialAccess().create(rep);
    JsonWebToken token = new JWSInput(initialAccess.getToken()).readJsonContent(JsonWebToken.class);
    assertEquals(expectedBaseUrl + "/realms/" + realm, token.getIssuer());

    ClientRegistration clientReg = ClientRegistration.create().url(AUTH_SERVER_ROOT, realm).build();
    clientReg.auth(Auth.token(initialAccess.getToken()));

    ClientRepresentation client = new ClientRepresentation();
    client.setEnabled(true);
    ClientRepresentation response = clientReg.create(client);

    String registrationAccessToken = response.getRegistrationAccessToken();
    JsonWebToken registrationToken = new JWSInput(registrationAccessToken).readJsonContent(JsonWebToken.class);
    assertEquals(expectedBaseUrl + "/realms/" + realm, registrationToken.getIssuer());
}
 
Example 4
Source File: FixedHostnameTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private void assertInitialAccessTokenFromMasterRealm(Keycloak testAdminClient, String realm, String expectedBaseUrl) throws JWSInputException, ClientRegistrationException {
    ClientInitialAccessCreatePresentation rep = new ClientInitialAccessCreatePresentation();
    rep.setCount(1);
    rep.setExpiration(10000);

    ClientInitialAccessPresentation initialAccess = testAdminClient.realm(realm).clientInitialAccess().create(rep);
    JsonWebToken token = new JWSInput(initialAccess.getToken()).readJsonContent(JsonWebToken.class);
    assertEquals(expectedBaseUrl + "/auth/realms/" + realm, token.getIssuer());

    ClientRegistration clientReg = ClientRegistration.create().url(authServerUrl, realm).build();
    clientReg.auth(Auth.token(initialAccess.getToken()));

    ClientRepresentation client = new ClientRepresentation();
    client.setEnabled(true);
    ClientRepresentation response = clientReg.create(client);

    String registrationAccessToken = response.getRegistrationAccessToken();
    JsonWebToken registrationToken = new JWSInput(registrationAccessToken).readJsonContent(JsonWebToken.class);
    assertEquals(expectedBaseUrl + "/auth/realms/" + realm, registrationToken.getIssuer());
}
 
Example 5
Source File: KeycloakTestResource.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private static ClientRepresentation createClient(String clientId) {
    ClientRepresentation client = new ClientRepresentation();

    client.setClientId(clientId);
    client.setPublicClient(false);
    client.setSecret("secret");
    client.setDirectAccessGrantsEnabled(true);
    client.setEnabled(true);

    client.setAuthorizationServicesEnabled(true);

    ResourceServerRepresentation authorizationSettings = new ResourceServerRepresentation();

    authorizationSettings.setResources(new ArrayList<>());
    authorizationSettings.setPolicies(new ArrayList<>());

    configurePermissionResourcePermission(authorizationSettings);
    configureClaimBasedPermission(authorizationSettings);
    configureHttpResponseClaimBasedPermission(authorizationSettings);
    configureBodyClaimBasedPermission(authorizationSettings);
    configurePaths(authorizationSettings);

    client.setAuthorizationSettings(authorizationSettings);

    return client;
}
 
Example 6
Source File: CustomAuthFlowCookieTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Before
@Override
public void beforeTest() {
    super.beforeTest();

    ClientRepresentation testApp = new ClientRepresentation();
    testApp.setClientId("test-app");
    testApp.setEnabled(true);
    testApp.setBaseUrl(APP_ROOT);
    testApp.setRedirectUris(Arrays.asList(new String[]{APP_ROOT + "/*"}));
    testApp.setAdminUrl(APP_ROOT + "/logout");
    testApp.setSecret("password");
    Response response = testRealmResource().clients().create(testApp);
    assertEquals(201, response.getStatus());
    getCleanup().addClientUuid(ApiUtil.getCreatedId(response));
    response.close();
}
 
Example 7
Source File: ClientTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void createClientValidation() {
    ClientRepresentation rep = new ClientRepresentation();
    rep.setClientId("my-app");
    rep.setDescription("my-app description");
    rep.setEnabled(true);

    rep.setRootUrl("invalid");
    createClientExpectingValidationError(rep, "Invalid URL in rootUrl");

    rep.setRootUrl(null);
    rep.setBaseUrl("invalid");
    createClientExpectingValidationError(rep, "Invalid URL in baseUrl");

    rep.setRootUrl(null);
    rep.setBaseUrl("/valid");
    createClientExpectingSuccessfulClientCreation(rep);

    rep.setRootUrl("");
    rep.setBaseUrl("/valid");
    createClientExpectingSuccessfulClientCreation(rep);
}
 
Example 8
Source File: KeycloakRealmResourceManager.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static ClientRepresentation createClient(String clientId) {
    ClientRepresentation client = new ClientRepresentation();

    client.setClientId(clientId);
    client.setPublicClient(false);
    client.setSecret("secret");
    client.setDirectAccessGrantsEnabled(true);
    client.setEnabled(true);

    return client;
}
 
Example 9
Source File: SAMLServletAdapterTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Test
public void disabledClientTest() {
    ClientResource clientResource = ApiUtil.findClientResourceByClientId(testRealmResource(), AbstractSamlTest.SAML_CLIENT_ID_SALES_POST_SIG);
    ClientRepresentation client = clientResource.toRepresentation();
    client.setEnabled(false);
    clientResource.update(client);

    salesPostSigServletPage.navigateTo();
    waitUntilElement(By.xpath("//body")).text().contains("Login requester not enabled");

    client.setEnabled(true);
    clientResource.update(client);
}
 
Example 10
Source File: AdapterInstallationConfigTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Before
@Override
public void before() throws Exception {
    super.before();

    client = new ClientRepresentation();
    client.setEnabled(true);
    client.setClientId("RegistrationAccessTokenTest");
    client.setSecret("RegistrationAccessTokenTestClientSecret");
    client.setPublicClient(false);
    client.setRegistrationAccessToken("RegistrationAccessTokenTestRegistrationAccessToken");
    client.setRootUrl("http://root");
    client = createClient(client);
    client.setSecret("RegistrationAccessTokenTestClientSecret");
    getCleanup().addClientUuid(client.getId());

    client2 = new ClientRepresentation();
    client2.setEnabled(true);
    client2.setClientId("RegistrationAccessTokenTest2");
    client2.setSecret("RegistrationAccessTokenTestClientSecret");
    client2.setPublicClient(false);
    client2.setRegistrationAccessToken("RegistrationAccessTokenTestRegistrationAccessToken");
    client2.setRootUrl("http://root");
    client2 = createClient(client2);
    getCleanup().addClientUuid(client2.getId());

    clientPublic = new ClientRepresentation();
    clientPublic.setEnabled(true);
    clientPublic.setClientId("RegistrationAccessTokenTestPublic");
    clientPublic.setPublicClient(true);
    clientPublic.setRegistrationAccessToken("RegistrationAccessTokenTestRegistrationAccessTokenPublic");
    clientPublic.setRootUrl("http://root");
    clientPublic = createClient(clientPublic);
    getCleanup().addClientUuid(clientPublic.getId());
}
 
Example 11
Source File: BrokerTestTools.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public static void createKcOidcBroker(Keycloak adminClient, String childRealm, String idpRealm, String alias, boolean linkOnly) {
    IdentityProviderRepresentation idp = createIdentityProvider(alias, IDP_OIDC_PROVIDER_ID);
    idp.setLinkOnly(linkOnly);
    idp.setStoreToken(true);

    Map<String, String> config = idp.getConfig();

    config.put("clientId", childRealm);
    config.put("clientSecret", childRealm);
    config.put("authorizationUrl", getProviderRoot() + "/auth/realms/" + idpRealm + "/protocol/openid-connect/auth");
    config.put("tokenUrl", getProviderRoot() + "/auth/realms/" + idpRealm + "/protocol/openid-connect/token");
    config.put("logoutUrl", getProviderRoot() + "/auth/realms/" + idpRealm + "/protocol/openid-connect/logout");
    config.put("userInfoUrl", getProviderRoot() + "/auth/realms/" + idpRealm + "/protocol/openid-connect/userinfo");
    config.put("backchannelSupported", "true");
    adminClient.realm(childRealm).identityProviders().create(idp);

    ClientRepresentation client = new ClientRepresentation();
    client.setClientId(childRealm);
    client.setName(childRealm);
    client.setSecret(childRealm);
    client.setEnabled(true);

    client.setRedirectUris(Collections.singletonList(getConsumerRoot() +
            "/auth/realms/" + childRealm + "/broker/" + idpRealm + "/endpoint/*"));

    client.setAdminUrl(getConsumerRoot() +
            "/auth/realms/" + childRealm + "/broker/" + idpRealm + "/endpoint");
    adminClient.realm(idpRealm).clients().create(client);
}
 
Example 12
Source File: ClientTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Test
public void updateClientValidation() {
    ClientRepresentation rep = createClient();

    rep.setClientId("my-app");
    rep.setDescription("my-app description");
    rep.setEnabled(true);

    rep.setRootUrl("invalid");
    updateClientExpectingValidationError(rep, "Invalid URL in rootUrl");

    rep.setRootUrl(null);
    rep.setBaseUrl("invalid");
    updateClientExpectingValidationError(rep, "Invalid URL in baseUrl");

    ClientRepresentation stored = realm.clients().get(rep.getId()).toRepresentation();
    assertNull(stored.getRootUrl());
    assertNull(stored.getBaseUrl());

    rep.setRootUrl(null);
    rep.setBaseUrl("/valid");
    updateClientExpectingSuccessfulClientUpdate(rep, null, "/valid");

    rep.setRootUrl("");
    rep.setBaseUrl("/valid");
    updateClientExpectingSuccessfulClientUpdate(rep, "", "/valid");
}
 
Example 13
Source File: InvalidationCrossDCTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Test
public void clientListInvalidationTest() throws Exception {
    enableDcOnLoadBalancer(DC.FIRST);
    enableDcOnLoadBalancer(DC.SECOND);

    List<ClientRepresentation> dc0List = getAdminClientForStartedNodeInDc(0).realms().realm(REALM_NAME).clients().findAll();
    List<ClientRepresentation> dc1List = getAdminClientForStartedNodeInDc(1).realms().realm(REALM_NAME).clients().findAll();


    // Test same clients on both DCs
    Assert.assertEquals(dc0List.size(), dc1List.size());
    int initialSize = dc0List.size();

    // Create client on DC0
    ClientRepresentation rep = new ClientRepresentation();
    rep.setClientId("some-new-client");
    rep.setEnabled(true);
    Response response = getAdminClientForStartedNodeInDc(0).realms().realm(REALM_NAME).clients().create(rep);
    Assert.assertEquals(201, response.getStatus());
    response.close();

    // Assert updated on both DC0 and DC1 (here retry is needed. We need to wait until invalidation message arrives)
    dc0List = getAdminClientForStartedNodeInDc(0).realms().realm(REALM_NAME).clients().findAll();
    Assert.assertEquals(initialSize + 1, dc0List.size());

    AtomicInteger i = new AtomicInteger(0);
    Retry.execute(() -> {
        i.incrementAndGet();
        List<ClientRepresentation> dc1Listt = getAdminClientForStartedNodeInDc(1).realms().realm(REALM_NAME).clients().findAll();
        Assert.assertEquals(initialSize + 1, dc1Listt.size());
    }, 50, 50);

    log.infof("clientListInvalidationTest: Passed after '%d' iterations", i.get());
}
 
Example 14
Source File: KeycloakDevModeRealmResourceManager.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static ClientRepresentation createClient(String clientId) {
    ClientRepresentation client = new ClientRepresentation();

    client.setClientId(clientId);
    client.setPublicClient(true);
    client.setDirectAccessGrantsEnabled(true);
    client.setEnabled(true);
    client.setRedirectUris(Arrays.asList("*"));

    return client;
}
 
Example 15
Source File: KeycloakRealmResourceManager.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static ClientRepresentation createClient(String clientId) {
    ClientRepresentation client = new ClientRepresentation();

    client.setClientId(clientId);
    client.setEnabled(true);
    client.setRedirectUris(Arrays.asList("*"));
    client.setClientAuthenticatorType("client-secret");
    client.setSecret("secret");

    return client;
}
 
Example 16
Source File: KeycloakRealmResourceManager.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static ClientRepresentation createClientJwt(String clientId) {
    ClientRepresentation client = new ClientRepresentation();

    client.setClientId(clientId);
    client.setEnabled(true);
    client.setRedirectUris(Arrays.asList("*"));
    client.setClientAuthenticatorType("client-secret-jwt");
    client.setSecret("AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow");

    return client;
}
 
Example 17
Source File: RealmSetup.java    From keycloak-custom-protocol-mapper-example with Apache License 2.0 5 votes vote down vote up
private List<ClientRepresentation> createClients() {
    ClientRepresentation client = new ClientRepresentation();
    client.setEnabled(true);
    // normally you wouldn't do this, but we use the direct grant to be able
    // to fetch the token for demo purposes per curl ;-)
    client.setDirectAccessGrantsEnabled(true);
    client.setId(CLIENT);
    client.setName(CLIENT);
    client.setPublicClient(Boolean.TRUE);
    return Arrays.asList(client);
}
 
Example 18
Source File: ClientBuilder.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public static ClientBuilder create() {
    ClientRepresentation rep = new ClientRepresentation();
    rep.setEnabled(Boolean.TRUE);
    return new ClientBuilder(rep);
}
 
Example 19
Source File: KcOidcBrokerConfiguration.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public List<ClientRepresentation> createProviderClients() {
    ClientRepresentation client = new ClientRepresentation();
    client.setId(CLIENT_ID);
    client.setClientId(getIDPClientIdInProviderRealm());
    client.setName(CLIENT_ID);
    client.setSecret(CLIENT_SECRET);
    client.setEnabled(true);

    client.setRedirectUris(Collections.singletonList(getConsumerRoot() +
            "/auth/realms/" + REALM_CONS_NAME + "/broker/" + IDP_OIDC_ALIAS + "/endpoint/*"));

    client.setAdminUrl(getConsumerRoot() +
            "/auth/realms/" + REALM_CONS_NAME + "/broker/" + IDP_OIDC_ALIAS + "/endpoint");

    ProtocolMapperRepresentation emailMapper = new ProtocolMapperRepresentation();
    emailMapper.setName("email");
    emailMapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    emailMapper.setProtocolMapper(UserPropertyMapper.PROVIDER_ID);

    Map<String, String> emailMapperConfig = emailMapper.getConfig();
    emailMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, "email");
    emailMapperConfig.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, "email");
    emailMapperConfig.put(OIDCAttributeMapperHelper.JSON_TYPE, ProviderConfigProperty.STRING_TYPE);
    emailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    emailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    emailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_USERINFO, "true");

    ProtocolMapperRepresentation nestedAttrMapper = new ProtocolMapperRepresentation();
    nestedAttrMapper.setName("attribute - nested claim");
    nestedAttrMapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    nestedAttrMapper.setProtocolMapper(UserAttributeMapper.PROVIDER_ID);

    Map<String, String> nestedEmailMapperConfig = nestedAttrMapper.getConfig();
    nestedEmailMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, "nested.email");
    nestedEmailMapperConfig.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, "nested.email");
    nestedEmailMapperConfig.put(OIDCAttributeMapperHelper.JSON_TYPE, ProviderConfigProperty.STRING_TYPE);
    nestedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    nestedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    nestedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_USERINFO, "true");

    ProtocolMapperRepresentation dottedAttrMapper = new ProtocolMapperRepresentation();
    dottedAttrMapper.setName("attribute - claim with dot in name");
    dottedAttrMapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    dottedAttrMapper.setProtocolMapper(UserAttributeMapper.PROVIDER_ID);

    Map<String, String> dottedEmailMapperConfig = dottedAttrMapper.getConfig();
    dottedEmailMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, "dotted.email");
    dottedEmailMapperConfig.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, "dotted\\.email");
    dottedEmailMapperConfig.put(OIDCAttributeMapperHelper.JSON_TYPE, ProviderConfigProperty.STRING_TYPE);
    dottedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    dottedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    dottedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_USERINFO, "true");

    ProtocolMapperRepresentation userAttrMapper = new ProtocolMapperRepresentation();
    userAttrMapper.setName("attribute - name");
    userAttrMapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    userAttrMapper.setProtocolMapper(UserAttributeMapper.PROVIDER_ID);

    Map<String, String> userAttrMapperConfig = userAttrMapper.getConfig();
    userAttrMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, ATTRIBUTE_TO_MAP_NAME);
    userAttrMapperConfig.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, ATTRIBUTE_TO_MAP_NAME);
    userAttrMapperConfig.put(OIDCAttributeMapperHelper.JSON_TYPE, ProviderConfigProperty.STRING_TYPE);
    userAttrMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    userAttrMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    userAttrMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_USERINFO, "true");
    userAttrMapperConfig.put(ProtocolMapperUtils.MULTIVALUED, "true");

    ProtocolMapperRepresentation userAttrMapper2 = new ProtocolMapperRepresentation();
    userAttrMapper2.setName("attribute - name - 2");
    userAttrMapper2.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    userAttrMapper2.setProtocolMapper(UserAttributeMapper.PROVIDER_ID);

    Map<String, String> userAttrMapperConfig2 = userAttrMapper2.getConfig();
    userAttrMapperConfig2.put(ProtocolMapperUtils.USER_ATTRIBUTE, ATTRIBUTE_TO_MAP_NAME_2);
    userAttrMapperConfig2.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, ATTRIBUTE_TO_MAP_NAME_2);
    userAttrMapperConfig2.put(OIDCAttributeMapperHelper.JSON_TYPE, ProviderConfigProperty.STRING_TYPE);
    userAttrMapperConfig2.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    userAttrMapperConfig2.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    userAttrMapperConfig2.put(OIDCAttributeMapperHelper.INCLUDE_IN_USERINFO, "true");
    userAttrMapperConfig2.put(ProtocolMapperUtils.MULTIVALUED, "true");

    ProtocolMapperRepresentation hardcodedJsonClaim = new ProtocolMapperRepresentation();
    hardcodedJsonClaim.setName("json-mapper");
    hardcodedJsonClaim.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    hardcodedJsonClaim.setProtocolMapper(HardcodedClaim.PROVIDER_ID);

    Map<String, String> hardcodedJsonClaimMapperConfig = hardcodedJsonClaim.getConfig();
    hardcodedJsonClaimMapperConfig.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, KcOidcBrokerConfiguration.USER_INFO_CLAIM);
    hardcodedJsonClaimMapperConfig.put(OIDCAttributeMapperHelper.JSON_TYPE, "JSON");
    hardcodedJsonClaimMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    hardcodedJsonClaimMapperConfig.put(HardcodedClaim.CLAIM_VALUE, "{\"" + HARDOCDED_CLAIM + "\": \"" + HARDOCDED_VALUE + "\"}");

    client.setProtocolMappers(Arrays.asList(emailMapper, userAttrMapper, userAttrMapper2, nestedAttrMapper, dottedAttrMapper, hardcodedJsonClaim));

    return Collections.singletonList(client);
}
 
Example 20
Source File: ClientBuilder.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public static ClientBuilder create(String clientId) {
    ClientRepresentation rep = new ClientRepresentation();
    rep.setEnabled(Boolean.TRUE);
    rep.setClientId(clientId);
    return new ClientBuilder(rep);
}