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