Remove usage of http password get api
The get api for http password has been removed [1] and the remaining
usage caused fatal errors [2] in the service user display.
Remove the retrieval of the password. On generating a new password it
is still displayed to the user.
[1] https://gerrit-review.googlesource.com/#/c/99738/
[2] https://groups.google.com/forum/#!topic/repo-discuss/76dDi_uauYw
Change-Id: I5f11292401dc3c6f18fd9157f2b0fa7e56d26a45
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/ServiceUserScreen.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/ServiceUserScreen.java
index bece2c3..1886c72 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/ServiceUserScreen.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/client/ServiceUserScreen.java
@@ -48,57 +48,45 @@
new RestApi("config").id("server").view(Plugin.get().getPluginName(), "serviceusers")
.id(serviceUser).get(new AsyncCallback<ServiceUserInfo>() {
- @Override
- public void onSuccess(final ServiceUserInfo serviceUserInfo) {
- new RestApi("config").id("server").view(Plugin.get().getPluginName(), "serviceusers")
- .id(serviceUser).view("password.http").get(new AsyncCallback<NativeString>() {
+ @Override
+ public void onSuccess(final ServiceUserInfo serviceUserInfo) {
+ new RestApi("config").id("server")
+ .view(Plugin.get().getPluginName(), "config")
+ .get(new AsyncCallback<ConfigInfo>() {
+ @Override
+ public void onSuccess(final ConfigInfo configInfo) {
+ AccountCapabilities.all(new AsyncCallback<AccountCapabilities>() {
@Override
- public void onSuccess(final NativeString httpPassword) {
- new RestApi("config").id("server")
- .view(Plugin.get().getPluginName(), "config")
- .get(new AsyncCallback<ConfigInfo>() {
- @Override
- public void onSuccess(final ConfigInfo configInfo) {
- AccountCapabilities.all(new AsyncCallback<AccountCapabilities>() {
- @Override
- public void onSuccess(AccountCapabilities ac) {
- boolean isAdmin = ac.canPerform("administrateServer");
- display(serviceUserInfo,
- httpPassword.asString(),
- configInfo.getAllowEmail() || isAdmin,
- configInfo.getAllowOwner() || isAdmin,
- configInfo.getAllowHttpPassword() || isAdmin);
- }
-
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- }, "administrateServer");
- }
-
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
+ public void onSuccess(AccountCapabilities ac) {
+ boolean isAdmin = ac.canPerform("administrateServer");
+ display(serviceUserInfo,
+ configInfo.getAllowEmail() || isAdmin,
+ configInfo.getAllowOwner() || isAdmin,
+ configInfo.getAllowHttpPassword() || isAdmin);
}
@Override
public void onFailure(Throwable caught) {
// never invoked
}
- });
- }
+ }, "administrateServer");
+ }
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
}
- private void display(ServiceUserInfo info, String httpPassword,
+ private void display(ServiceUserInfo info,
boolean allowEmail, boolean allowOwner, boolean allowHttpPassword) {
MyTable t = new MyTable();
t.setStyleName("serviceuser-serviceUserInfoTable");
@@ -146,7 +134,7 @@
}
t.addRow(
"HTTP Password",
- createHttpPasswordWidget(info.username(), httpPassword,
+ createHttpPasswordWidget(info.username(),
allowHttpPassword));
t.addRow("Owner Group", createOwnerWidget(info, allowOwner));
t.addRow("Created By", info.getDisplayName());
@@ -206,11 +194,11 @@
}
private Widget createHttpPasswordWidget(final String serviceUser,
- String httpPassword, boolean allowHttpPassword) {
+ boolean allowHttpPassword) {
if (allowHttpPassword) {
HorizontalPanel p = new HorizontalPanel();
- final CopyableLabel label = new CopyableLabel(httpPassword);
- label.setVisible(!httpPassword.isEmpty());
+ final CopyableLabel label = new CopyableLabel("");
+ label.setVisible(false);
p.add(label);
// The redNot icon is only used as temporary measure until gerrit core
@@ -237,7 +225,7 @@
});
}
});
- delete.setVisible(!httpPassword.isEmpty());
+ delete.setVisible(true);
p.add(delete);
Image generate = new Image(ServiceUserPlugin.RESOURCES.gear());
@@ -267,7 +255,7 @@
p.add(generate);
return p;
} else {
- return new CopyableLabel(httpPassword);
+ return new CopyableLabel("");
}
}