Search in sources :

Example 1 with KeycloakContext

use of org.dcm4chee.arc.keycloak.KeycloakContext in project dcm4chee-arc-light by dcm4che.

the class WadoURI method validateWebApp.

private void validateWebApp() {
    WebApplication webApplication = device.getWebApplications().stream().filter(webApp -> request.getRequestURI().startsWith(webApp.getServicePath()) && Arrays.asList(webApp.getServiceClasses()).contains(WebApplication.ServiceClass.WADO_URI)).findFirst().orElseThrow(() -> new WebApplicationException(errResponse("No Web Application with WADO_URI service class found for Application Entity: " + aet, Response.Status.NOT_FOUND)));
    KeycloakContext keycloakContext = KeycloakContext.valueOf(request);
    if (keycloakContext.isSecured() && webApplication.getProperties().containsKey("roles"))
        Arrays.stream(webApplication.getProperties().get("roles").split(",")).filter(keycloakContext::isUserInRole).findFirst().orElseThrow(() -> new WebApplicationException(errResponse("Web Application with WADO_URI service class does not list role of accessing user", Response.Status.FORBIDDEN)));
}
Also used : KeycloakContext(org.dcm4chee.arc.keycloak.KeycloakContext)

Example 2 with KeycloakContext

use of org.dcm4chee.arc.keycloak.KeycloakContext in project dcm4chee-arc-light by dcm4che.

the class WadoRS method validateWebApp.

private void validateWebApp() {
    WebApplication webApplication = device.getWebApplications().stream().filter(webApp -> request.getRequestURI().startsWith(webApp.getServicePath()) && Arrays.asList(webApp.getServiceClasses()).contains(WebApplication.ServiceClass.WADO_RS)).findFirst().orElseThrow(() -> new WebApplicationException(errResponse("No Web Application with WADO_RS service class found for Application Entity: " + aet, Response.Status.NOT_FOUND)));
    KeycloakContext keycloakContext = KeycloakContext.valueOf(request);
    if (keycloakContext.isSecured() && webApplication.getProperties().containsKey("roles"))
        Arrays.stream(webApplication.getProperties().get("roles").split(",")).filter(keycloakContext::isUserInRole).findFirst().orElseThrow(() -> new WebApplicationException(errResponse("Web Application with WADO_RS service class does not list role of accessing user", Response.Status.FORBIDDEN)));
}
Also used : KeycloakContext(org.dcm4chee.arc.keycloak.KeycloakContext) WebApplication(org.dcm4che3.net.WebApplication)

Example 3 with KeycloakContext

use of org.dcm4chee.arc.keycloak.KeycloakContext in project dcm4chee-arc-light by dcm4che.

the class StowRS method validateWebApp.

private void validateWebApp() {
    WebApplication webApplication = device.getWebApplications().stream().filter(webApp -> request.getRequestURI().startsWith(webApp.getServicePath()) && Arrays.asList(webApp.getServiceClasses()).contains(WebApplication.ServiceClass.STOW_RS)).findFirst().orElseThrow(() -> new WebApplicationException(errResponse("No Web Application with STOW_RS service class found for Application Entity: " + aet, Response.Status.NOT_FOUND)));
    KeycloakContext keycloakContext = KeycloakContext.valueOf(request);
    if (keycloakContext.isSecured() && webApplication.getProperties().containsKey("roles"))
        Arrays.stream(webApplication.getProperties().get("roles").split(",")).filter(keycloakContext::isUserInRole).findFirst().orElseThrow(() -> new WebApplicationException(errResponse("Web Application with STOW_RS service class does not list role of accessing user", Response.Status.FORBIDDEN)));
}
Also used : KeycloakContext(org.dcm4chee.arc.keycloak.KeycloakContext) WebApplication(org.dcm4che3.net.WebApplication)

Example 4 with KeycloakContext

use of org.dcm4chee.arc.keycloak.KeycloakContext in project dcm4chee-arc-light by dcm4che.

the class QidoRS method validateWebApp.

private void validateWebApp() {
    WebApplication webApplication = device.getWebApplications().stream().filter(webApp -> request.getRequestURI().startsWith(webApp.getServicePath()) && Arrays.asList(webApp.getServiceClasses()).contains(WebApplication.ServiceClass.QIDO_RS)).findFirst().orElseThrow(() -> new WebApplicationException(errResponse("No Web Application with QIDO_RS service class found for Application Entity: " + aet, Response.Status.NOT_FOUND)));
    KeycloakContext keycloakContext = KeycloakContext.valueOf(request);
    if (keycloakContext.isSecured() && webApplication.getProperties().containsKey("roles"))
        Arrays.stream(webApplication.getProperties().get("roles").split(",")).filter(keycloakContext::isUserInRole).findFirst().orElseThrow(() -> new WebApplicationException(errResponse("Web Application with QIDO_RS service class does not list role of accessing user", Response.Status.FORBIDDEN)));
}
Also used : KeycloakContext(org.dcm4chee.arc.keycloak.KeycloakContext) WebApplication(org.dcm4che3.net.WebApplication)

Aggregations

KeycloakContext (org.dcm4chee.arc.keycloak.KeycloakContext)4 WebApplication (org.dcm4che3.net.WebApplication)3