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

The following examples show how to use org.keycloak.representations.idm.ClientRepresentation#isStandardFlowEnabled() . 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: DescriptionConverter.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private static List<String> getOIDCResponseTypes(ClientRepresentation client) {
    List<String> responseTypes = new ArrayList<>();
    if (client.isStandardFlowEnabled()) {
        responseTypes.add(OAuth2Constants.CODE);
        responseTypes.add(OIDCResponseType.NONE);
    }
    if (client.isImplicitFlowEnabled()) {
        responseTypes.add(OIDCResponseType.ID_TOKEN);
        responseTypes.add("id_token token");
    }
    if (client.isStandardFlowEnabled() && client.isImplicitFlowEnabled()) {
        responseTypes.add("code id_token");
        responseTypes.add("code token");
        responseTypes.add("code id_token token");
    }
    return responseTypes;
}
 
Example 2
Source File: DescriptionConverter.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private static List<String> getOIDCGrantTypes(ClientRepresentation client) {
    List<String> grantTypes = new ArrayList<>();
    if (client.isStandardFlowEnabled()) {
        grantTypes.add(OAuth2Constants.AUTHORIZATION_CODE);
    }
    if (client.isImplicitFlowEnabled()) {
        grantTypes.add(OAuth2Constants.IMPLICIT);
    }
    if (client.isDirectAccessGrantsEnabled()) {
        grantTypes.add(OAuth2Constants.PASSWORD);
    }
    if (client.isServiceAccountsEnabled()) {
        grantTypes.add(OAuth2Constants.CLIENT_CREDENTIALS);
    }
    if (client.getAuthorizationServicesEnabled() != null && client.getAuthorizationServicesEnabled()) {
        grantTypes.add(OAuth2Constants.UMA_GRANT_TYPE);
    }
    grantTypes.add(OAuth2Constants.REFRESH_TOKEN);
    return grantTypes;
}
 
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);
}
 
Example 4
Source File: SamlProtocolFactory.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public void setupClientDefaults(ClientRepresentation clientRep, ClientModel newClient) {
    SamlRepresentationAttributes rep = new SamlRepresentationAttributes(clientRep.getAttributes());
    SamlClient client = new SamlClient(newClient);
    if (clientRep.isStandardFlowEnabled() == null) newClient.setStandardFlowEnabled(true);
    if (rep.getCanonicalizationMethod() == null) {
        client.setCanonicalizationMethod(CanonicalizationMethod.EXCLUSIVE);
    }
    if (rep.getSignatureAlgorithm() == null) {
        client.setSignatureAlgorithm(SignatureAlgorithm.RSA_SHA256);
    }

    if (rep.getNameIDFormat() == null) {
        client.setNameIDFormat("username");
    }

    if (rep.getIncludeAuthnStatement() == null) {
        client.setIncludeAuthnStatement(true);
    }

    if (rep.getForceNameIDFormat() == null) {
        client.setForceNameIDFormat(false);
    }

    if (rep.getSamlServerSignature() == null) {
        client.setRequiresRealmSignature(true);
    }
    if (rep.getForcePostBinding() == null) {
        client.setForcePostBinding(true);
    }

    if (rep.getClientSignature() == null) {
        client.setRequiresClientSignature(true);
    }

    if (client.requiresClientSignature() && client.getClientSigningCertificate() == null) {
        CertificateRepresentation info = KeycloakModelUtils.generateKeyPairCertificate(newClient.getClientId());
        client.setClientSigningCertificate(info.getCertificate());
        client.setClientSigningPrivateKey(info.getPrivateKey());

    }

    if (clientRep.isFrontchannelLogout() == null) {
        newClient.setFrontchannelLogout(true);
    }
}