public abstract class AuthIdentityModification<T extends AuthIdentity>
extends java.lang.Object
AuthIdentity as part of a create
or update operation using AuthIdentityManager.createIdentity(String, AuthIdentityModification) or
AuthIdentityManager.updateIdentity(String, AuthIdentityModification), respectively. Subclasses should
override to instantiate a new instance from one of the build methods, as well as add any additional modifiers
for attributes specific to the AuthIdentity implementation if necessary.| Constructor and Description |
|---|
AuthIdentityModification() |
| Modifier and Type | Method and Description |
|---|---|
AuthIdentityModification<T> |
addRoles(java.util.Set<java.lang.String> roles) |
AuthIdentityModification<T> |
addRoles(java.lang.String... roles) |
abstract T |
buildFrom(T identity)
Subclasses should return a new AuthIdentity instance matching the provided entity plus any modifications
set in this object.
|
abstract T |
buildNew(java.lang.String id)
Subclasses should return a new AuthIdentity instance based only on the attributes set in this object with
the provided ID.
|
protected java.lang.String |
getDescription() |
protected java.lang.String |
getOwner() |
protected java.util.Set<java.lang.String> |
getUpdatedRolesFrom(java.util.Set<java.lang.String> roles)
Helper method for subclasses which, given a set of roles, returns a new set of roles with all added and removed
roles from this modification applied.
|
protected boolean |
isDescriptionPresent() |
protected boolean |
isOwnerPresent() |
AuthIdentityModification<T> |
removeRoles(java.util.Set<java.lang.String> roles) |
AuthIdentityModification<T> |
removeRoles(java.lang.String... roles) |
AuthIdentityModification<T> |
withDescription(java.lang.String description) |
AuthIdentityModification<T> |
withOwner(java.lang.String owner) |
public AuthIdentityModification<T> withOwner(java.lang.String owner)
public AuthIdentityModification<T> withDescription(java.lang.String description)
public AuthIdentityModification<T> addRoles(java.util.Set<java.lang.String> roles)
public AuthIdentityModification<T> addRoles(java.lang.String... roles)
public AuthIdentityModification<T> removeRoles(java.util.Set<java.lang.String> roles)
public AuthIdentityModification<T> removeRoles(java.lang.String... roles)
protected boolean isOwnerPresent()
protected java.lang.String getOwner()
protected boolean isDescriptionPresent()
protected java.lang.String getDescription()
protected java.util.Set<java.lang.String> getUpdatedRolesFrom(java.util.Set<java.lang.String> roles)
public abstract T buildNew(java.lang.String id)
AuthIdentityImpl identity = createAuthIdentityImplModification()
.withOwner("owner@example.com")
.addRoles("role1")
.buildNew("123");
assert identity.getId().equals("123");
assert identity.getOwner().equals("owner@example.com");
assert identity.getRoles().equals(ImmutableSet.of("role1"));
assert identity.getDescription() == null;
public abstract T buildFrom(T identity)
AuthIdentityImpl before = getAuthIdentityImplFromSomewhere();
assert before.getId().equals("123");
assert before.getOwner.equals("owner@example.com");
assert before.getDescription.equals("Old description");
assert before.getRoles().equals(ImmutableSet.of("role1"));
AuthIdentityImpl after = createAuthIdentityImplModification()
.withDescription("New description")
.addRoles("role2")
.removeRoles("role1")
.buildFrom(before);
assert after.getId().equals("123");
assert after.getOwner.equals("owner@example.com");
assert after.getDescription.equals("New description");
assert after.getRoles().equals(ImmutableSet.of("role2"));
Copyright © 2019. All Rights Reserved.