Class CommonJsonIdentity

java.lang.Object
io.continual.iam.impl.common.CommonJsonObject
io.continual.iam.impl.common.CommonJsonIdentity
All Implemented Interfaces:
Identity, UserDataHolder

public class CommonJsonIdentity extends CommonJsonObject implements Identity
  • Constructor Details

  • Method Details

    • initializeIdentity

      public static org.json.JSONObject initializeIdentity()
    • getId

      public String getId()
      Description copied from interface: Identity
      Get the unique id for this user
      Specified by:
      getId in interface Identity
      Returns:
      a unique ID
    • toString

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

      public void setApiKeyUsedForAuth(String apiKey)
    • getApiKey

      public String getApiKey()
      Get the API key supplied to the constructor, if any.
      Returns:
      an API key or null
    • asJson

      public org.json.JSONObject asJson()
    • setPassword

      public void setPassword(String password) throws IamSvcException
      Description copied from interface: Identity
      Set the user's password. Implementations of this interface should be careful to store the password indirectly (e.g. via salted hash), but this is not enforced at the interface layer.
      Specified by:
      setPassword in interface Identity
      Parameters:
      password - a password
      Throws:
      IamSvcException - when the call cannot be completed due to a service error
    • setPasswordSaltAndHash

      public void setPasswordSaltAndHash(String salt, String hash) throws IamSvcException
      Throws:
      IamSvcException
    • requestPasswordReset

      public String requestPasswordReset(long secondsUntilExpire, String nonce) throws IamSvcException, IamBadRequestException
      Description copied from interface: Identity
      Request a password reset. The response is a unique tag that would normally be distributed to the user via email as a link. The user acknowledges the password change request by clicking the link. The link handler then calls completePasswordReset().
      Specified by:
      requestPasswordReset in interface Identity
      Parameters:
      secondsUntilExpire - amount of time until the generated tag expires
      nonce - arbitrary user data used to create the tag
      Returns:
      a unique tag
      Throws:
      IamSvcException - when the call cannot be completed due to a service error
      IamBadRequestException - when the request is now allowed
    • createApiKey

      public ApiKey createApiKey() throws IamSvcException
      Description copied from interface: Identity
      Create an API key for this user.
      Specified by:
      createApiKey in interface Identity
      Returns:
      an API key
      Throws:
      IamSvcException - when the call cannot be completed due to a service error
    • loadApiKeysForUser

      public Collection<String> loadApiKeysForUser() throws IamSvcException
      Description copied from interface: Identity
      Load the set of API keys for this user.
      Specified by:
      loadApiKeysForUser in interface Identity
      Returns:
      a set of 0 or more API keys
      Throws:
      IamSvcException - when the call cannot be completed due to a service error
    • deleteApiKey

      public void deleteApiKey(ApiKey key) throws IamSvcException
      Description copied from interface: Identity
      Delete an API key from the user.
      Specified by:
      deleteApiKey in interface Identity
      Parameters:
      key - the API key to remove
      Throws:
      IamSvcException - when the call cannot be completed due to a service error
    • enable

      public void enable(boolean enable) throws IamSvcException
      Description copied from interface: Identity
      Enable or disable the user. When disabled, authentication will fail.
      Specified by:
      enable in interface Identity
      Parameters:
      enable - if true, enable the user
      Throws:
      IamSvcException - when the call cannot be completed due to a service error
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: Identity
      Is this identity enabled?
      Specified by:
      isEnabled in interface Identity
      Returns:
      true if enabled
    • getPasswordSalt

      public String getPasswordSalt()
    • getPasswordHash

      public String getPasswordHash()
    • getGroupIds

      public Set<String> getGroupIds() throws IamSvcException
      Description copied from interface: Identity
      Get the IDs of the groups this user belongs to
      Specified by:
      getGroupIds in interface Identity
      Returns:
      a set of group IDs
      Throws:
      IamSvcException - when the call cannot be completed due to a service error
    • getGroups

      public Collection<Group> getGroups() throws IamSvcException
      Description copied from interface: Identity
      Get the groups this user belongs to
      Specified by:
      getGroups in interface Identity
      Returns:
      a set of groups
      Throws:
      IamSvcException - when the call cannot be completed due to a service error
    • getGroup

      public Group getGroup(String groupId) throws IamSvcException
      Description copied from interface: Identity
      Get a group by ID if the user is a member. Otherwise, null is returned.
      Specified by:
      getGroup in interface Identity
      Parameters:
      groupId - the ID of the group to retrieve
      Returns:
      a group or null if not a member
      Throws:
      IamSvcException - when the call cannot be completed due to a service error
    • addApiKey

      public void addApiKey(String newApiKey)
    • addGroup

      protected boolean addGroup(String groupId)
    • removeGroup

      protected boolean removeGroup(String groupId)
    • getDataRecord

      protected org.json.JSONObject getDataRecord()
      Specified by:
      getDataRecord in class CommonJsonObject
    • reload

      public void reload() throws IamSvcException
      Description copied from interface: UserDataHolder
      reload this object from the server
      Specified by:
      reload in interface UserDataHolder
      Specified by:
      reload in class CommonJsonObject
      Throws:
      IamSvcException - if there's a problem in the IAM service
    • store

      protected void store() throws IamSvcException
      Specified by:
      store in class CommonJsonObject
      Throws:
      IamSvcException
    • main

      public static void main(String[] args)