Java Code Examples for org.keycloak.models.ClientModel#setManagementUrl()

The following examples show how to use org.keycloak.models.ClientModel#setManagementUrl() . 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: ClientModelTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private ClientModel setUpClient(RealmModel realm) {
    ClientModel client = realm.addClient("application");
    client.setName("Application");
    client.setDescription("Description");
    client.setBaseUrl("http://base");
    client.setManagementUrl("http://management");
    client.setClientId("app-name");
    client.setProtocol("openid-connect");
    client.addRole("role-1");
    client.addRole("role-2");
    client.addRole("role-3");
    client.addDefaultRole("role-1");
    client.addDefaultRole("role-2");
    client.addRedirectUri("redirect-1");
    client.addRedirectUri("redirect-2");
    client.addWebOrigin("origin-1");
    client.addWebOrigin("origin-2");
    client.registerNode("node1", 10);
    client.registerNode("10.20.30.40", 50);
    client.addProtocolMapper(AddressMapper.createAddressMapper());
    client.updateClient();
    return client;
}
 
Example 2
Source File: CASLoginProtocolFactory.java    From keycloak-protocol-cas with Apache License 2.0 5 votes vote down vote up
@Override
public void setupClientDefaults(ClientRepresentation rep, ClientModel newClient) {
    if (rep.getRootUrl() != null && (rep.getRedirectUris() == null || rep.getRedirectUris().isEmpty())) {
        String root = rep.getRootUrl();
        if (root.endsWith("/")) root = root + "*";
        else root = root + "/*";
        newClient.addRedirectUri(root);
    }

    if (rep.getAdminUrl() == null && rep.getRootUrl() != null) {
        newClient.setManagementUrl(rep.getRootUrl());
    }
}
 
Example 3
Source File: OIDCLoginProtocolFactory.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void setupClientDefaults(ClientRepresentation rep, ClientModel newClient) {
    if (rep.getRootUrl() != null && (rep.getRedirectUris() == null || rep.getRedirectUris().isEmpty())) {
        String root = rep.getRootUrl();
        if (root.endsWith("/")) root = root + "*";
        else root = root + "/*";
        newClient.addRedirectUri(root);

        Set<String> origins = new HashSet<String>();
        String origin = UriUtils.getOrigin(root);
        logger.debugv("adding default client origin: {0}" , origin);
        origins.add(origin);
        newClient.setWebOrigins(origins);
    }
    if (rep.isBearerOnly() == null
            && rep.isPublicClient() == null) {
        newClient.setPublicClient(true);
    }
    if (rep.isBearerOnly() == null) newClient.setBearerOnly(false);
    if (rep.getAdminUrl() == null && rep.getRootUrl() != null) {
        newClient.setManagementUrl(rep.getRootUrl());
    }


    // Backwards compatibility only
    if (rep.isDirectGrantsOnly() != null) {
        ServicesLogger.LOGGER.usingDeprecatedDirectGrantsOnly();
        newClient.setStandardFlowEnabled(!rep.isDirectGrantsOnly());
        newClient.setDirectAccessGrantsEnabled(rep.isDirectGrantsOnly());
    } else {
        if (rep.isStandardFlowEnabled() == null) newClient.setStandardFlowEnabled(true);
        if (rep.isDirectAccessGrantsEnabled() == null) newClient.setDirectAccessGrantsEnabled(true);

    }

    if (rep.isImplicitFlowEnabled() == null) newClient.setImplicitFlowEnabled(false);
    if (rep.isPublicClient() == null) newClient.setPublicClient(true);
    if (rep.isFrontchannelLogout() == null) newClient.setFrontchannelLogout(false);
}