- All Superinterfaces:
- SecurityContext<Principal>
Security context to retrieve security information about current user, either injected or obtained from 
Security.contextBuilder(String) and to handle programmatic security.- 
Nested Class SummaryNested Classes
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionAuthenticator client builder to use for programmatic authentication.default booleanDeprecated.Authorization client builder to use for programmatic authorization.voidaudit(AuditEvent event) Audit a security event.Authenticate current request (based on currentSecurityEnvironmentandEndpointConfig.Authorize access to a resource (or more resources) based on current environment and endpoint configuration.Current endpoint configuration.voidSet endpoint configuration to use for subsequent security requests.default voidendpointConfig(Supplier<EndpointConfig> epBuilder) Shortcut method to setEndpointConfigusing a builder rather than built instance.env()CurrentSecurityEnvironment.voidenv(SecurityEnvironment env) Set a new security environment to be used in this context.default voidenv(Supplier<SecurityEnvironment> envBuilder) Set a new security environment to be used int this context.id()Id of this context instance.booleanReturn true if the user is authenticated.booleanisUserInRole(String role) Check if user is in specified role if supported by global authorization provider.booleanisUserInRole(String role, String authorizerName) Check if user is in specified role if supported by global or specific authorization provider.voidlogout()Logout user, clear current security context.Outbound security client builder for programmatic outbound security used for identity propagation, identity mapping, encryption of outbound calls etc.voidExecutes provided code under provided subject.voidExecute provided code as current user with an additional explicit role added.A builder to build aSecurityRequest.securityRequestBuilder(SecurityEnvironment environment) A builder to build aSecurityRequestwith a specific environment.Get time instance, that can be used to obtain current time consistent with the security framework.service()Returns subject of current context (caller) service or client identity.default StringA helper method to get service name if authenticated.Returns service principal if service is authenticated.tracer()Provides the tracer to create new spans.Provides the span for tracing.user()Returns subject of current context (caller) user.default StringuserName()A helper method to get user name if authenticated.Returns user principal if user is authenticated.Methods inherited from interface io.helidon.common.security.SecurityContextisAuthorized
- 
Field Details- 
ANONYMOUS_PRINCIPALAnonymous user principal. This is the user principal used when no user is authenticated (e.g. when a service is authenticated or when fullyANONYMOUS.
- 
ANONYMOUSAnonymous subject. This is the subject you get when not authenticated and a Subject is required..
 
- 
- 
Method Details- 
securityRequestBuilderSecurityRequestBuilder<?> securityRequestBuilder()A builder to build aSecurityRequest.- Returns:
- security request builder
 
- 
securityRequestBuilderA builder to build aSecurityRequestwith a specific environment.- Parameters:
- environment- environment to use for this request
- Returns:
- security request builder
 
- 
atnClientBuilderSecurityClientBuilder<AuthenticationResponse> atnClientBuilder()Authenticator client builder to use for programmatic authentication.- Returns:
- a builder for SecurityClientinstance providingAuthenticationResponse
 
- 
authenticateAuthenticationResponse authenticate()Authenticate current request (based on currentSecurityEnvironmentandEndpointConfig.- Returns:
- response of authentication operation
 
- 
atzClientBuilderSecurityClientBuilder<AuthorizationResponse> atzClientBuilder()Authorization client builder to use for programmatic authorization. Will use existing environment.- Returns:
- a builder for SecurityClientinstance providingAuthorizationResponse
 
- 
outboundClientBuilderOutboundSecurityClientBuilder outboundClientBuilder()Outbound security client builder for programmatic outbound security used for identity propagation, identity mapping, encryption of outbound calls etc.- Returns:
- a builder for SecurityClientinstance providingOutboundSecurityResponse
 
- 
authorizeAuthorize access to a resource (or more resources) based on current environment and endpoint configuration.- Parameters:
- resource- resources to authorize access to (may be empty)
- Returns:
- response of authorization
 
- 
isAuthenticatedboolean isAuthenticated()Return true if the user is authenticated. This only cares about USER! not about service. To check if service is authenticated, useservice()and check the resulting optional.- Specified by:
- isAuthenticatedin interface- SecurityContext<Principal>
- Returns:
- true for authenticated user, false otherwise (e.g. no subject or ANONYMOUS)
 
- 
logoutvoid logout()Logout user, clear current security context.
- 
isUserInRoleCheck if user is in specified role if supported by global or specific authorization provider.- Parameters:
- role- Role to check
- authorizerName- explicit authorization provider class name to use (or config property pointing to class name)
- Returns:
- true if current user is in specified role and current authorization provider supports roles, false otherwise
 
- 
isUserInRoleCheck if user is in specified role if supported by global authorization provider. This method expects global authorization provider is in use. If you explicitly use a custom provider, useisUserInRole(String, String)instead.- Parameters:
- role- Role to check
- Returns:
- true if current user is in specified role and current authorization provider supports roles, false otherwise
 
- 
auditAudit a security event. This allows custom auditing events from applications. Note that main security events are already audited (e.g. authentication, authorization, identity propagation and various runAs events).- Parameters:
- event- AuditEvent to store
 
- 
serviceReturns subject of current context (caller) service or client identity.- Returns:
- current context service (client) subject. If there is no service/client, returns empty.
 
- 
servicePrincipalReturns service principal if service is authenticated.- Specified by:
- servicePrincipalin interface- SecurityContext<Principal>
- Returns:
- current context service principal, or empty if none authenticated
 
- 
serviceNameA helper method to get service name if authenticated.- Returns:
- name of currently authenticated service or null.
 
- 
userReturns subject of current context (caller) user.- Returns:
- current context user subject. If there is no authenticated user, returns empty.
 
- 
userPrincipalReturns user principal if user is authenticated.- Specified by:
- userPrincipalin interface- SecurityContext<Principal>
- Returns:
- current context user principal, or empty if none authenticated
 
- 
userNameA helper method to get user name if authenticated.- Returns:
- name of currently authenticated user or null.
 
- 
runAsExecutes provided code under provided subject.- Parameters:
- subject- to use for execution. Use- ANONYMOUSfor anon.
- runnable- to execute.
 
- 
runAsExecute provided code as current user with an additional explicit role added.- Parameters:
- role- name of role
- runnable- to execute
 
- 
tracingSpanSpanContext tracingSpan()Provides the span for tracing. This is the span of current context (e.g. parent to security).- Returns:
- Open tracing Span context of current security context
 
- 
tracerTracer tracer()Provides the tracer to create new spans. If you use this, we can control whether tracing is enabled or disabled as part of security. If you useTracer.global()you will get around this.- Returns:
- Tracerto build custom- Spans. Use in combination with- tracingSpan()to create a nice tree of spans
 
- 
idString id()Id of this context instance. Created as security instance id : context id (depends on container integration or id provided by developer).- Returns:
- id uniquely identifying this context
 
- 
serverTimeSecurityTime serverTime()Get time instance, that can be used to obtain current time consistent with the security framework. This time may be shifted against real time, may have a different time zone, explicit values (for testing). To obtain the decisive time for current request, please useSecurityEnvironment.- Returns:
- time instance to obtain current time
- See Also:
 
- 
envSecurityEnvironment env()CurrentSecurityEnvironment. 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.- Returns:
- environment of current security context (e.g. to use for ABAC)
 
- 
envSet a new security environment to be used int this context.- Parameters:
- envBuilder- builder to build environment from
- See Also:
 
- 
envSet a new security environment to be used in this context.- Parameters:
- env- environment to use for further security operations
- See Also:
 
- 
endpointConfigEndpointConfig endpointConfig()Current endpoint configuration.- Returns:
- configuration specific to current endpoint (annotations, config, custom object, attributes)
 
- 
endpointConfigSet endpoint configuration to use for subsequent security requests.- Parameters:
- ec- configuration specific to current endpoint (annotations, config, custom object, attributes)
 
- 
endpointConfigShortcut method to setEndpointConfigusing a builder rather than built instance. Shortcut toendpointConfig(EndpointConfig)- Parameters:
- epBuilder- builder of an endpoint configuration
 
- 
atzCheckedDeprecated.useSecurityContext.isAuthorized()insteadReturn true if either of authorization methods (authorize(Object...)oratzClientBuilder()was called). This is a safe-guard for attribute based authorization that is using annotations and requires object to be passed for evaluation.- Returns:
- true if authorization was checked, false otherwise
 
 
- 
SecurityContext.isAuthorized()instead