public interface SecurityContext
Security.contextBuilder(String) and to handle programmatic security.| Modifier and Type | Interface and Description |
|---|---|
static class |
SecurityContext.Builder
Fluent API builder for
SecurityContext. |
| Modifier and Type | Field and Description |
|---|---|
static Subject |
ANONYMOUS
Anonymous subject.
|
static Principal |
ANONYMOUS_PRINCIPAL
Anonymous user principal.
|
| Modifier and Type | Method and Description |
|---|---|
SecurityClientBuilder<AuthenticationResponse> |
atnClientBuilder()
Authenticator client builder to use for programmatic authentication.
|
boolean |
atzChecked()
Return true if either of authorization methods (
authorize(Object...) or atzClientBuilder()
was called). |
SecurityClientBuilder<AuthorizationResponse> |
atzClientBuilder()
Authorization client builder to use for programmatic authorization.
|
void |
audit(AuditEvent event)
Audit a security event.
|
AuthenticationResponse |
authenticate()
Authenticate current request (based on current
SecurityEnvironment and EndpointConfig. |
AuthorizationResponse |
authorize(Object... resource)
Authorize access to a resource (or more resources) based on current environment and endpoint configuration.
|
EndpointConfig |
endpointConfig()
Current endpoint configuration.
|
void |
endpointConfig(EndpointConfig ec)
Set endpoint configuration to use for subsequent security requests.
|
default void |
endpointConfig(Supplier<EndpointConfig> epBuilder)
Shortcut method to set
EndpointConfig using a builder rather than built instance. |
SecurityEnvironment |
env()
Current
SecurityEnvironment. |
void |
env(SecurityEnvironment env)
Set a new security environment to be used in this context.
|
default void |
env(Supplier<SecurityEnvironment> envBuilder)
Set a new security environment to be used int this context.
|
ExecutorService |
executorService()
Executor service of the security module.
|
String |
id()
Id of this context instance.
|
boolean |
isAuthenticated()
Return true if the user is authenticated.
|
boolean |
isUserInRole(String role)
Check if user is in specified role if supported by global authorization provider.
|
boolean |
isUserInRole(String role,
String authorizerName)
Check if user is in specified role if supported by global or specific authorization provider.
|
void |
logout()
Logout user, clear current security context.
|
OutboundSecurityClientBuilder |
outboundClientBuilder()
Outbound security client builder for programmatic outbound security used for identity propagation, identity mapping,
encryption of outbound calls etc.
|
void |
runAs(String role,
Runnable runnable)
Execute provided code as current user with an additional explicit role added.
|
void |
runAs(Subject subject,
Runnable runnable)
Executes provided code under provided subject.
|
SecurityRequestBuilder<?> |
securityRequestBuilder()
A builder to build a
SecurityRequest. |
SecurityRequestBuilder<?> |
securityRequestBuilder(SecurityEnvironment environment)
A builder to build a
SecurityRequest with a specific environment. |
SecurityTime |
serverTime()
Get time instance, that can be used to obtain current time consistent with the security framework.
|
Optional<Subject> |
service()
Returns subject of current context (caller) service or client identity.
|
default String |
serviceName()
A helper method to get service name if authenticated.
|
default Optional<Principal> |
servicePrincipal()
Returns service principal if service is authenticated.
|
Tracer |
tracer()
Provides the tracer to create new spans.
|
SpanContext |
tracingSpan()
Provides the span for tracing.
|
Optional<Subject> |
user()
Returns subject of current context (caller) user.
|
default String |
userName()
A helper method to get user name if authenticated.
|
default Optional<Principal> |
userPrincipal()
Returns user principal if user is authenticated.
|
static final Principal ANONYMOUS_PRINCIPAL
ANONYMOUS.static final Subject ANONYMOUS
SecurityRequestBuilder<?> securityRequestBuilder()
SecurityRequest.SecurityRequestBuilder<?> securityRequestBuilder(SecurityEnvironment environment)
SecurityRequest with a specific environment.environment - environment to use for this requestSecurityClientBuilder<AuthenticationResponse> atnClientBuilder()
SecurityClient instance providing AuthenticationResponseAuthenticationResponse authenticate()
SecurityEnvironment and EndpointConfig.SecurityClientBuilder<AuthorizationResponse> atzClientBuilder()
SecurityClient instance providing AuthorizationResponseOutboundSecurityClientBuilder outboundClientBuilder()
SecurityClient instance providing OutboundSecurityResponseAuthorizationResponse authorize(Object... resource)
resource - resources to authorize access to (may be empty)boolean isAuthenticated()
service() and check the resulting optional.ANONYMOUS)void logout()
boolean isUserInRole(String role, String authorizerName)
role - Role to checkauthorizerName - explicit authorization provider class name to use (or config property pointing to class name)ExecutorService executorService()
boolean isUserInRole(String role)
isUserInRole(String, String) instead.role - Role to checkvoid audit(AuditEvent event)
event - AuditEvent to storeOptional<Subject> service()
default Optional<Principal> servicePrincipal()
default String serviceName()
Optional<Subject> user()
default Optional<Principal> userPrincipal()
default String userName()
void runAs(Subject subject, Runnable runnable)
subject - to use for execution. Use ANONYMOUS for anon.runnable - to execute.void runAs(String role, Runnable runnable)
role - name of rolerunnable - to executeSpanContext tracingSpan()
Tracer tracer()
GlobalTracer.get() you will get around this.Tracer to build custom Spans. Use in combination with tracingSpan() to
create a nice tree of spansString id()
SecurityTime serverTime()
SecurityEnvironment.SecurityTime.get()SecurityEnvironment env()
SecurityEnvironment. For web, this probably won't change, as the environment
is valid for whole request. For other frameworks or standalone applications, this may change
over time.default void env(Supplier<SecurityEnvironment> envBuilder)
envBuilder - builder to build environment fromSecurityEnvironment.derive(),
SecurityEnvironment.builder(SecurityTime)void env(SecurityEnvironment env)
env - environment to use for further security operationsSecurityEnvironment.derive()EndpointConfig endpointConfig()
void endpointConfig(EndpointConfig ec)
ec - configuration specific to current endpoint (annotations, config, custom object, attributes)default void endpointConfig(Supplier<EndpointConfig> epBuilder)
EndpointConfig using a builder rather than built instance.
Shortcut to endpointConfig(EndpointConfig)epBuilder - builder of an endpoint configurationboolean atzChecked()
authorize(Object...) or atzClientBuilder()
was called).
This is a safe-guard for attribute based authorization that is using annotations and requires object to be passed
for evaluation.Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.