public final int compareTo(Role role) { return getPrincipalName().compareTo(role.getPrincipalName()); } }
@Override public String toString() { StringBuilder builder = new StringBuilder(super.toString()); builder.append("[type='").append(getType()); builder.append("', expire='").append(getExpire() == null ? "" : getExpire().toString()); builder.append("', lastChange='").append(getLastChange() == null ? "" : getLastChange().toString()); builder.append("', unlocked='").append(getUnlocked() == null ? "" : getUnlocked().toString()); builder.append("', disable='").append(getDisable() == null ? "" : getDisable().toString()); builder.append("']"); return builder.toString(); } }
/** * Calculate that status type based on the dates attributes set in this * object. */ public void calculateType() { Date now = new Date(); setType(AccountStatusType.unlocked); if(isDisabled()) { setType(AccountStatusType.disabled); } else if (getExpire() != null && now.after(getExpire())) { // Expired account setType(AccountStatusType.expired); } else if (getLocked() != null) { if (getUnlocked() == null || getUnlocked().compareTo(now) < 1) { setType(AccountStatusType.locked); } } }
/** * Calculate that status type based on the dates attribtues set in this * object. */ public void calculateType() { Date now = new Date(); if(isNeedChange()) { setType(PasswordStatusType.changeRequired); } else if (getExpire() != null && now.after(getExpire())) { // Expired, must change password setType(PasswordStatusType.expired); } else if (getWarn() != null && now.after(getWarn())) { // Near expiry setType(PasswordStatusType.nearExpiry); } else { // Locked // TODO prevent password change if locked. Can be // permanently locked as well by making unlock > expiry if (getUnlocked() != null && now.before(getUnlocked())) { setType(PasswordStatusType.locked); } else { setType(PasswordStatusType.upToDate); } } }
protected String replaceTokens(String str, Principal identity) { str = str.replace("${guid}", escapeString(identity.getGuid())); str = str.replace("${principalName}", escapeString(identity.getPrincipalName())); if (identity instanceof Identity) { Identity id = (Identity) identity; Map<String, String[]> attributes = id.getAttributes(); if (attributes != null) { for (Map.Entry<String, String[]> en : attributes.entrySet()) { str = replaceToken(str, "${" + en.getKey() + "}", escapeString(StringUtil.getValue(en.getValue()))); } } } return replaceTokens(str); }
@Override public String toString() { StringBuilder builder = new StringBuilder(super.toString()); builder.append("[passwordStatus='").append(getPasswordStatus() == null ? "" : getPasswordStatus().toString()); builder.append("', lastSignOnDate='").append(getLastSignOnDate() == null ? "" : getLastSignOnDate().toString()); builder.append("', roles='").append(roles == null ? "" : roles).append("']"); return builder.toString(); }
protected final void assertGuid(Principal principal, String guid) { if (!principal.getGuid().equals(guid)) { throw new PrincipalNotFoundException("Principal '" + principal.getPrincipalName() + "' found but GUID does not match: expected = '" + principal.getGuid() + "' actual = '" + guid + "'"); } }
@Override public String toString() { StringBuilder builder = new StringBuilder(super.toString()); builder.append("[type='").append(getType()); builder.append("', expire='").append(getExpire() == null ? "" : getExpire().toString()); builder.append("', locked='").append(getLocked() == null ? "" : getLocked().toString()); builder.append("', unlocked='").append(getUnlocked() == null ? "" : getUnlocked().toString()); builder.append("']"); return builder.toString(); }
/** * Checks that the supplied credentials are valid for authentication * * @param identity * @param password * @return <tt>true</tt> if the credentials are valid * @throws ConnectorException */ protected boolean areCredentialsValid(Identity identity, char[] password) throws ConnectorException { try { final Object obj = ((Invocable) engine).invokeFunction("areCredentialsValid", identity, new String(password)); if(obj instanceof PasswordChangeRequiredException) { throw (PasswordChangeRequiredException)obj; } Boolean ok = (Boolean) obj; if (ok && identity.getPasswordStatus().getType().equals(PasswordStatusType.changeRequired)) { throw new PasswordChangeRequiredException(); } return ok; } catch (ScriptException e) { processScriptExecption(e); throw new ConnectorException("Failed script execution.", e); } catch (NoSuchMethodException e) { return super.areCredentialsValid(identity, password); } }
public final int compareTo(Identity identity) { return getPrincipalName().compareTo(identity.getPrincipalName()); }
private void assertValidCredentials(Identity identity, char[] password) throws ConnectorException, InvalidLoginCredentialsException { if (!areCredentialsValid(identity, password)) { throw new InvalidLoginCredentialsException("Invalid username or password: '" + identity.getPrincipalName() + "'"); } }
public void unlock() { setType(AccountStatusType.unlocked); setUnlocked(new Date()); } }
@Override public String toString() { StringBuilder builder = new StringBuilder(super.toString()); builder.append("[principalName='").append(getPrincipalName()); builder.append("', guid='").append(getGuid()).append("']"); return builder.toString(); }
/** * Very inefficient default implementation. It is highly recommended * sub-classes override this. * * @param name * @return role * @see {@link Connector#getIdentityByName(String)} * @throws PrincipalNotFoundException * @throws {@link ConnectorException} */ public Role getRoleByName(String name) throws PrincipalNotFoundException, ConnectorException { for (Iterator<Role> roleIterator = allRoles(); roleIterator.hasNext();) { Role role = roleIterator.next(); if (role.getPrincipalName().equals(name)) { return role; } } throw new PrincipalNotFoundException(name + " not found."); }
/** * Very inefficient default implementation. It is highly recommended * sub-classes override this. * * @param name * @return identity * @see {@link Connector#getIdentityByName(String)} * @throws PrincipalNotFoundException * @throws {@link ConnectorException} */ public Identity getIdentityByName(String name) throws PrincipalNotFoundException, ConnectorException { for (Iterator<Identity> identityIterator = allIdentities(); identityIterator.hasNext();) { Identity identity = identityIterator.next(); if (identity.getPrincipalName().equals(name)) { return identity; } } throw new PrincipalNotFoundException(name + " not found."); }