Skip to content

Commit

Permalink
Credentials page is finished
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Oct 15, 2015
1 parent bddc417 commit 215b9bf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
Expand Up @@ -258,9 +258,8 @@ private PasswordAccountDto createPasswordAccountDto(PrismObject<ShadowType> acco
}

private void onSavePerformed(AjaxRequestTarget target) {
List<PasswordAccountDto> accounts = WebMiscUtil.getSelectedData(
(TablePanel) get(createComponentPath(ID_MAIN_FORM, ID_TAB_PANEL, ID_PANEL, ChangePasswordPanel.ID_ACCOUNTS_TABLE)));
if (accounts.isEmpty()) {
List<PasswordAccountDto> selectedAccounts = getSelectedAccountsList();
if (selectedAccounts.isEmpty()) {
warn(getString("PageMyPasswords.noAccountSelected"));
target.add(getFeedbackPanel());
return;
Expand All @@ -278,14 +277,12 @@ private void onSavePerformed(AjaxRequestTarget target) {
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();


for (PasswordAccountDto accDto : accounts) {
for (PasswordAccountDto accDto : selectedAccounts) {
if (accDto.getCssClass().equals(ChangePasswordPanel.SELECTED_ACCOUNT_ICON_CSS)) {
PrismObjectDefinition objDef = accDto.isMidpoint() ?
registry.findObjectDefinitionByCompileTimeClass(UserType.class) :
registry.findObjectDefinitionByCompileTimeClass(ShadowType.class);

// UserType.F_LINK_REF
// ShadowType.REF
PropertyDelta delta = PropertyDelta.createModificationReplaceProperty(valuePath, objDef, password, password);

Class<? extends ObjectType> type = accDto.isMidpoint() ? UserType.class : ShadowType.class;
Expand All @@ -308,12 +305,32 @@ private void onSavePerformed(AjaxRequestTarget target) {
target.add(getFeedbackPanel());
} else {
showResultInSession(result);
setResponsePage(PageDashboard.class);
if (WebMiscUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DASHBOARD_URL,
AuthorizationConstants.AUTZ_UI_HOME_ALL_URL)) {
setResponsePage(PageDashboard.class);
} else {
setResponsePage(PageSelfDashboard.class);
}
}
}

private List<PasswordAccountDto> getSelectedAccountsList(){
List<PasswordAccountDto> passwordAccountDtos = model.getObject().getAccounts();
List<PasswordAccountDto> selectedAccountList = new ArrayList<>();
for (PasswordAccountDto passwordAccountDto : passwordAccountDtos){
if (passwordAccountDto.getCssClass().equals(ChangePasswordPanel.SELECTED_ACCOUNT_ICON_CSS)){
selectedAccountList.add(passwordAccountDto);
}
}
return selectedAccountList;
}
private void onCancelPerformed(AjaxRequestTarget target) {
setResponsePage(PageDashboard.class);
if (WebMiscUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DASHBOARD_URL,
AuthorizationConstants.AUTZ_UI_HOME_ALL_URL)) {
setResponsePage(PageDashboard.class);
} else {
setResponsePage(PageSelfDashboard.class);
}
}

private List<ShadowType> loadShadowTypeList() {
Expand Down
Expand Up @@ -16,7 +16,9 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
Expand All @@ -39,7 +41,7 @@ public class ChangePasswordPanel extends SimplePanel<MyPasswordsDto> {
private static final String ID_PASSWORD_LABEL = "passwordLabel";
private static final String ID_CONFIRM_PASSWORD_LABEL = "confirmPasswordLabel";
public static final String ID_ACCOUNTS_TABLE = "accounts";
public static final String SELECTED_ACCOUNT_ICON_CSS = "fa fa-square";
public static final String SELECTED_ACCOUNT_ICON_CSS = "fa fa-check-square-o";
public static final String DESELECTED_ACCOUNT_ICON_CSS = "fa fa-square-o";
public static final String PROPAGATED_ACCOUNT_ICON_CSS = "fa fa-sign-out";
private static final Trace LOGGER = TraceManager.getTrace(ChangePasswordPanel.class);
Expand Down Expand Up @@ -69,7 +71,7 @@ protected void initLayout() {
Label confirmPasswordLabel = new Label(ID_CONFIRM_PASSWORD_LABEL, createStringResource("PageSelfCredentials.passwordLabel2"));
add(confirmPasswordLabel);

PasswordPanel passwordPanel = new PasswordPanel(ID_PASSWORD_PANEL, new PropertyModel<String>(model, MyPasswordsDto.F_PASSWORD));
PasswordPanel passwordPanel = new PasswordPanel(ID_PASSWORD_PANEL, new PropertyModel<ProtectedStringType>(model, MyPasswordsDto.F_PASSWORD));
add(passwordPanel);

List<IColumn<PasswordAccountDto, String>> columns = initColumns();
Expand Down

0 comments on commit 215b9bf

Please sign in to comment.