Remove old RPC backend for MyIdentitiesScreen
MyIdentitiesScreen has been migrated to REST API by [1]. The old RPC backend will not be used anymore and thus can be removed. [1] https://gerrit-review.googlesource.com/#/c/95952/ Change-Id: I7d2b255b1ea7df455656cb8a4410cb0f279416d2
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
|
||||
package com.google.gerrit.httpd.rpc;
|
||||
|
||||
import com.google.gerrit.httpd.rpc.account.AccountModule;
|
||||
import com.google.gerrit.httpd.rpc.project.ProjectModule;
|
||||
|
||||
/** Registers servlets to answer RPCs from client UI. */
|
||||
@@ -27,7 +26,6 @@ public class UiRpcModule extends RpcServletModule {
|
||||
protected void configureServlets() {
|
||||
rpc(SystemInfoServiceImpl.class);
|
||||
|
||||
install(new AccountModule());
|
||||
install(new ProjectModule());
|
||||
}
|
||||
}
|
||||
|
@@ -1,38 +0,0 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.httpd.rpc.account;
|
||||
|
||||
import com.google.gerrit.extensions.config.FactoryModule;
|
||||
import com.google.gerrit.httpd.rpc.RpcServletModule;
|
||||
import com.google.gerrit.httpd.rpc.UiRpcModule;
|
||||
|
||||
public class AccountModule extends RpcServletModule {
|
||||
public AccountModule() {
|
||||
super(UiRpcModule.PREFIX);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureServlets() {
|
||||
install(
|
||||
new FactoryModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
factory(DeleteExternalIds.Factory.class);
|
||||
factory(ExternalIdDetailFactory.Factory.class);
|
||||
}
|
||||
});
|
||||
rpc(AccountSecurityImpl.class);
|
||||
}
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.httpd.rpc.account;
|
||||
|
||||
import com.google.gerrit.common.data.AccountSecurity;
|
||||
import com.google.gerrit.httpd.rpc.BaseServiceImplementation;
|
||||
import com.google.gerrit.reviewdb.client.AccountExternalId;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
class AccountSecurityImpl extends BaseServiceImplementation implements AccountSecurity {
|
||||
private final DeleteExternalIds.Factory deleteExternalIdsFactory;
|
||||
private final ExternalIdDetailFactory.Factory externalIdDetailFactory;
|
||||
|
||||
@Inject
|
||||
AccountSecurityImpl(
|
||||
final Provider<ReviewDb> schema,
|
||||
final Provider<CurrentUser> currentUser,
|
||||
final DeleteExternalIds.Factory deleteExternalIdsFactory,
|
||||
final ExternalIdDetailFactory.Factory externalIdDetailFactory) {
|
||||
super(schema, currentUser);
|
||||
this.deleteExternalIdsFactory = deleteExternalIdsFactory;
|
||||
this.externalIdDetailFactory = externalIdDetailFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void myExternalIds(AsyncCallback<List<AccountExternalId>> callback) {
|
||||
externalIdDetailFactory.create().to(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteExternalIds(
|
||||
final Set<AccountExternalId.Key> keys,
|
||||
final AsyncCallback<Set<AccountExternalId.Key>> callback) {
|
||||
deleteExternalIdsFactory.create(keys).to(callback);
|
||||
}
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.httpd.rpc.account;
|
||||
|
||||
import com.google.gerrit.httpd.rpc.Handler;
|
||||
import com.google.gerrit.reviewdb.client.AccountExternalId;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountByEmailCache;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
class DeleteExternalIds extends Handler<Set<AccountExternalId.Key>> {
|
||||
interface Factory {
|
||||
DeleteExternalIds create(Set<AccountExternalId.Key> keys);
|
||||
}
|
||||
|
||||
private final ReviewDb db;
|
||||
private final IdentifiedUser user;
|
||||
private final ExternalIdDetailFactory detailFactory;
|
||||
private final AccountByEmailCache byEmailCache;
|
||||
private final AccountCache accountCache;
|
||||
|
||||
private final Set<AccountExternalId.Key> keys;
|
||||
|
||||
@Inject
|
||||
DeleteExternalIds(
|
||||
final ReviewDb db,
|
||||
final IdentifiedUser user,
|
||||
final ExternalIdDetailFactory detailFactory,
|
||||
final AccountByEmailCache byEmailCache,
|
||||
final AccountCache accountCache,
|
||||
@Assisted final Set<AccountExternalId.Key> keys) {
|
||||
this.db = db;
|
||||
this.user = user;
|
||||
this.detailFactory = detailFactory;
|
||||
this.byEmailCache = byEmailCache;
|
||||
this.accountCache = accountCache;
|
||||
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<AccountExternalId.Key> call() throws OrmException, IOException {
|
||||
final Map<AccountExternalId.Key, AccountExternalId> have = have();
|
||||
|
||||
List<AccountExternalId> toDelete = new ArrayList<>();
|
||||
for (AccountExternalId.Key k : keys) {
|
||||
final AccountExternalId id = have.get(k);
|
||||
if (id != null && id.canDelete()) {
|
||||
toDelete.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!toDelete.isEmpty()) {
|
||||
db.accountExternalIds().delete(toDelete);
|
||||
accountCache.evict(user.getAccountId());
|
||||
for (AccountExternalId e : toDelete) {
|
||||
byEmailCache.evict(e.getEmailAddress());
|
||||
}
|
||||
}
|
||||
|
||||
return toKeySet(toDelete);
|
||||
}
|
||||
|
||||
private Map<AccountExternalId.Key, AccountExternalId> have() throws OrmException {
|
||||
Map<AccountExternalId.Key, AccountExternalId> r;
|
||||
|
||||
r = new HashMap<>();
|
||||
for (AccountExternalId i : detailFactory.call()) {
|
||||
r.put(i.getKey(), i);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private Set<AccountExternalId.Key> toKeySet(List<AccountExternalId> toDelete) {
|
||||
Set<AccountExternalId.Key> r = new HashSet<>();
|
||||
for (AccountExternalId i : toDelete) {
|
||||
r.add(i.getKey());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.httpd.rpc.account;
|
||||
|
||||
import static com.google.gerrit.reviewdb.client.AccountExternalId.SCHEME_USERNAME;
|
||||
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.httpd.WebSession;
|
||||
import com.google.gerrit.httpd.rpc.Handler;
|
||||
import com.google.gerrit.reviewdb.client.AccountExternalId;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
class ExternalIdDetailFactory extends Handler<List<AccountExternalId>> {
|
||||
interface Factory {
|
||||
ExternalIdDetailFactory create();
|
||||
}
|
||||
|
||||
private final ReviewDb db;
|
||||
private final IdentifiedUser user;
|
||||
private final AuthConfig authConfig;
|
||||
private final DynamicItem<WebSession> session;
|
||||
|
||||
@Inject
|
||||
ExternalIdDetailFactory(
|
||||
final ReviewDb db,
|
||||
final IdentifiedUser user,
|
||||
final AuthConfig authConfig,
|
||||
final DynamicItem<WebSession> session) {
|
||||
this.db = db;
|
||||
this.user = user;
|
||||
this.authConfig = authConfig;
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountExternalId> call() throws OrmException {
|
||||
final AccountExternalId.Key last = session.get().getLastLoginExternalId();
|
||||
final List<AccountExternalId> ids =
|
||||
db.accountExternalIds().byAccount(user.getAccountId()).toList();
|
||||
|
||||
for (final AccountExternalId e : ids) {
|
||||
e.setTrusted(authConfig.isIdentityTrustable(Collections.singleton(e)));
|
||||
|
||||
// The identity can be deleted only if its not the one used to
|
||||
// establish this web session, and if only if an identity was
|
||||
// actually used to establish this web session.
|
||||
//
|
||||
if (e.isScheme(SCHEME_USERNAME)) {
|
||||
e.setCanDelete(false);
|
||||
} else {
|
||||
e.setCanDelete(last != null && !last.equals(e.getKey()));
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user