Class Mechanism

  • All Implemented Interfaces:
    java.lang.Comparable<Mechanism>
    Direct Known Subclasses:
    OathMechanism, PushMechanism

    public abstract class Mechanism
    extends java.lang.Object
    The Mechanism model represents the two-factor way used for authentication. Encapsulates the related settings, as well as an owning Account.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String OATH  
      static java.lang.String PUSH  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Mechanism​(java.lang.String mechanismUID, java.lang.String issuer, java.lang.String accountName, java.lang.String type, java.lang.String secret, java.util.Calendar timeAdded)
      Base constructor which encapsulates common elements of all Mechanisms.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Mechanism another)  
      static Mechanism deserialize​(java.lang.String jsonString)
      Deserializes the specified Json into an object of the Mechanism object.
      boolean equals​(java.lang.Object o)  
      java.lang.String getAccountName()
      Returns the name of this Account.
      java.lang.String getId()
      Gets the storage id of the Mechanism.
      java.lang.String getIssuer()
      Gets the name of the IDP that issued this account.
      java.lang.String getMechanismUID()
      Get the mechanism unique Id.
      java.util.Calendar getTimeAdded()
      Get the Date and Time this mechanism was stored.
      java.lang.String getType()
      Get the string used to represent this type of mechanism.
      int hashCode()  
      boolean matches​(Mechanism other)
      Returns true if the two objects would conflict if added to a storage system.
      abstract java.lang.String toJson()
      Creates a JSON string representation of ModelObject object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Mechanism

        protected Mechanism​(java.lang.String mechanismUID,
                            java.lang.String issuer,
                            java.lang.String accountName,
                            java.lang.String type,
                            java.lang.String secret,
                            java.util.Calendar timeAdded)
        Base constructor which encapsulates common elements of all Mechanisms.
        Parameters:
        mechanismUID - The ID used to identify the Mechanism to external systems
        issuer - String value of issuer
        accountName - String value of accountName or username
        type - String value of the mechanism type
        secret - String value of the shared secret
        timeAdded - Date and Time this Mechanism was stored
    • Method Detail

      • getId

        public java.lang.String getId()
        Gets the storage id of the Mechanism.
        Returns:
        The unique identifier.
      • getMechanismUID

        public java.lang.String getMechanismUID()
        Get the mechanism unique Id.
        Returns:
        The receiving Mechanism.
      • getIssuer

        public java.lang.String getIssuer()
        Gets the name of the IDP that issued this account.
        Returns:
        The name of the IDP.
      • getAccountName

        public java.lang.String getAccountName()
        Returns the name of this Account.
        Returns:
        The account name.
      • getType

        public java.lang.String getType()
        Get the string used to represent this type of mechanism.
        Returns:
        The mechanism type as string.
      • getTimeAdded

        public java.util.Calendar getTimeAdded()
        Get the Date and Time this mechanism was stored.
        Returns:
        when this mechanism was stored.
      • toJson

        public abstract java.lang.String toJson()
        Creates a JSON string representation of ModelObject object. Sensitive information are not exposed.
        Returns:
        a JSON string object
      • deserialize

        public static Mechanism deserialize​(java.lang.String jsonString)
        Deserializes the specified Json into an object of the Mechanism object.
        Parameters:
        jsonString - the json string representing the object to be deserialized
        Returns:
        an Mechanism object from the string. Returns null if jsonString is null, if jsonString is empty or not able to parse it.
      • matches

        public final boolean matches​(Mechanism other)
        Returns true if the two objects would conflict if added to a storage system.
        Parameters:
        other - The object to compare.
        Returns:
        True if key traits of the objects match, false otherwise.
      • compareTo

        public int compareTo​(Mechanism another)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object