Java Code Examples for org.keycloak.services.messages.Messages#CLIENT_DISABLED

The following examples show how to use org.keycloak.services.messages.Messages#CLIENT_DISABLED . 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: AuthorizationEndpoint.java    From keycloak-protocol-cas with Apache License 2.0 5 votes vote down vote up
private void checkClient(String service) {
    if (service == null) {
        event.error(Errors.INVALID_REQUEST);
        throw new ErrorPageException(session, Response.Status.BAD_REQUEST, Messages.MISSING_PARAMETER, CASLoginProtocol.SERVICE_PARAM);
    }

    client = realm.getClients().stream()
            .filter(c -> CASLoginProtocol.LOGIN_PROTOCOL.equals(c.getProtocol()))
            .filter(c -> RedirectUtils.verifyRedirectUri(session.getContext().getUri(), service, realm, c) != null)
            .findFirst().orElse(null);
    if (client == null) {
        event.error(Errors.CLIENT_NOT_FOUND);
        throw new ErrorPageException(session, Response.Status.BAD_REQUEST, Messages.CLIENT_NOT_FOUND);
    }

    if (!client.isEnabled()) {
        event.error(Errors.CLIENT_DISABLED);
        throw new ErrorPageException(session, Response.Status.BAD_REQUEST, Messages.CLIENT_DISABLED);
    }

    redirectUri = RedirectUtils.verifyRedirectUri(session.getContext().getUri(), service, realm, client);

    event.client(client.getClientId());
    event.detail(Details.REDIRECT_URI, redirectUri);

    session.getContext().setClient(client);
}
 
Example 2
Source File: AuthorizationEndpoint.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void checkClient(String clientId) {
    if (clientId == null) {
        event.error(Errors.INVALID_REQUEST);
        throw new ErrorPageException(session, authenticationSession, Response.Status.BAD_REQUEST, Messages.MISSING_PARAMETER, OIDCLoginProtocol.CLIENT_ID_PARAM);
    }

    event.client(clientId);

    client = realm.getClientByClientId(clientId);
    if (client == null) {
        event.error(Errors.CLIENT_NOT_FOUND);
        throw new ErrorPageException(session, authenticationSession, Response.Status.BAD_REQUEST, Messages.CLIENT_NOT_FOUND);
    }

    if (!client.isEnabled()) {
        event.error(Errors.CLIENT_DISABLED);
        throw new ErrorPageException(session, authenticationSession, Response.Status.BAD_REQUEST, Messages.CLIENT_DISABLED);
    }

    if (client.isBearerOnly()) {
        event.error(Errors.NOT_ALLOWED);
        throw new ErrorPageException(session, authenticationSession, Response.Status.FORBIDDEN, Messages.BEARER_ONLY);
    }

    String protocol = client.getProtocol();
    if (protocol == null) {
        logger.warnf("Client '%s' doesn't have protocol set. Fallback to openid-connect. Please fix client configuration", clientId);
        protocol = OIDCLoginProtocol.LOGIN_PROTOCOL;
    }
    if (!protocol.equals(OIDCLoginProtocol.LOGIN_PROTOCOL)) {
        event.error(Errors.INVALID_CLIENT);
        throw new ErrorPageException(session, authenticationSession, Response.Status.BAD_REQUEST, "Wrong client protocol.");
    }

    session.getContext().setClient(client);
}