Class Pac4jModule

java.lang.Object
io.jooby.pac4j.Pac4jModule
All Implemented Interfaces:
io.jooby.Extension

public class Pac4jModule extends Object implements io.jooby.Extension
Pac4j module: https://jooby.io/modules/pac4j.

Usage:

- Add pac4j dependency

- Add pac4j client dependency, like oauth, openid, etc... (Optional)

- Install them


 {
   install(new Pac4jModule());
 }
 
- Use it

 {

   get("/", ctx -> {
     UserProfile user = ctx.getUser();
   });

 }
 
Previous example install a simple login form and give you access to profile details via Context.getUser().
Since:
2.4.0.
Author:
edgar
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new pac4j module.
    Creates a new pac4j module.
    Pac4jModule(org.pac4j.core.config.Config options)
    Creates a new pac4j module.
  • Method Summary

    Modifier and Type
    Method
    Description
    client(Class<? extends org.pac4j.core.authorization.authorizer.Authorizer> authorizer, Class<? extends org.pac4j.core.client.Client> client)
    Register a default security filter.
    client(Class<? extends org.pac4j.core.authorization.authorizer.Authorizer> authorizer, Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
    Register a default security filter.
    client(Class<? extends org.pac4j.core.client.Client> client)
    Register a default security filter.
    client(String pattern, Class<? extends org.pac4j.core.authorization.authorizer.Authorizer> authorizer, Class<? extends org.pac4j.core.client.Client> client)
    Register a security filter under the given path.
    client(String pattern, Class<? extends org.pac4j.core.authorization.authorizer.Authorizer> authorizer, Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
    Register a security filter under the given path.
    client(String pattern, Class<? extends org.pac4j.core.client.Client> client)
    Register a security filter under the given path.
    client(String pattern, String authorizer, Class<? extends org.pac4j.core.client.Client> client)
    Register a filter under the given path.
    client(String pattern, String authorizer, Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
    Register a filter under the given path.
    client(String pattern, Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
    Register a security filter under the given path.
    client(String pattern, org.pac4j.core.authorization.authorizer.Authorizer authorizer, Class<? extends org.pac4j.core.client.Client> client)
    Register a security filter under the given path.
    client(String pattern, org.pac4j.core.authorization.authorizer.Authorizer authorizer, Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
    Register a security filter under the given path.
    client(Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
    Register a default security filter.
    client(org.pac4j.core.authorization.authorizer.Authorizer authorizer, Class<? extends org.pac4j.core.client.Client> client)
    Register a default security filter.
    client(org.pac4j.core.authorization.authorizer.Authorizer authorizer, Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
    Register a default security filter.
    void
    install(io.jooby.Jooby app)
     
    static org.pac4j.core.http.adapter.HttpActionAdapter
    Default action adapter.
    static org.pac4j.core.engine.DefaultCallbackLogic
    Default callback logic and optionally specify the pattern to excludes while saving user requested urls.
    static org.pac4j.core.engine.LogoutLogic
    Creates a default logout logic.
    static org.pac4j.core.engine.DefaultSecurityLogic
    Default security logic and optionally specify the pattern to excludes while saving user requested urls.
    static org.pac4j.core.http.url.UrlResolver
    Default url resolver.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.jooby.Extension

    lateinit
  • Constructor Details

    • Pac4jModule

      public Pac4jModule()
      Creates a new pac4j module.
    • Pac4jModule

      public Pac4jModule(Pac4jOptions options)
      Creates a new pac4j module.
      Parameters:
      options - Options.
    • Pac4jModule

      public Pac4jModule(org.pac4j.core.config.Config options)
      Creates a new pac4j module.
      Parameters:
      options - Options.
  • Method Details

    • client

      public Pac4jModule client(Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
      Register a default security filter.
      Parameters:
      provider - Client factory.
      Returns:
      This module.
    • client

      public Pac4jModule client(String pattern, Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
      Register a security filter under the given path.
      Parameters:
      pattern - Protected pattern.
      provider - Client factory.
      Returns:
      This module.
    • client

      public Pac4jModule client(Class<? extends org.pac4j.core.authorization.authorizer.Authorizer> authorizer, Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
      Register a default security filter.

      NOTE: the authorizer is attached to the given path pattern (not the client). All the authorizers added to the path applies to all the registered clients.

      Parameters:
      authorizer - Authorizer to use. Authorizer must be provisioned by application registry.
      provider - Client factory.
      Returns:
      This module.
    • client

      @NonNull public Pac4jModule client(@NonNull org.pac4j.core.authorization.authorizer.Authorizer authorizer, @NonNull Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
      Register a default security filter.

      NOTE: the authorizer is attached to the given path pattern (not the client). All the authorizers added to the path applies to all the registered clients.

      Parameters:
      authorizer - Authorizer to use.
      provider - Client factory.
      Returns:
      This module.
    • client

      @NonNull public Pac4jModule client(@NonNull String pattern, @NonNull Class<? extends org.pac4j.core.authorization.authorizer.Authorizer> authorizer, @NonNull Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
      Register a security filter under the given path.

      NOTE: the authorizer is attached to the given path pattern (not the client). All the authorizers added to the path applies to all the registered clients.

      Parameters:
      pattern - Protected pattern. Use * for intercept all calls.
      authorizer - Authorizer to use. Authorizer must be provisioned by application registry.
      provider - Client factory.
      Returns:
      This module.
    • client

      @NonNull public Pac4jModule client(@NonNull String pattern, @NonNull org.pac4j.core.authorization.authorizer.Authorizer authorizer, @NonNull Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
      Register a security filter under the given path.

      NOTE: the authorizer is attached to the given path pattern (not the client). All the authorizers added to the path applies to all the registered clients.

      Parameters:
      pattern - Protected pattern. Use * for intercept all calls.
      authorizer - Authorizer to use.
      provider - Client factory.
      Returns:
      This module.
    • client

      @NonNull public Pac4jModule client(@NonNull String pattern, @Nullable String authorizer, @NonNull Function<com.typesafe.config.Config,org.pac4j.core.client.Client> provider)
      Register a filter under the given path.

      NOTE: the authorizer is attached to the given path pattern (not the client). All the authorizers added to the path applies to all the registered clients.

      Parameters:
      pattern - Protected pattern. Use * for intercept all calls.
      authorizer - Authorizer to use. Must be registered via Config.addAuthorizer(String, Authorizer). Null is allowed.
      provider - Client factory.
      Returns:
      This module.
    • client

      public Pac4jModule client(@NonNull Class<? extends org.pac4j.core.client.Client> client)
      Register a default security filter.
      Parameters:
      client - Client class.
      Returns:
      This module.
    • client

      public Pac4jModule client(@NonNull String pattern, @NonNull Class<? extends org.pac4j.core.client.Client> client)
      Register a security filter under the given path.
      Parameters:
      pattern - Protected pattern.
      client - Client class.
      Returns:
      This module.
    • client

      public Pac4jModule client(@NonNull Class<? extends org.pac4j.core.authorization.authorizer.Authorizer> authorizer, @NonNull Class<? extends org.pac4j.core.client.Client> client)
      Register a default security filter.

      NOTE: the authorizer is attached to the given path pattern (not the client). All the authorizers added to the path applies to all the registered clients.

      Parameters:
      authorizer - Authorizer to use. Authorizer must be provisioned by application registry.
      client - Client class.
      Returns:
      This module.
    • client

      @NonNull public Pac4jModule client(@NonNull org.pac4j.core.authorization.authorizer.Authorizer authorizer, @NonNull Class<? extends org.pac4j.core.client.Client> client)
      Register a default security filter.

      NOTE: the authorizer is attached to the given path pattern (not the client). All the authorizers added to the path applies to all the registered clients.

      Parameters:
      authorizer - Authorizer to use.
      client - Client class.
      Returns:
      This module.
    • client

      @NonNull public Pac4jModule client(@NonNull String pattern, @NonNull Class<? extends org.pac4j.core.authorization.authorizer.Authorizer> authorizer, @NonNull Class<? extends org.pac4j.core.client.Client> client)
      Register a security filter under the given path.

      NOTE: the authorizer is attached to the given path pattern (not the client). All the authorizers added to the path applies to all the registered clients.

      Parameters:
      pattern - Protected pattern. Use * for intercept all calls.
      authorizer - Authorizer to use. Authorizer must be provisioned by application registry.
      client - Client class.
      Returns:
      This module.
    • client

      @NonNull public Pac4jModule client(@NonNull String pattern, @NonNull org.pac4j.core.authorization.authorizer.Authorizer authorizer, @NonNull Class<? extends org.pac4j.core.client.Client> client)
      Register a security filter under the given path.

      NOTE: the authorizer is attached to the given path pattern (not the client). All the authorizers added to the path applies to all the registered clients.

      Parameters:
      pattern - Protected pattern. Use * for intercept all calls.
      authorizer - Authorizer to use.
      client - Client class.
      Returns:
      This module.
    • client

      @NonNull public Pac4jModule client(@NonNull String pattern, @Nullable String authorizer, @NonNull Class<? extends org.pac4j.core.client.Client> client)
      Register a filter under the given path.

      NOTE: the authorizer is attached to the given path pattern (not the client). All the authorizers added to the path applies to all the registered clients.

      Parameters:
      pattern - Protected pattern. Use * for intercept all calls.
      authorizer - Authorizer to use. Must be registered via Config.addAuthorizer(String, Authorizer). Null is allowed.
      client - Client class.
      Returns:
      This module.
    • install

      public void install(@NonNull io.jooby.Jooby app) throws Exception
      Specified by:
      install in interface io.jooby.Extension
      Throws:
      Exception
    • newLogoutLogic

      public static org.pac4j.core.engine.LogoutLogic newLogoutLogic()
      Creates a default logout logic.
      Returns:
      Default logout logic.
    • newActionAdapter

      public static org.pac4j.core.http.adapter.HttpActionAdapter newActionAdapter()
      Default action adapter.
      Returns:
      Default action adapter.
    • newSecurityLogic

      public static org.pac4j.core.engine.DefaultSecurityLogic newSecurityLogic(Set<String> excludes)
      Default security logic and optionally specify the pattern to excludes while saving user requested urls.
      Parameters:
      excludes - Pattern to ignores.
      Returns:
      Default security logic.
    • newCallbackLogic

      public static org.pac4j.core.engine.DefaultCallbackLogic newCallbackLogic(Set<String> excludes)
      Default callback logic and optionally specify the pattern to excludes while saving user requested urls.
      Parameters:
      excludes - Pattern to ignores.
      Returns:
      Default callback logic.
    • newUrlResolver

      public static org.pac4j.core.http.url.UrlResolver newUrlResolver()
      Default url resolver.
      Returns:
      Default url resolver.