@Override public void onClick(ClickEvent event) { super.onClick(event); PasswordTextBox password1 = popup.getPassword1(); PasswordTextBox password2 = popup.getPassword2(); UserSecurityInfo userInfo = popup.getUser(); RealmSecurityInfo realmInfo = AggregateUI.getUI().getRealmInfo(); String pw1 = password1.getText(); String pw2 = password2.getText(); if (pw1 == null || pw2 == null || pw1.length() == 0) { Window.alert("Password cannot be blank"); } else if (pw1.equals(pw2)) { if (realmInfo == null || userInfo == null) { Window.alert("Unable to obtain required information from server"); } else { CredentialsInfo credential; try { credential = CredentialsInfoBuilder.build(userInfo.getUsername(), realmInfo, pw1); } catch (NoSuchAlgorithmException e) { Window.alert("Unable to build credentials hash"); return; } baseUrl = realmInfo.getChangeUserPasswordURL(); // Construct a JSOP request String parameters = credential.getRequestParameters(); String url = baseUrl + "?" + parameters + "&callback="; getJson(jsonRequestId++, url, this); } } else { Window.alert("The passwords do not match. Please retype the password."); } }
public void handleJsonResponse(String username, String status) { if (username == null) { Window.alert("JSON change-password request to " + baseUrl + " failed"); } else { // process response... if (!(status != null && "OK".equals(status))) { Window.alert( "Change password request " + ((username == null) ? "" : ("for " + username + " ")) + "failed.\n" + "JSON change-password request to\n " + baseUrl + "\nreturned: " + status); } } popup.hide(); }