Search in sources :

Example 1 with UmaErrorResponse

use of org.xdi.oxauth.model.uma.UmaErrorResponse in project oxAuth by GluuFederation.

the class ErrorResponseFactory method getUmaErrorResponse.

public UmaErrorResponse getUmaErrorResponse(IErrorType type) {
    final UmaErrorResponse response = new UmaErrorResponse();
    final ErrorMessage errorMessage = getError(messages.getUma(), type);
    response.setError(errorMessage.getId());
    response.setErrorDescription(errorMessage.getDescription());
    response.setErrorUri(errorMessage.getUri());
    return response;
}
Also used : UmaErrorResponse(org.xdi.oxauth.model.uma.UmaErrorResponse)

Example 2 with UmaErrorResponse

use of org.xdi.oxauth.model.uma.UmaErrorResponse in project oxAuth by GluuFederation.

the class ErrorResponseFactory method getUmaJsonErrorResponse.

public String getUmaJsonErrorResponse(IErrorType type) {
    final UmaErrorResponse response = getUmaErrorResponse(type);
    JSONObject jsonObj = new JSONObject();
    try {
        jsonObj.put("error", response.getError());
        if (StringHelper.isNotEmpty(response.getStatus())) {
            jsonObj.put("status", response.getStatus());
        }
        if (StringHelper.isNotEmpty(response.getErrorDescription())) {
            jsonObj.put("error_description", response.getErrorDescription());
        }
        if (StringHelper.isNotEmpty(response.getErrorUri())) {
            jsonObj.put("error_uri", response.getErrorUri());
        }
    } catch (JSONException ex) {
        log.error("Failed to generate error response", ex);
        return null;
    }
    return jsonObj.toString();
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) JSONException(org.codehaus.jettison.json.JSONException) UmaErrorResponse(org.xdi.oxauth.model.uma.UmaErrorResponse)

Aggregations

UmaErrorResponse (org.xdi.oxauth.model.uma.UmaErrorResponse)2 JSONException (org.codehaus.jettison.json.JSONException)1 JSONObject (org.codehaus.jettison.json.JSONObject)1