use of com.evolveum.midpoint.web.page.admin.home.dto.PersonalInfoDto in project midpoint by Evolveum.
the class PersonalInfoPanel method loadPersonalInfo.
private PersonalInfoDto loadPersonalInfo() {
FocusType focus = AuthUtil.getPrincipalUser().getFocus();
AuthenticationBehavioralDataType behaviour = focus.getBehavior() != null ? focus.getBehavior().getAuthentication() : null;
PersonalInfoDto dto = new PersonalInfoDto();
if (behaviour != null) {
if (behaviour.getPreviousSuccessfulLogin() != null) {
dto.setLastLoginDate(MiscUtil.asDate(behaviour.getPreviousSuccessfulLogin().getTimestamp()));
dto.setLastLoginFrom(behaviour.getPreviousSuccessfulLogin().getFrom());
}
if (behaviour.getLastFailedLogin() != null) {
dto.setLastFailDate(MiscUtil.asDate(behaviour.getLastFailedLogin().getTimestamp()));
dto.setLastFailFrom(behaviour.getLastFailedLogin().getFrom());
}
}
Task task = getPageBase().createSimpleTask(OPERATION_GET_CREDENTIALS_POLICY);
CredentialsPolicyType credentialsPolicyType = WebComponentUtil.getPasswordCredentialsPolicy(focus.asPrismContainer(), getPageBase(), task);
Duration maxAge = credentialsPolicyType != null && credentialsPolicyType.getPassword() != null ? credentialsPolicyType.getPassword().getMaxAge() : null;
if (maxAge != null) {
MetadataType credentialMetadata = focus.getCredentials() != null && focus.getCredentials().getPassword() != null ? focus.getCredentials().getPassword().getMetadata() : null;
XMLGregorianCalendar changeTimestamp = MiscSchemaUtil.getChangeTimestamp(credentialMetadata);
if (changeTimestamp != null) {
XMLGregorianCalendar passwordValidUntil = XmlTypeConverter.addDuration(changeTimestamp, maxAge);
dto.setPasswordExp(MiscUtil.asDate(passwordValidUntil));
}
}
return dto;
}
use of com.evolveum.midpoint.web.page.admin.home.dto.PersonalInfoDto in project midpoint by Evolveum.
the class PersonalInfoPanel method initLayout.
protected void initLayout(PageBase parentPage) {
DateLabelComponent lastLoginDate = new DateLabelComponent(ID_LAST_LOGIN_DATE, new AbstractReadOnlyModel<Date>() {
@Override
public Date getObject() {
PersonalInfoDto dto = getModel().getObject();
return dto == null ? null : dto.getLastLoginDate();
}
}, DateLabelComponent.LONG_MEDIUM_STYLE);
lastLoginDate.setBeforeTextOnDateNull(parentPage.getString("PersonalInfoPanel.never"));
add(lastLoginDate);
Label lastLoginFrom = new Label(ID_LAST_LOGIN_FROM, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
PersonalInfoDto dto = getModel().getObject();
return StringUtils.isNotEmpty(dto.getLastLoginFrom()) ? dto.getLastLoginFrom() : PersonalInfoPanel.this.getString("PersonalInfoPanel.undefined");
}
});
add(lastLoginFrom);
DateLabelComponent lastFailDate = new DateLabelComponent(ID_LAST_FAIL_DATE, new AbstractReadOnlyModel<Date>() {
@Override
public Date getObject() {
PersonalInfoDto dto = getModel().getObject();
return dto == null ? null : dto.getLastFailDate();
}
}, DateLabelComponent.LONG_MEDIUM_STYLE);
lastFailDate.setBeforeTextOnDateNull(parentPage.getString("PersonalInfoPanel.never"));
add(lastFailDate);
Label lastFailFrom = new Label(ID_LAST_FAIL_FROM, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
PersonalInfoDto dto = getModel().getObject();
return StringUtils.isNotEmpty(dto.getLastFailFrom()) ? dto.getLastFailFrom() : PersonalInfoPanel.this.getString("PersonalInfoPanel.undefined");
}
});
add(lastFailFrom);
Label passwordExp = new Label(ID_PASSWORD_EXP, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
PersonalInfoDto dto = getModel().getObject();
return dto.getPasswordExp() != null ? WebComponentUtil.formatDate(dto.getPasswordExp()) : PersonalInfoPanel.this.getString("PersonalInfoPanel.undefined");
}
});
add(passwordExp);
}
use of com.evolveum.midpoint.web.page.admin.home.dto.PersonalInfoDto in project midpoint by Evolveum.
the class PersonalInfoPanel method initLayout.
protected void initLayout() {
DateLabelComponent lastLoginDate = new DateLabelComponent(ID_LAST_LOGIN_DATE, new IModel<Date>() {
private static final long serialVersionUID = 1L;
@Override
public Date getObject() {
if (getModel() == null) {
return null;
}
PersonalInfoDto dto = getModel().getObject();
return dto == null ? null : dto.getLastLoginDate();
}
}, WebComponentUtil.getLongDateTimeFormat(getPageBase()));
lastLoginDate.setBeforeTextOnDateNull(getPageBase().getString("PersonalInfoPanel.never"));
add(lastLoginDate);
Label lastLoginFrom = new Label(ID_LAST_LOGIN_FROM, new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (getModel() == null) {
return PersonalInfoPanel.this.getString("PersonalInfoPanel.undefined");
}
PersonalInfoDto dto = getModel().getObject();
return StringUtils.isNotEmpty(dto.getLastLoginFrom()) ? dto.getLastLoginFrom() : PersonalInfoPanel.this.getString("PersonalInfoPanel.undefined");
}
});
add(lastLoginFrom);
DateLabelComponent lastFailDate = new DateLabelComponent(ID_LAST_FAIL_DATE, new IModel<Date>() {
private static final long serialVersionUID = 1L;
@Override
public Date getObject() {
if (getModel() == null) {
return null;
}
PersonalInfoDto dto = getModel().getObject();
return dto == null ? null : dto.getLastFailDate();
}
}, WebComponentUtil.getLongDateTimeFormat(getPageBase()));
lastFailDate.setBeforeTextOnDateNull(getPageBase().getString("PersonalInfoPanel.never"));
add(lastFailDate);
Label lastFailFrom = new Label(ID_LAST_FAIL_FROM, new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (getModel() == null) {
return PersonalInfoPanel.this.getString("PersonalInfoPanel.undefined");
}
PersonalInfoDto dto = getModel().getObject();
return StringUtils.isNotEmpty(dto.getLastFailFrom()) ? dto.getLastFailFrom() : PersonalInfoPanel.this.getString("PersonalInfoPanel.undefined");
}
});
add(lastFailFrom);
DateLabelComponent passwordExp = new DateLabelComponent(ID_PASSWORD_EXP, new IModel<Date>() {
private static final long serialVersionUID = 1L;
@Override
public Date getObject() {
if (getModel() == null) {
return null;
}
PersonalInfoDto dto = getModel().getObject();
return dto == null ? null : dto.getPasswordExp();
}
}, WebComponentUtil.getLongDateTimeFormat(getPageBase()));
passwordExp.setBeforeTextOnDateNull(getPageBase().getString("PersonalInfoPanel.never"));
add(passwordExp);
}
Aggregations