Search in sources :

Example 1 with AuthenticationBehavioralDataType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationBehavioralDataType 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;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Task(com.evolveum.midpoint.task.api.Task) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) PersonalInfoDto(com.evolveum.midpoint.web.page.admin.home.dto.PersonalInfoDto) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) Duration(javax.xml.datatype.Duration) CredentialsPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType) AuthenticationBehavioralDataType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationBehavioralDataType)

Aggregations

Task (com.evolveum.midpoint.task.api.Task)1 PersonalInfoDto (com.evolveum.midpoint.web.page.admin.home.dto.PersonalInfoDto)1 AuthenticationBehavioralDataType (com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationBehavioralDataType)1 CredentialsPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsPolicyType)1 FocusType (com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType)1 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)1 Duration (javax.xml.datatype.Duration)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1