Repository: cloudstack Updated Branches: refs/heads/rbac ebfe947f4 -> 26e92af62
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/26e92af6/services/iam/plugin/src/org/apache/cloudstack/api/response/acl/AclPermissionResponse.java ---------------------------------------------------------------------- diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/response/acl/AclPermissionResponse.java b/services/iam/plugin/src/org/apache/cloudstack/api/response/acl/AclPermissionResponse.java new file mode 100644 index 0000000..f44144c --- /dev/null +++ b/services/iam/plugin/src/org/apache/cloudstack/api/response/acl/AclPermissionResponse.java @@ -0,0 +1,125 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 org.apache.cloudstack.api.response.acl; + +import com.google.gson.annotations.SerializedName; + +import org.apache.cloudstack.acl.AclEntityType; +import org.apache.cloudstack.acl.PermissionScope; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseResponse; +import org.apache.cloudstack.iam.api.AclPolicyPermission; + +import com.cloud.serializer.Param; + +public class AclPermissionResponse extends BaseResponse { + + @SerializedName(ApiConstants.ACL_ACTION) + @Param(description = "action of this permission") + private String action; + + @SerializedName(ApiConstants.ENTITY_TYPE) + @Param(description = "the entity type of this permission") + private AclEntityType entityType; + + @SerializedName(ApiConstants.ACL_SCOPE) + @Param(description = "scope of this permission") + private PermissionScope scope; + + @SerializedName(ApiConstants.ACL_SCOPE_ID) + @Param(description = "scope id of this permission") + private Long scopeId; + + @SerializedName(ApiConstants.ACL_ALLOW_DENY) + @Param(description = "allow or deny of this permission") + private AclPolicyPermission.Permission permission; + + public AclEntityType getEntityType() { + return entityType; + } + + public void setEntityType(AclEntityType entityType) { + this.entityType = entityType; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public PermissionScope getScope() { + return scope; + } + + public void setScope(PermissionScope scope) { + this.scope = scope; + } + + public Long getScopeId() { + return scopeId; + } + + public void setScopeId(Long scopeId) { + this.scopeId = scopeId; + } + + public AclPolicyPermission.Permission getPermission() { + return permission; + } + + public void setPermission(AclPolicyPermission.Permission permission) { + this.permission = permission; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((action == null) ? 0 : action.hashCode()); + result = prime * result + ((entityType == null) ? 0 : entityType.hashCode()); + result = prime * result + ((scope == null) ? 0 : scope.hashCode()); + result = prime * result + ((scopeId == null) ? 0 : scopeId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AclPermissionResponse other = (AclPermissionResponse) obj; + if ((entityType == null && other.entityType != null) || !entityType.equals(other.entityType)) { + return false; + } else if ((action == null && other.action != null) || !action.equals(other.action)) { + return false; + } else if ((scope == null && other.scope != null) || !scope.equals(other.scope)) { + return false; + } else if ((scopeId == null && other.scopeId != null) || !scopeId.equals(other.scopeId)) { + return false; + } + return true; + } + + + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/26e92af6/services/iam/plugin/src/org/apache/cloudstack/api/response/acl/AclPolicyResponse.java ---------------------------------------------------------------------- diff --git a/services/iam/plugin/src/org/apache/cloudstack/api/response/acl/AclPolicyResponse.java b/services/iam/plugin/src/org/apache/cloudstack/api/response/acl/AclPolicyResponse.java new file mode 100644 index 0000000..76651d8 --- /dev/null +++ b/services/iam/plugin/src/org/apache/cloudstack/api/response/acl/AclPolicyResponse.java @@ -0,0 +1,177 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 org.apache.cloudstack.api.response.acl; + +import java.util.LinkedHashSet; +import java.util.Set; + +import com.google.gson.annotations.SerializedName; + +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseResponse; +import org.apache.cloudstack.api.EntityReference; +import org.apache.cloudstack.api.response.ControlledViewEntityResponse; +import org.apache.cloudstack.iam.api.AclPolicy; + +import com.cloud.serializer.Param; + +@SuppressWarnings("unused") +@EntityReference(value = AclPolicy.class) +public class AclPolicyResponse extends BaseResponse implements ControlledViewEntityResponse { + + @SerializedName(ApiConstants.ID) + @Param(description = "the ID of the acl policy") + private String id; + + @SerializedName(ApiConstants.NAME) + @Param(description = "the name of the acl policy") + private String name; + + @SerializedName(ApiConstants.DESCRIPTION) + @Param(description = "the description of the acl policy") + private String description; + + @SerializedName(ApiConstants.DOMAIN_ID) + @Param(description = "the domain ID of the acl policy") + private String domainId; + + @SerializedName(ApiConstants.DOMAIN) + @Param(description = "the domain name of the acl policy") + private String domainName; + + @SerializedName(ApiConstants.ACCOUNT) + @Param(description = "the account owning the policy") + private String accountName; + + @SerializedName(ApiConstants.ACL_PERMISSIONS) + @Param(description = "set of permissions for the acl policy") + private Set<AclPermissionResponse> permissionList; + + public AclPolicyResponse() { + permissionList = new LinkedHashSet<AclPermissionResponse>(); + } + + @Override + public String getObjectId() { + return getId(); + } + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public void setName(String name) { + this.name = name; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + @Override + public void setDomainName(String domainName) { + this.domainName = domainName; + } + + public Set<AclPermissionResponse> getPermissionList() { + return permissionList; + } + + public void setPermissionList(Set<AclPermissionResponse> perms) { + permissionList = perms; + } + + public void addPermission(AclPermissionResponse perm) { + permissionList.add(perm); + } + + @Override + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + @Override + public void setProjectId(String projectId) { + // TODO Auto-generated method stub + + } + + @Override + public void setProjectName(String projectName) { + // TODO Auto-generated method stub + + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public String getDomainId() { + return domainId; + } + + public String getDomainName() { + return domainName; + } + + public String getAccountName() { + return accountName; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AclPolicyResponse other = (AclPolicyResponse) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/26e92af6/services/iam/plugin/test/org/apache/cloudstack/acl/AclApiServiceTest.java ---------------------------------------------------------------------- diff --git a/services/iam/plugin/test/org/apache/cloudstack/acl/AclApiServiceTest.java b/services/iam/plugin/test/org/apache/cloudstack/acl/AclApiServiceTest.java index 602e708..02b7331 100644 --- a/services/iam/plugin/test/org/apache/cloudstack/acl/AclApiServiceTest.java +++ b/services/iam/plugin/test/org/apache/cloudstack/acl/AclApiServiceTest.java @@ -37,11 +37,11 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.acl.api.AclApiService; import org.apache.cloudstack.acl.api.AclApiServiceImpl; -import org.apache.cloudstack.acl.api.response.AclGroupResponse; -import org.apache.cloudstack.acl.api.response.AclPermissionResponse; -import org.apache.cloudstack.acl.api.response.AclPolicyResponse; import org.apache.cloudstack.api.command.user.vm.ListVMsCmd; import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.acl.AclGroupResponse; +import org.apache.cloudstack.api.response.acl.AclPermissionResponse; +import org.apache.cloudstack.api.response.acl.AclPolicyResponse; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.iam.api.AclGroup;
