public interface SecurityContext
Security.contextBuilder(String) and to handle programmatic security.| Modifier and Type | Interface | Description |
|---|---|---|
static class |
SecurityContext.Builder |
Fluent API builder for
SecurityContext. |
| Modifier and Type | Field | Description |
|---|---|---|
static Subject |
ANONYMOUS |
Anonymous subject.
|
static Principal |
ANONYMOUS_PRINCIPAL |
Anonymous user principal.
|
| Modifier and Type | Method | 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(java.lang.Object... resource) |
Authorize access to a resource (or more resources) based on current environment and endpoint configuration.
|
EndpointConfig |
getEndpointConfig() |
Current endpoint configuration.
|
SecurityEnvironment |
getEnv() |
Current
SecurityEnvironment. |
java.util.concurrent.ExecutorService |
getExecutorService() |
Executor service of the security module.
|
java.lang.String |
getId() |
Id of this context instance.
|
SecurityTime |
getServerTime() |
Get time instance, that can be used to obtain current time consistent with the security framework.
|
java.util.Optional<Subject> |
getService() |
Returns subject of current context (caller) service or client identity.
|
default java.lang.String |
getServiceName() |
A helper method to get service name if authenticated.
|
default java.util.Optional<Principal> |
getServicePrincipal() |
Returns service principal if service is authenticated.
|
io.opentracing.Tracer |
getTracer() |
Provides the tracer to create new spans.
|
io.opentracing.SpanContext |
getTracingSpan() |
Provides the span for tracing.
|
java.util.Optional<Subject> |
getUser() |
Returns subject of current context (caller) user.
|
default java.lang.String |
getUserName() |
A helper method to get user name if authenticated.
|
default java.util.Optional<Principal> |
getUserPrincipal() |
Returns user principal if user is authenticated.
|
boolean |
isAuthenticated() |
Return true if the user is authenticated.
|
boolean |
isUserInRole(java.lang.String role) |
Check if user is in specified role if supported by global authorization provider.
|
boolean |
isUserInRole(java.lang.String role,
java.lang.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(Subject subject,
java.lang.Runnable runnable) |
Executes provided code under provided subject.
|
void |
runAs(java.lang.String role,
java.lang.Runnable runnable) |
Execute provided code as current user with an additional explicit role added.
|
SecurityRequestBuilder |
securityRequestBuilder() |
A builder to build a
SecurityRequest. |
SecurityRequestBuilder |
securityRequestBuilder(SecurityEnvironment environment) |
A builder to build a
SecurityRequest with a specific environment. |
default void |
setEndpointConfig(Builder<EndpointConfig> epBuilder) |
Shortcut method to set
EndpointConfig using a builder rather than built instance. |
void |
setEndpointConfig(EndpointConfig ec) |
Set endpoint configuration to use for subsequent security requests.
|
default void |
setEnv(Builder<SecurityEnvironment> envBuilder) |
Set a new security environment to be used int this context.
|
void |
setEnv(SecurityEnvironment env) |
Set a new security environment to be used in this context.
|
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(java.lang.Object... resource)
resource - resources to authorize access to (may be empty)boolean isAuthenticated()
getService() and check the resulting optional.ANONYMOUS)void logout()
boolean isUserInRole(java.lang.String role,
java.lang.String authorizerName)
role - Role to checkauthorizerName - explicit authorization provider class name to use (or config property pointing to class name)java.util.concurrent.ExecutorService getExecutorService()
boolean isUserInRole(java.lang.String role)
isUserInRole(String, String) instead.role - Role to checkvoid audit(AuditEvent event)
event - AuditEvent to storejava.util.Optional<Subject> getService()
default java.util.Optional<Principal> getServicePrincipal()
default java.lang.String getServiceName()
java.util.Optional<Subject> getUser()
default java.util.Optional<Principal> getUserPrincipal()
default java.lang.String getUserName()
void runAs(Subject subject, java.lang.Runnable runnable)
subject - to use for execution. Use ANONYMOUS for anon.runnable - to execute.void runAs(java.lang.String role,
java.lang.Runnable runnable)
role - name of rolerunnable - to executeio.opentracing.SpanContext getTracingSpan()
io.opentracing.Tracer getTracer()
GlobalTracer.get() you will get around this.Tracer to build custom Spans. Use in combination with getTracingSpan() to
create a nice tree of spansjava.lang.String getId()
SecurityTime getServerTime()
SecurityEnvironment.SecurityTime.get()SecurityEnvironment getEnv()
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 setEnv(Builder<SecurityEnvironment> envBuilder)
envBuilder - builder to build environment fromSecurityEnvironment.derive(),
SecurityEnvironment.builder(SecurityTime)void setEnv(SecurityEnvironment env)
env - environment to use for further security operationsSecurityEnvironment.derive()EndpointConfig getEndpointConfig()
void setEndpointConfig(EndpointConfig ec)
ec - configuration specific to current endpoint (annotations, config, custom object, attributes)default void setEndpointConfig(Builder<EndpointConfig> epBuilder)
EndpointConfig using a builder rather than built instance.
Shortcut to setEndpointConfig(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.