@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 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); } } }
/** * 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); } }
@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(); }
PasswordStatus pwdStatus = new PasswordStatus(); i.setPasswordStatus(pwdStatus);