Class JerseySecurityFeature.Builder

java.lang.Object
io.helidon.microprofile.security.JerseySecurityFeature.Builder
All Implemented Interfaces:
Builder<JerseySecurityFeature.Builder,JerseySecurityFeature>, Supplier<JerseySecurityFeature>
Enclosing class:
JerseySecurityFeature

public static final class JerseySecurityFeature.Builder extends Object implements Builder<JerseySecurityFeature.Builder,JerseySecurityFeature>
JerseySecurityFeature fluent API builder.
  • Method Details

    • authorizeAnnotatedOnly

      public JerseySecurityFeature.Builder authorizeAnnotatedOnly(boolean authzOnly)
      Whether to authorize only annotated methods (with Authorized annotation) or all. When using usePrematchingAuthorization(boolean) this method is ignored.
      Parameters:
      authzOnly - if set to true, authorization will be performed on annotated methods only, defaults to false
      Returns:
      updated builder instance
    • authenticateAnnotatedOnly

      public JerseySecurityFeature.Builder authenticateAnnotatedOnly(boolean authnOnly)
      Whether to authorize only annotated methods (with Authenticated annotation or all. When using usePrematchingAuthentication(boolean) this method is ignored. By default only annotated methods (annotation may be also on Application class or resource class) are authenticated.
      Parameters:
      authnOnly - if set to false, authentication will be performed for all requests, defaults to true
      Returns:
      updated builder instance
    • addQueryParamHandler

      public JerseySecurityFeature.Builder addQueryParamHandler(QueryParamHandler handler)
      Add a new handler to extract query parameter and store it in security request header.
      Parameters:
      handler - handler to extract data
      Returns:
      updated builder instance
    • addQueryParamHandlers

      public JerseySecurityFeature.Builder addQueryParamHandlers(Iterable<QueryParamHandler> handlers)
      Add handlers to extract query parameters and store them in security request header.
      Parameters:
      handlers - handlers to extract data
      Returns:
      updated builder instance
    • usePrematchingAuthentication

      public JerseySecurityFeature.Builder usePrematchingAuthentication(boolean usePrematching)
      Configure whether pre-matching or post-matching filter is used to authenticate requests. Defaults to post-matching, as we have access to information about resource class and method that is invoked, allowing us to use annotations defined on these. When switched to prematching, the security is an on/off switch - all resources are protected the same way.
      Parameters:
      usePrematching - whether to use pre-matching filter instead of post-matching
      Returns:
      updated builder instance
    • usePrematchingAuthorization

      public JerseySecurityFeature.Builder usePrematchingAuthorization(boolean usePrematching)
      Configure whether pre-matching or post-matching filter is used to authorize requests. Defaults to post-matching, as we have access to information about resource class and method that is invoked, allowing us to use annotations defined on these. When switched to prematching, the security is an on/off switch - all resources are protected the same way.
      When set to true, authentication will be prematching as well.
      Parameters:
      usePrematching - whether to use pre-matching filter instead of post-matching
      Returns:
      updated builder instance
    • debug

      Set debugging on. Will return description from response in entity.
      Returns:
      updated builder instance
    • useAbortWith

      public JerseySecurityFeature.Builder useAbortWith(boolean useAbortWith)
      When set to true (which is the default behavior, the security filter would use ContainerRequest.abortWith(jakarta.ws.rs.core.Response) to abort request and configure a security response.

      When set to false, the security filter would throw an WebApplicationException instead. Such an exception can be handled by a custom error handler.

      Parameters:
      useAbortWith - set to false to use exceptions, by default uses abortWith on request
      Returns:
      updated builder instance
    • config

      public JerseySecurityFeature.Builder config(Config config)
      Update this builder from configuration. Expects: Example:
        security:
          jersey:
            defaults:
            # If set to true, only annotated (@Authenticated) resources will be authorized
            # By default, every request is sent to authorization provider
            authorize-annotated-only: false
            # query parameters will be extracted from request
            # and sent to authentication and authorization providers
            # as headers. These will NOT be available to application
            # as headers.
            query-params:
              - name: "basicAuth"
                header: "Authorization"
       
      Parameters:
      config - configuration set to key "jersey" (see example above)
      Returns:
      updated builder instance
    • build

      public JerseySecurityFeature build()
      Build this configuration into an instance.
      Specified by:
      build in interface Builder<JerseySecurityFeature.Builder,JerseySecurityFeature>
      Returns:
      feature to register with Jersey