All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.canoo.dp.impl.server.security.SecurityContextKeycloakImpl Maven / Gradle / Ivy

Go to download

The Dolphin Platform is a framework that implements the presentation model pattern and provides amodern way to create enterprise applications. The Platform provides several client implementations that all canbe used in combination with a general sever API.

There is a newer version: 1.0.0.CR5
Show newest version
package com.canoo.dp.impl.server.security;

import com.canoo.platform.server.security.SecurityContext;
import com.canoo.platform.server.security.SecurityException;
import com.canoo.platform.server.security.User;
import org.keycloak.KeycloakSecurityContext;

import java.util.Optional;

public class SecurityContextKeycloakImpl implements SecurityContext {

    private final User user;

    private final AccessDeniedCallback accessDeniedCallback;

    public SecurityContextKeycloakImpl(final KeycloakSecurityContext keycloakSecurityContext, final AccessDeniedCallback accessDeniedCallback) {
        this.user = Optional.ofNullable(keycloakSecurityContext).map(c -> new UserKeycloakImpl(keycloakSecurityContext)).orElse(null);
        this.accessDeniedCallback = accessDeniedCallback;
    }

    @Override
    public User getUser() {
        return user;
    }

    @Override
    public void accessDenied() {
        try {
            accessDeniedCallback.onAccessDenied();
        } finally {
            throw new SecurityException("Access Denied");
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy