Class PrincipalWrapper

  • All Implemented Interfaces:
    java.security.Principal

    public final class PrincipalWrapper
    extends java.lang.Object
    implements java.security.Principal
    Wrapper class for container-managed or externally-provided principals. Instances of PrincipalWrapper are immutable.
    Since:
    2.3
    • Constructor Summary

      Constructors 
      Constructor Description
      PrincipalWrapper​(java.security.Principal principal)
      Constructs a new instance of this class by wrapping (decorating) the supplied principal.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Two PrincipalWrapper objects are equal if their internally-wrapped principals are also equal.
      java.lang.String getName()
      Returns the name of the wrapped principal.
      java.security.Principal getPrincipal()
      Returns the wrapped Principal used to construct this instance.
      int hashCode()
      The hashcode is based on the hashcode of the wrapped principal.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.security.Principal

        implies, toString
    • Constructor Detail

      • PrincipalWrapper

        public PrincipalWrapper​(java.security.Principal principal)
        Constructs a new instance of this class by wrapping (decorating) the supplied principal.
        Parameters:
        principal - The principal to wrap
    • Method Detail

      • getPrincipal

        public java.security.Principal getPrincipal()
        Returns the wrapped Principal used to construct this instance.
        Returns:
        the wrapped Principal decorated by this instance.
      • getName

        public java.lang.String getName()
        Returns the name of the wrapped principal.
        Specified by:
        getName in interface java.security.Principal
        Returns:
        The name of the wrapped principal.
      • equals

        public boolean equals​(java.lang.Object obj)
        Two PrincipalWrapper objects are equal if their internally-wrapped principals are also equal.
        Specified by:
        equals in interface java.security.Principal
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj -
        Returns:
        True, if the wrapped object is also equal to our wrapped object.
      • hashCode

        public int hashCode()
        The hashcode is based on the hashcode of the wrapped principal.
        Specified by:
        hashCode in interface java.security.Principal
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        A hashcode.