Class AuthArg

java.lang.Object
org.apache.juneau.rest.server.auth.AuthArg
All Implemented Interfaces:
RestOpArg

public class AuthArg extends Object implements RestOpArg
Resolves @RestOp-method parameters that represent the authenticated Principal.

Matches any of:

Resolution pulls the Principal stashed by an upstream AuthN guard (BearerTokenGuard / ApiKeyGuard) on the request attributes under "juneau.principal". If the stashed value is missing or not assignable to the requested parameter type, null is injected — the guard chain is the contract that guarantees a non-null value.

Type-driven resolution lets a bare Principal parameter be filled without an annotation, matching the Spring / Servlet convention; the Auth annotation is for clarity and for disambiguating against another arg resolver that might otherwise claim the parameter.

See Also:
Since:
10.0.0
  • Constructor Details

    • AuthArg

      protected AuthArg(ParameterInfo paramInfo)
      Constructor.
      Parameters:
      paramInfo - The Java method parameter being resolved. Must not be null.
  • Method Details

    • create

      public static AuthArg create(ParameterInfo paramInfo)
      Static creator.
      Parameters:
      paramInfo - The Java method parameter being resolved. Must not be null.
      Returns:
      A new AuthArg, or null if the parameter is not eligible.
    • resolve

      public Object resolve(RestOpSession opSession)
      Description copied from interface: RestOpArg
      Resolves the parameter object.
      Specified by:
      resolve in interface RestOpArg
      Parameters:
      opSession - The rest call.
      Returns:
      The resolved object.