public class ApiKeyModification extends AuthIdentityModification<ApiKey>
AuthIdentityModification implementation for API keys. Since API keys introduce no new attributes to
AuthIdentity this class only defines the two builder methods.| Constructor and Description |
|---|
ApiKeyModification() |
| Modifier and Type | Method and Description |
|---|---|
ApiKey |
buildFrom(ApiKey identity)
Subclasses should return a new AuthIdentity instance matching the provided entity plus any modifications
set in this object.
|
ApiKey |
buildNew(String id)
Subclasses should return a new AuthIdentity instance based only on the attributes set in this object with
the provided ID.
|
addRoles, addRoles, getDescription, getOwner, getUpdatedRolesFrom, isDescriptionPresent, isOwnerPresent, removeRoles, removeRoles, withDescription, withOwnerpublic ApiKey buildNew(String id)
AuthIdentityModification
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;
buildNew in class AuthIdentityModification<ApiKey>public ApiKey buildFrom(ApiKey identity)
AuthIdentityModification
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"));
buildFrom in class AuthIdentityModification<ApiKey>Copyright © 2017. All Rights Reserved.