use of com.evolveum.midpoint.web.page.admin.home.dto.MyPasswordsDto in project midpoint by Evolveum.
the class ChangePasswordPanel method initLayout.
private void initLayout(final boolean oldPasswordVisible) {
model = (LoadableModel<MyPasswordsDto>) getModel();
Label oldPasswordLabel = new Label(ID_OLD_PASSWORD_LABEL, createStringResource("PageSelfCredentials.oldPasswordLabel"));
add(oldPasswordLabel);
oldPasswordLabel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return oldPasswordVisible;
}
});
Label passwordLabel = new Label(ID_PASSWORD_LABEL, createStringResource("PageSelfCredentials.passwordLabel1"));
add(passwordLabel);
PasswordTextField oldPasswordField = new PasswordTextField(ID_OLD_PASSWORD_FIELD, new PropertyModel<String>(model, MyPasswordsDto.F_OLD_PASSWORD));
oldPasswordField.setRequired(false);
oldPasswordField.setResetPassword(false);
add(oldPasswordField);
oldPasswordField.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
public boolean isVisible() {
return oldPasswordVisible;
}
;
});
PasswordPanel passwordPanel = new PasswordPanel(ID_PASSWORD_PANEL, new PropertyModel<ProtectedStringType>(model, MyPasswordsDto.F_PASSWORD));
passwordPanel.getBaseFormComponent().add(new AttributeModifier("autofocus", ""));
add(passwordPanel);
WebMarkupContainer accountContainer = new WebMarkupContainer(ID_ACCOUNTS_CONTAINER);
List<IColumn<PasswordAccountDto, String>> columns = initColumns();
ListDataProvider<PasswordAccountDto> provider = new ListDataProvider<PasswordAccountDto>(this, new PropertyModel<List<PasswordAccountDto>>(model, MyPasswordsDto.F_ACCOUNTS));
TablePanel accounts = new TablePanel(ID_ACCOUNTS_TABLE, provider, columns);
accounts.setItemsPerPage(30);
accounts.setShowPaging(false);
if (model.getObject().getPropagation() != null && model.getObject().getPropagation().equals(CredentialsPropagationUserControlType.MAPPING)) {
accountContainer.setVisible(false);
}
accountContainer.add(accounts);
AjaxLink help = new AjaxLink(ID_BUTTON_HELP) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showHelpPerformed(target);
}
};
accountContainer.add(help);
add(accountContainer);
}
use of com.evolveum.midpoint.web.page.admin.home.dto.MyPasswordsDto in project midpoint by Evolveum.
the class PageAbstractSelfCredentials method loadPageModel.
private MyPasswordsDto loadPageModel() {
LOGGER.debug("Loading user and accounts.");
MyPasswordsDto dto = new MyPasswordsDto();
OperationResult result = new OperationResult(OPERATION_LOAD_USER_WITH_ACCOUNTS);
try {
String userOid = SecurityUtils.getPrincipalUser().getOid();
Task task = createSimpleTask(OPERATION_LOAD_USER);
OperationResult subResult = result.createSubresult(OPERATION_LOAD_USER);
user = getModelService().getObject(UserType.class, userOid, null, task, subResult);
subResult.recordSuccessIfUnknown();
dto.getAccounts().add(createDefaultPasswordAccountDto(user));
CredentialsPolicyType credentialsPolicyType = getPasswordCredentialsPolicy();
if (credentialsPolicyType != null) {
PasswordCredentialsPolicyType passwordCredentialsPolicy = credentialsPolicyType.getPassword();
if (passwordCredentialsPolicy != null) {
CredentialsPropagationUserControlType propagationUserControl = passwordCredentialsPolicy.getPropagationUserControl();
if (propagationUserControl != null) {
dto.setPropagation(propagationUserControl);
}
PasswordChangeSecurityType passwordChangeSecurity = passwordCredentialsPolicy.getPasswordChangeSecurity();
if (passwordChangeSecurity != null) {
dto.setPasswordChangeSecurity(passwordChangeSecurity);
}
}
}
if (dto.getPropagation() == null || dto.getPropagation().equals(CredentialsPropagationUserControlType.USER_CHOICE)) {
PrismReference reference = user.findReference(UserType.F_LINK_REF);
if (reference == null || reference.getValues() == null) {
LOGGER.debug("No accounts found for user {}.", new Object[] { userOid });
return dto;
}
final Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(ShadowType.F_RESOURCE, GetOperationOptions.createResolve());
List<PrismReferenceValue> values = reference.getValues();
for (PrismReferenceValue value : values) {
subResult = result.createSubresult(OPERATION_LOAD_ACCOUNT);
try {
String accountOid = value.getOid();
task = createSimpleTask(OPERATION_LOAD_ACCOUNT);
PrismObject<ShadowType> account = getModelService().getObject(ShadowType.class, accountOid, options, task, subResult);
dto.getAccounts().add(createPasswordAccountDto(account));
subResult.recordSuccessIfUnknown();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load account", ex);
subResult.recordFatalError("Couldn't load account.", ex);
}
}
}
result.recordSuccessIfUnknown();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load accounts", ex);
result.recordFatalError("Couldn't load accounts", ex);
} finally {
result.recomputeStatus();
}
Collections.sort(dto.getAccounts());
if (!result.isSuccess() && !result.isHandledError()) {
showResult(result);
}
return dto;
}
use of com.evolveum.midpoint.web.page.admin.home.dto.MyPasswordsDto in project midpoint by Evolveum.
the class PageAbstractSelfCredentials method setEncryptedPasswordData.
protected void setEncryptedPasswordData(EncryptedDataType data) {
MyPasswordsDto dto = model.getObject();
ProtectedStringType password = dto.getPassword();
if (password != null) {
password.setEncryptedData(data);
}
}
use of com.evolveum.midpoint.web.page.admin.home.dto.MyPasswordsDto in project midpoint by Evolveum.
the class PageResetPassword method finishChangePassword.
@Override
protected void finishChangePassword(final OperationResult result, AjaxRequestTarget target, boolean showFeedback) {
if (result.getStatus() == OperationResultStatus.SUCCESS) {
result.setMessage(getString("PageResetPassword.reset.successful"));
setResponsePage(PageLogin.class);
MyPasswordsDto passwords = getPasswordDto();
PrismObject<? extends FocusType> focus = passwords.getFocus();
if (focus == null) {
SecurityContextHolder.getContext().setAuthentication(null);
return;
}
FocusType focusType = focus.asObjectable();
if (focusType.getCredentials() != null && focusType.getCredentials().getNonce() != null) {
try {
ObjectDelta<UserType> deleteNonceDelta = getPrismContext().deltaFactory().object().createModificationDeleteContainer(UserType.class, focusType.getOid(), SchemaConstants.PATH_NONCE, focusType.getCredentials().getNonce().clone());
WebModelServiceUtils.save(deleteNonceDelta, result, this);
} catch (SchemaException e) {
// nothing to do, just let the nonce here.. it will be invalid
}
}
SecurityContextHolder.getContext().setAuthentication(null);
showResult(result);
target.add(getFeedbackPanel());
} else if (showFeedback) {
showResult(result);
}
target.add(getFeedbackPanel());
// get(ID_MAIN_FORM).setVisible(false);
// success(getString("PageShowPassword.success")); //TODO uncomment when remove old mechanism
}
use of com.evolveum.midpoint.web.page.admin.home.dto.MyPasswordsDto in project midpoint by Evolveum.
the class ChangePasswordPanel method loadPageModel.
private MyPasswordsDto loadPageModel() {
LOGGER.debug("Loading user and accounts.");
MyPasswordsDto passwordsDto = new MyPasswordsDto();
OperationResult result = new OperationResult(OPERATION_LOAD_USER_WITH_ACCOUNTS);
try {
String focusOid = AuthUtil.getPrincipalUser().getOid();
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_USER);
OperationResult subResult = result.createSubresult(OPERATION_LOAD_USER);
PrismObject<? extends FocusType> focus = getPageBase().getModelService().getObject(FocusType.class, focusOid, null, task, subResult);
passwordsDto = createMyPasswordsDto(focus);
subResult.recordSuccessIfUnknown();
getModel().setObject(passwordsDto);
if (!shouldShowPasswordPropagation()) {
LOGGER.debug("Skip loading account, because policy said so (enabled {} propagation).", passwordsDto.getPropagation());
return passwordsDto;
}
PrismReference reference = focus.findReference(FocusType.F_LINK_REF);
if (reference == null || CollectionUtils.isEmpty(reference.getValues())) {
LOGGER.debug("No accounts found for user {}.", focusOid);
return passwordsDto;
}
addAccountsToMyPasswordsDto(passwordsDto, reference.getValues(), task, result);
result.recordSuccessIfUnknown();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load accounts", ex);
result.recordFatalError(getString("PageAbstractSelfCredentials.message.couldntLoadAccounts.fatalError"), ex);
} finally {
result.recomputeStatus();
}
Collections.sort(passwordsDto.getAccounts());
if (!result.isSuccess() && !result.isHandledError()) {
getPageBase().showResult(result);
}
return passwordsDto;
}
Aggregations