use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TargetUserSelectorComponent method getTargetUsersButtonTitle.
private IModel<String> getTargetUsersButtonTitle() {
return new LoadableModel<String>(true) {
public String load() {
if (getRoleCatalogStorage().isSelfRequest()) {
return createStringResource("AssignmentCatalogPanel.requestForMe").getString();
}
List<PrismObject<UserType>> targetUsersList = getRoleCatalogStorage().getTargetUserList();
if (targetUsersList.size() == 1) {
return createStringResource("AssignmentCatalogPanel.requestFor").getString() + " " + targetUsersList.get(0).getName().getOrig();
}
StringBuilder sb = new StringBuilder(createStringResource("AssignmentCatalogPanel.requestForMultiple", targetUsersList.size()).getString());
sb.append(System.lineSeparator());
if (getRoleCatalogStorage().isMultiUserRequest()) {
List<PrismObject<UserType>> sortedList = getRoleCatalogStorage().getTargetUserList();
Collections.sort(sortedList, new Comparator<PrismObject<UserType>>() {
@Override
public int compare(PrismObject<UserType> u1, PrismObject<UserType> u2) {
return String.CASE_INSENSITIVE_ORDER.compare(u1.getName().getOrig(), u2.getName().getOrig());
}
});
int columnsAmount = sortedList.size() / TARGET_USERS_TITLE_ROWS;
Iterator<PrismObject<UserType>> it = sortedList.iterator();
while (it.hasNext()) {
for (int i = 0; i <= columnsAmount; i++) {
if (it.hasNext()) {
PrismObject user = it.next();
sb.append(user.getName().getOrig());
if (it.hasNext()) {
sb.append(",\t");
}
}
}
sb.append(System.lineSeparator());
}
}
return sb.toString();
}
};
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class PersonalInfoPanel method loadPersonalInfo.
private PersonalInfoDto loadPersonalInfo() {
UserType user = SecurityUtils.getPrincipalUser().getUser();
CredentialsType credentials = user.getCredentials();
PersonalInfoDto dto = new PersonalInfoDto();
if (credentials != null) {
PasswordType password = credentials.getPassword();
if (password.getPreviousSuccessfulLogin() != null) {
dto.setLastLoginDate(MiscUtil.asDate(password.getPreviousSuccessfulLogin().getTimestamp()));
dto.setLastLoginFrom(password.getPreviousSuccessfulLogin().getFrom());
}
if (password.getLastFailedLogin() != null) {
dto.setLastFailDate(MiscUtil.asDate(password.getLastFailedLogin().getTimestamp()));
dto.setLastFailFrom(password.getLastFailedLogin().getFrom());
}
}
if (user.getActivation() != null) {
//todo fix, this is not password expiration date...
dto.setPasswordExp(MiscUtil.asDate(user.getActivation().getValidTo()));
}
return dto;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class PageMyPasswordQuestions method loadUserWrapper.
private ObjectWrapper loadUserWrapper(PrismObject<UserType> userToEdit) {
OperationResult result = new OperationResult(OPERATION_LOAD_USER);
PrismObject<UserType> user = null;
Task task = createSimpleTask(OPERATION_LOAD_USER);
try {
Collection options = SelectorOptions.createCollection(UserType.F_CREDENTIALS, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
user = getModelService().getObject(UserType.class, SecurityUtils.getPrincipalUser().getOid(), options, task, result);
result.recordSuccess();
} catch (Exception ex) {
result.recordFatalError("Couldn't get user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user PageMyQuestions", ex);
}
showResult(result, false);
if (user == null) {
throw new RestartResponseException(PageDashboard.class);
}
ContainerStatus status = ContainerStatus.MODIFYING;
ObjectWrapperFactory owf = new ObjectWrapperFactory(this);
ObjectWrapper wrapper;
try {
wrapper = owf.createObjectWrapper("pageMyPasswordQuestions.userDetails", null, user, status, task);
} catch (Exception ex) {
result.recordFatalError("Couldn't get user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user", ex);
wrapper = owf.createObjectWrapper("pageMyPasswordQuestions.userDetails", null, user, null, null, status, false);
}
// ObjectWrapper wrapper = new ObjectWrapper("pageUser.userDetails", null, user, status);
showResult(wrapper.getResult(), false);
return wrapper;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class PageMyPasswordQuestions method updateQuestions.
private void updateQuestions(String useroid, AjaxRequestTarget target) {
Task task = createSimpleTask(OPERATION_SAVE_QUESTIONS);
OperationResult result = new OperationResult(OPERATION_SAVE_QUESTIONS);
SchemaRegistry registry = getPrismContext().getSchemaRegistry();
SecurityQuestionAnswerType[] answerTypeList = new SecurityQuestionAnswerType[questionNumber];
try {
int listnum = 0;
for (Iterator iterator = pqPanels.iterator(); iterator.hasNext(); ) {
MyPasswordQuestionsPanel type = (MyPasswordQuestionsPanel) iterator.next();
SecurityQuestionAnswerType answerType = new SecurityQuestionAnswerType();
ProtectedStringType answer = new ProtectedStringType();
answer.setClearValue(((TextField<String>) type.get(MyPasswordQuestionsPanel.F_ANSWER)).getModelObject());
answerType.setQuestionAnswer(answer);
//used apache's unescapeHtml method for special chars like \'
String results = StringEscapeUtils.unescapeHtml((type.get(MyPasswordQuestionsPanel.F_QUESTION)).getDefaultModelObjectAsString());
answerType.setQuestionIdentifier(getQuestionIdentifierFromQuestion(results));
answerTypeList[listnum] = answerType;
listnum++;
}
//if(answerTypeList.length !=)
// fill in answerType data here
ItemPath path = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_SECURITY_QUESTIONS, SecurityQuestionsCredentialsType.F_QUESTION_ANSWER);
ObjectDelta<UserType> objectDelta = ObjectDelta.createModificationReplaceContainer(UserType.class, useroid, path, getPrismContext(), answerTypeList);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
getModelService().executeChanges(deltas, null, task, result);
/*
System.out.println("getModel");
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
PasswordQuestionsDto dto = new PasswordQuestionsDto();
PrismObjectDefinition objDef =registry.findObjectDefinitionByCompileTimeClass(UserType.class);
Class<? extends ObjectType> type = UserType.class;
final ItemPath valuePath = new ItemPath(SchemaConstantsGenerated.C_CREDENTIALS,
CredentialsType.F_SECURITY_QUESTIONS, SecurityQuestionsCredentialsType.F_QUESTION_ANSWER);
SecurityQuestionAnswerType secQuesAnsType= new SecurityQuestionAnswerType();
ProtectedStringType protStrType= new ProtectedStringType();
protStrType.setClearValue("deneme");
secQuesAnsType.setQuestionAnswer(protStrType);
dto.setSecurityAnswers(new ArrayList<SecurityQuestionAnswerType>());
dto.getSecurityAnswers().add(secQuesAnsType);
PropertyDelta delta = PropertyDelta.createModificationReplaceProperty(valuePath, objDef, dto.getSecurityAnswers().get(0).getQuestionAnswer());
// PropertyDelta delta= PropertyDelta.createModifica
System.out.println("Update Questions3");
deltas.add(ObjectDelta.createModifyDelta(useroid, delta, type, getPrismContext()));
System.out.println("Update Questions4");
getModelService().executeChanges(deltas, null, createSimpleTask(OPERATION_SAVE_QUESTIONS), result);
System.out.println("Update Questions5");
*/
success(getString("message.success"));
target.add(getFeedbackPanel());
} catch (Exception ex) {
error(getString("message.error"));
target.add(getFeedbackPanel());
ex.printStackTrace();
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class RunReportPopupPanel method createUserAttributeListModel.
private IModel<List<String>> createUserAttributeListModel(Class type) {
final List<String> attrList = new ArrayList();
PrismObjectDefinition<UserType> userDefinition = getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
List<? extends ItemDefinition> itemDefs = userDefinition.getDefinitions();
for (ItemDefinition id : itemDefs) {
if (id instanceof PrismPropertyDefinition && ((((PrismPropertyDefinition) id).isIndexed() == null) || (((PrismPropertyDefinition) id).isIndexed() == true))) {
if (id.getTypeClass() != null && id.getTypeClass().equals(type)) {
attrList.add(id.getName().getLocalPart());
}
}
}
return new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
return attrList;
}
};
}
Aggregations