Class Actor

java.lang.Object
com.nimbusds.oauth2.sdk.id.Actor
All Implemented Interfaces:
Serializable, Comparable<Actor>, net.minidev.json.JSONAware

@Immutable public final class Actor extends Object implements Serializable, Comparable<Actor>, net.minidev.json.JSONAware
Authorised actor in impersonation and delegation cases.
See Also:
  • Constructor Details

    • Actor

      public Actor(Subject subject)
      Creates a new actor.
      Parameters:
      subject - The subject. Must not be null.
    • Actor

      public Actor(Subject subject, Issuer issuer, Actor parent)
      Creates a new actor.
      Parameters:
      subject - The subject. Must not be null.
      issuer - Optional issuer for the subject, null if not specified.
      parent - Optional parent for the actor, null if none.
  • Method Details

    • getSubject

      public Subject getSubject()
      Returns the subject.
      Returns:
      The subject.
    • getIssuer

      public Issuer getIssuer()
      Returns the optional issuer for the subject.
      Returns:
      The issuer, null if not specified.
    • getParent

      public Actor getParent()
      Returns the optional parent for this actor.
      Returns:
      The optional parent for the actor, null if none.
    • toJSONObject

      public net.minidev.json.JSONObject toJSONObject()
      Returns a JSON object representation of this actor.

      Simple example:

       {
         "sub" : "[email protected]"
       }
       

      With nesting:

       {
         "sub" : "consumer.example.com-web-application",
         "iss" : "https://issuer.example.net",
         "act" : { "sub":"[email protected]" }
       }
       
      Returns:
      The JSON object.
    • compareTo

      public int compareTo(Actor other)
      Specified by:
      compareTo in interface Comparable<Actor>
    • toJSONString

      public String toJSONString()
      Specified by:
      toJSONString in interface net.minidev.json.JSONAware
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • parse

      public static Actor parse(net.minidev.json.JSONObject jsonObject) throws ParseException
      Parses an actor from the specified JSON object representation.

      Simple example:

       {
         "sub" : "[email protected]"
       }
       

      With nesting:

       {
         "sub" : "consumer.example.com-web-application",
         "iss" : "https://issuer.example.net",
         "act" : { "sub":"[email protected]" }
       }
       
      Parameters:
      jsonObject - The JSON object. Must not be null.
      Returns:
      The actor.
      Throws:
      ParseException - If parsing failed.
    • parseTopLevel

      public static Actor parseTopLevel(net.minidev.json.JSONObject jsonObject) throws ParseException
      Parses an actor from the specified top-level JSON object contains an optional actor JSON representation.

      Simple example:

       {
         "aud" : "https://consumer.example.com",
         "iss" : "https://issuer.example.com",
         "exp" : 1443904177,
         "nbf" : 1443904077,
         "sub" : "[email protected]",
         "act" : { "sub" : "[email protected]" }
       }
       

      With nesting:

       {
         "aud" : "https://backend.example.com",
         "iss" : "https://issuer.example.com",
         "exp" : 1443904100,
         "nbf" : 1443904000,
         "sub" : "[email protected]",
         "act" : { "sub" : "consumer.example.com-web-application",
                   "iss" : "https://issuer.example.net",
                   "act" : { "sub":"[email protected]" } }
       }
       
      Parameters:
      jsonObject - The top-level JSON object to parse. Must not be null.
      Returns:
      The actor, null if not specified.
      Throws:
      ParseException - If parsing failed.