Search in sources :

Example 6 with GuiProfiledPrincipal

use of com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal in project midpoint by Evolveum.

the class PageBase method setTimeZone.

protected void setTimeZone(PageBase page) {
    String timeZone = null;
    GuiProfiledPrincipal principal = AuthUtil.getPrincipalUser();
    if (principal != null && principal.getCompiledGuiProfile() != null) {
        timeZone = principal.getCompiledGuiProfile().getDefaultTimezone();
    }
    if (timeZone != null) {
        WebSession.get().getClientInfo().getProperties().setTimeZone(TimeZone.getTimeZone(timeZone));
    }
}
Also used : GuiProfiledPrincipal(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 7 with GuiProfiledPrincipal

use of com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal in project midpoint by Evolveum.

the class PageSelfCredentials method showQuestions.

private boolean showQuestions() {
    GuiProfiledPrincipal principal = AuthUtil.getPrincipalUser();
    if (principal == null) {
        return false;
    }
    CredentialsPolicyType credentialsPolicyType = principal.getApplicableSecurityPolicy().getCredentials();
    if (credentialsPolicyType == null) {
        return false;
    }
    SecurityQuestionsCredentialsPolicyType securityQuestionsPolicy = credentialsPolicyType.getSecurityQuestions();
    if (securityQuestionsPolicy == null) {
        return false;
    }
    List<SecurityQuestionDefinitionType> secQuestAnsList = securityQuestionsPolicy.getQuestion();
    return secQuestAnsList != null && !secQuestAnsList.isEmpty();
}
Also used : GuiProfiledPrincipal(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal)

Example 8 with GuiProfiledPrincipal

use of com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal in project midpoint by Evolveum.

the class SecurityQuestionsPanel method loadPageModel.

private PasswordQuestionsDto loadPageModel() {
    LOGGER.debug("Loading user for Security Question Page.");
    GuiProfiledPrincipal principalUser = AuthUtil.getPrincipalUser();
    PasswordQuestionsDto dto = new PasswordQuestionsDto(principalUser.getOid());
    OperationResult result = new OperationResult(OPERATION_LOAD_USER);
    try {
        Task task = getPageBase().createSimpleTask(OPERATION_LOAD_USER);
        OperationResult subResult = result.createSubresult(OPERATION_LOAD_USER);
        PrismObject<UserType> user = getPageBase().getModelService().getObject(UserType.class, principalUser.getOid(), null, task, subResult);
        dto.setUserQuestionAnswers(createUsersSecurityQuestionsList(user));
        subResult.recordSuccessIfUnknown();
    } catch (Exception ex) {
        LoggingUtils.logExceptionOnDebugLevel(LOGGER, "Couldn't get user Questions, Probably not set yet", ex);
    } finally {
        result.recomputeStatus();
    }
    CredentialsPolicyType credPolicy = principalUser.getApplicableSecurityPolicy().getCredentials();
    List<SecurityQuestionDefinitionType> questionsDef = new ArrayList<>();
    // Security Policy set question numbers
    if (credPolicy != null && credPolicy.getSecurityQuestions() != null) {
        // Actual Policy Question List
        questionsDef = getEnabledSecurityQuestions(credPolicy);
    } else {
        LOGGER.debug("Couldn't load credentials for security questions");
    }
    result = new OperationResult(OPERATION_LOAD_QUESTION_POLICY);
    try {
        /*User's Pre-Set Question List*/
        List<SecurityQuestionAnswerDTO> userQuestionList = dto.getUserQuestionAnswers();
        /* check if user's set number of
             * questions matches the policy or not*/
        // Case that policy have more than users's number of numbers
        int questionSize = questionsDef.size();
        if (userQuestionList == null) {
            dto.getActualQuestionAnswers().addAll(executeAddingQuestions(questionSize, 0, questionsDef));
        // TODO same questions check should be implemented
        } else if (questionSize > userQuestionList.size()) {
            dto.getActualQuestionAnswers().addAll(executePasswordQuestionsAndAnswers(userQuestionList, questionsDef, userQuestionList.size()));
            // QUESTION NUMBER BIGGER THAN QUESTION LIST
            // rest of the questions
            int difference = questionSize - userQuestionList.size();
            dto.getActualQuestionAnswers().addAll(executeAddingQuestions(difference, userQuestionList.size(), questionsDef));
        } else if (questionSize <= userQuestionList.size()) {
            // QUESTION NUMBER SMALLER THAN QUESTION LIST OR EQUALS TO QUESTION LIST
            dto.getActualQuestionAnswers().addAll(executePasswordQuestionsAndAnswers(userQuestionList, questionsDef, 0));
        }
    } catch (Exception ex) {
        result.recordFatalError(getString("PageMyPasswordQuestions.message.couldNotLoadSysConfig"), ex);
    }
    return dto;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) GuiProfiledPrincipal(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal) SecurityQuestionAnswerDTO(com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)

Example 9 with GuiProfiledPrincipal

use of com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal in project midpoint by Evolveum.

the class PageTask method setupOwner.

private void setupOwner(PrismObjectWrapper<TaskType> taskWrapper) throws SchemaException {
    PrismReferenceWrapper<Referencable> taskOwner = taskWrapper.findReference(ItemPath.create(TaskType.F_OWNER_REF));
    if (taskOwner == null) {
        return;
    }
    PrismReferenceValueWrapperImpl<Referencable> taskOwnerValue = taskOwner.getValue();
    if (taskOwnerValue == null) {
        return;
    }
    if (taskOwnerValue.getNewValue() == null || taskOwnerValue.getNewValue().isEmpty()) {
        GuiProfiledPrincipal guiPrincipal = AuthUtil.getPrincipalUser();
        if (guiPrincipal == null) {
            // BTW something very strange must happened
            return;
        }
        FocusType focus = guiPrincipal.getFocus();
        taskOwnerValue.setRealValue(ObjectTypeUtil.createObjectRef(focus, SchemaConstants.ORG_DEFAULT));
    }
}
Also used : GuiProfiledPrincipal(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal)

Example 10 with GuiProfiledPrincipal

use of com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal in project midpoint by Evolveum.

the class GuiProfiledPrincipalManagerImpl method terminateLocalSessions.

@Override
public void terminateLocalSessions(TerminateSessionEvent terminateSessionEvent) {
    List<String> principalOids = terminateSessionEvent.getPrincipalOids();
    if (sessionRegistry != null && CollectionUtils.isNotEmpty(principalOids)) {
        List<Object> loggedInUsers = sessionRegistry.getAllPrincipals();
        for (Object principal : loggedInUsers) {
            if (!(principal instanceof GuiProfiledPrincipal)) {
                continue;
            }
            GuiProfiledPrincipal midPointPrincipal = (GuiProfiledPrincipal) principal;
            if (!principalOids.contains(midPointPrincipal.getOid())) {
                continue;
            }
            List<SessionInformation> sessionInfos = sessionRegistry.getAllSessions(principal, false);
            if (sessionInfos == null || sessionInfos.isEmpty()) {
                continue;
            }
            for (SessionInformation sessionInfo : sessionInfos) {
                sessionInfo.expireNow();
            }
        }
    }
}
Also used : SessionInformation(org.springframework.security.core.session.SessionInformation) GuiProfiledPrincipal(com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal) PrismObject(com.evolveum.midpoint.prism.PrismObject) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Aggregations

GuiProfiledPrincipal (com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal)17 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ConnectionEnvironment (com.evolveum.midpoint.security.api.ConnectionEnvironment)3 AuthenticationServiceException (org.springframework.security.authentication.AuthenticationServiceException)3 Authentication (org.springframework.security.core.Authentication)3 AuthenticationException (org.springframework.security.core.AuthenticationException)3 CompiledGuiProfile (com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile)2 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 ArrayList (java.util.ArrayList)2 SessionInformation (org.springframework.security.core.session.SessionInformation)2 TerminateSessionEvent (com.evolveum.midpoint.TerminateSessionEvent)1 MidpointAuthentication (com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)1 ModuleAuthentication (com.evolveum.midpoint.authentication.api.config.ModuleAuthentication)1 AuthenticationEvaluatorImpl (com.evolveum.midpoint.authentication.impl.evaluator.AuthenticationEvaluatorImpl)1 MailNonceAuthenticationToken (com.evolveum.midpoint.authentication.impl.module.authentication.token.MailNonceAuthenticationToken)1 SecurityQuestionsAuthenticationToken (com.evolveum.midpoint.authentication.impl.module.authentication.token.SecurityQuestionsAuthenticationToken)1 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1