Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Commit

Permalink
Agent auth: handle the case when account does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Alena Prokharchyk authored and Craig Jellick committed Jul 2, 2018
1 parent 4c80926 commit 79e931a
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@

import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AgentInstanceAuthObjectPostProcessor implements ObjectTypeSerializerPostProcessor {

private static final Logger log = LoggerFactory.getLogger(AgentInstanceAuthObjectPostProcessor.class);

ObjectManager objectManager;

@Override
Expand Down Expand Up @@ -52,6 +57,10 @@ public void process(Object obj, String type, Map<String, Object> data) {
// Secondary authed roles
for (Long accountId : authedRoleAccountIds) {
account = objectManager.loadResource(Account.class, accountId);
if (account == null) {
log.warn("Failed to find account by id [{}]", accountId);
continue;
}
String scope = null;
if (DataAccessor.fromDataFieldOf(account).withKey(AccountConstants.DATA_ACT_AS_RESOURCE_ACCOUNT).withDefault(false).as(Boolean.class)) {
scope = "ENVIRONMENT";
Expand Down

0 comments on commit 79e931a

Please sign in to comment.