Search in sources :

Example 1 with PersonalInfoDto

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;
}
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)

Example 2 with PersonalInfoDto

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);
}
Also used : PersonalInfoDto(com.evolveum.midpoint.web.page.admin.home.dto.PersonalInfoDto) Label(org.apache.wicket.markup.html.basic.Label) DateLabelComponent(com.evolveum.midpoint.web.component.DateLabelComponent) Date(java.util.Date)

Example 3 with PersonalInfoDto

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);
}
Also used : PersonalInfoDto(com.evolveum.midpoint.web.page.admin.home.dto.PersonalInfoDto) Label(org.apache.wicket.markup.html.basic.Label) DateLabelComponent(com.evolveum.midpoint.web.component.DateLabelComponent) Date(java.util.Date)

Aggregations

PersonalInfoDto (com.evolveum.midpoint.web.page.admin.home.dto.PersonalInfoDto)3 DateLabelComponent (com.evolveum.midpoint.web.component.DateLabelComponent)2 Date (java.util.Date)2 Label (org.apache.wicket.markup.html.basic.Label)2 Task (com.evolveum.midpoint.task.api.Task)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