com.canoo.dp.impl.server.security.SecurityContextKeycloakImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dolphin-platform-security-server Show documentation
Show all versions of dolphin-platform-security-server Show documentation
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.
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