All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bazaarvoice.emodb.auth.identity.AuthIdentity Maven / Gradle / Ivy

There is a newer version: 6.5.190
Show newest version
package com.bazaarvoice.emodb.auth.identity;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;

import java.util.Date;
import java.util.Set;

import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;

/**
 * Base unit of identity for a client which can be authenticated in the application.
 */
abstract public class AuthIdentity {

    /**
     * Each identity is associated with an immutable ID distinct from the secret authentication key.  This is done
     * for several reasons:
     *
     * 
    *
  1. * Parts of the system may need associate resources with an ID. For example, each databus subscription * is associated with an API key. By using a distinct ID these parts of the system don't need to * be concerned with safely storing the API key, since the ID is essentially a reference to the key. *
  2. *
  3. * Parts of the system may need to determine whether an ID has permission to perform certain actions * without actually logging the user in. Databus fanout is a prime example of this. Using IDs * in the interface allows those parts of the system to validate authorization for permission without * the ability to impersonate that user by logging them in. *
  4. *
  5. * If an ID is compromised an administrator may want to replace it with a new ID without * changing all internal references to that ID. *
  6. *
  7. * User management can be performed without the identity owner divulging her authentication ID, * such as over a chat client or in an email. *
  8. *
*/ private final String _id; // Roles assigned to the identity private final Set _roles; // Owner of the identity, such as an email address private String _owner; // Description of this identity private String _description; // Date this identity was issued private Date _issued; // Masked version of the authentication ID. private String _maskedId; protected AuthIdentity(String id, Set roles) { checkArgument(!Strings.isNullOrEmpty(id), "id"); _id = id; _roles = ImmutableSet.copyOf(requireNonNull(roles, "roles")); } public String getId() { return _id; } public Set getRoles() { return _roles; } public String getOwner() { return _owner; } public void setOwner(String owner) { _owner = owner; } public String getDescription() { return _description; } public void setDescription(String description) { _description = description; } public Date getIssued() { return _issued; } public void setIssued(Date issued) { _issued = issued; } public String getMaskedId() { return _maskedId; } public void setMaskedId(String maskedId) { _maskedId = maskedId; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy