io.inverno.mod.security.http.context.DelegatingSecurityContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of inverno-security-http Show documentation
Show all versions of inverno-security-http Show documentation
Inverno security HTTP module
The newest version!
/*
* Copyright 2022 Jeremy Kuhn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.inverno.mod.security.http.context;
import io.inverno.mod.security.accesscontrol.AccessController;
import io.inverno.mod.security.authentication.Authentication;
import io.inverno.mod.security.identity.Identity;
import java.util.Optional;
/**
*
* A security exchange context that delegates to a regular security context to return authentication, identity and access controller.
*
*
* @author Jeremy Kuhn
* @since 1.5
*
* @param the identity type
* @param the access controller type
*/
interface DelegatingSecurityContext extends SecurityContext {
@Override
public default Authentication getAuthentication() {
var ctx = this.getSecurityContext();
if(ctx != null) {
return ctx.getAuthentication();
}
return SecurityContext.super.getAuthentication();
}
@Override
@SuppressWarnings("unchecked")
default Optional getIdentity() {
var ctx = this.getSecurityContext();
if(ctx != null) {
return (Optional) ctx.getIdentity();
}
return SecurityContext.super.getIdentity();
}
@Override
@SuppressWarnings("unchecked")
default Optional getAccessController() {
var ctx = this.getSecurityContext();
if(ctx != null) {
return (Optional) ctx.getAccessController();
}
return SecurityContext.super.getAccessController();
}
/**
*
* Returns the underlying security context.
*
*
* @return a regular security context
*/
io.inverno.mod.security.context.SecurityContext extends A, ? extends B> getSecurityContext();
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy