Search in sources :

Example 1 with SamlAuthorizationResponse

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);
}
Also used : Account(com.cloud.user.Account) SamlAuthorizationResponse(org.apache.cloudstack.api.response.SamlAuthorizationResponse) User(com.cloud.user.User) UserVO(com.cloud.user.UserVO) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList)

Aggregations

Account (com.cloud.user.Account)1 User (com.cloud.user.User)1 UserVO (com.cloud.user.UserVO)1 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 SamlAuthorizationResponse (org.apache.cloudstack.api.response.SamlAuthorizationResponse)1