use of org.apache.cloudstack.api.response.SamlAuthorizationResponse in project cloudstack by apache.
the class ListSamlAuthorizationCmd method execute.
@Override
public void execute() {
List<UserVO> users = new ArrayList<UserVO>();
if (getUserId() != null) {
UserVO user = _userDao.getUser(getUserId());
if (user != null) {
Account account = _accountService.getAccount(user.getAccountId());
_accountService.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.ListEntry, true, account);
users.add(user);
}
} else if (CallContext.current().getCallingAccount().getType() == Account.ACCOUNT_TYPE_ADMIN) {
users = _userDao.listAll();
}
ListResponse<SamlAuthorizationResponse> response = new ListResponse<SamlAuthorizationResponse>();
List<SamlAuthorizationResponse> authorizationResponses = new ArrayList<SamlAuthorizationResponse>();
for (User user : users) {
SamlAuthorizationResponse authorizationResponse = new SamlAuthorizationResponse(user.getUuid(), user.getSource().equals(User.Source.SAML2), user.getExternalEntity());
authorizationResponse.setObjectName("samlauthorization");
authorizationResponses.add(authorizationResponse);
}
response.setResponses(authorizationResponses);
response.setResponseName(getCommandName());
setResponseObject(response);
}
Aggregations