Credentials implements SpaceFields { public boolean enabled() { return enabled; } Credentials();  Credentials(String username); String id(); Credentials id(String id); long version(); Credentials version(long version); String username(); Credentials username(String name); Optional<String> email(); Credentials email(String value); String accessToken(); long accessTokenExpiresIn(); boolean hasPasswordBeenChallenged(); Credentials passwordHasBeenChallenged(boolean passwordHasBeenChallenged); String passwordResetCode(); Credentials passwordResetCode(String passwordResetCode); String hashedPassword(); Credentials hashedPassword(String hashedPassword); boolean passwordMustChange(); void passwordMustChange(Boolean passwordMustChange); boolean enabled(); Credentials enabled(boolean enabled); DateTime enableAfter(); Credentials enableAfter(DateTime enableAfter); DateTime disableAfter(); Credentials disableAfter(DateTime disableAfter); Set<String> roles(); Credentials clearRoles(); Credentials addRoles(String... roles); Credentials removeRoles(String... roles); DateTime createdAt(); Credentials createdAt(DateTime value); DateTime updatedAt(); Credentials updatedAt(DateTime value); int invalidChallenges(); Credentials invalidChallenges(int invalidChallenges); DateTime lastInvalidChallengeAt(); Credentials lastInvalidChallengeAt(DateTime lastInvalidChallengeAt); String group(); Set<String> groups(); Credentials addGroup(String group); Credentials removeGroup(String group); boolean hasGroup(String group); String createGroup(String suffix); static String extractGroupOwner(String group); boolean hasGroupAccessPermission(String group); Credentials checkGroupAccessPermission(String group); boolean hasGroupAdminPermission(String group); Credentials checkGroupAdminPermission(String group); boolean isGroupMine(String group); Credentials checkGroupIsMine(String group); Set<String> tags(); Credentials tags(Iterable<String> tags); Credentials addTag(String key, Object value); Credentials addTag(String tag); Set<String> getTagValues(String key); Credentials removeTags(String key); @Override int hashCode(); @Override boolean equals(Object obj); String type(); boolean isSuperDog(); Credentials checkSuperDog(); boolean isSuperAdmin(); boolean isAtLeastSuperAdmin(); Credentials checkAtLeastSuperAdmin(); boolean isAdmin(); boolean isAtLeastAdmin(); Credentials checkAtLeastAdmin(); boolean isUser(); boolean isAtLeastUser(); Credentials checkAtLeastUser(); boolean isGuest(); boolean canManage(String role); boolean canManage(String... roles); Credentials checkCanManage(Credentials other); Credentials checkCanManage(String... roles); Credentials checkRoleAccess(String... authorizedRoles); Credentials checkRoleAccess(Iterable<String> authorizedRoles); void checkOwnerAccess(String owner, String objectType, String objectId); void doEnableOrDisable(boolean enable); void checkReallyEnabled(); boolean isReallyEnabled(); void checkPasswordHasBeenChallenged(); void resetPassword(); void newPasswordResetCode(); boolean challengePassword(String passwordToChallenge); void clearPasswordAndTokens(); void changePassword(String password, String passwordResetCode, Optional<String> regex); void changePassword(String password, Optional<String> regex); @Override String toString(); List<Session> sessions(); Credentials sessions(Iterable<Session> sessions); void setCurrentSession(String accessToken); void setCurrentSession(Session session); boolean hasCurrentSession(); void deleteCurrentSession(); void purgeOldSessions(int sessionsSizeMax); void deleteSession(String accessToken); boolean isBrandNew(); static final String TYPE; static final Credentials GUEST; static final Credentials SUPERDOG; }
@Test public void testEnabled() { DateTime now = DateTime.now(); assertFalse(newCredentials(now.minusHours(2), now.minusHours(1)).isReallyEnabled()); assertTrue(newCredentials(now.minusHours(2), now.plusHours(2)).isReallyEnabled()); assertFalse(newCredentials(now.plusHours(1), now.plusHours(2)).isReallyEnabled()); assertTrue(newCredentials(now.minusHours(1), now.minusHours(2)).isReallyEnabled()); assertFalse(newCredentials(now.plusHours(2), now.minusHours(2)).isReallyEnabled()); assertFalse(newCredentials(now.plusHours(2), now.plusHours(1)).isReallyEnabled()); assertTrue(newCredentials(now.minusHours(2), null).isReallyEnabled()); assertFalse(newCredentials(now.plusHours(2), null).isReallyEnabled()); assertFalse(newCredentials(null, now.minusHours(2)).isReallyEnabled()); assertTrue(newCredentials(null, now.plusHours(2)).isReallyEnabled()); assertTrue(newCredentials(null, null).isReallyEnabled()); }