From 2ae13d508c26c9d3e4a49706bbd43dd8cde679d2 Mon Sep 17 00:00:00 2001 From: Stu Arnett Date: Tue, 16 Apr 2019 13:57:00 -0500 Subject: [PATCH] Feature mgmt client (#5) * Added TenantMgmtClient and SystemMgmtClient - initial methods: * listRmgs * listSubtenants * getSubtenantDetails * listRmgNodes * getTenantInfo * listPolicies * listUids * getSharedSecret --- readme.tests.txt | 19 +- .../java/com/emc/atmos/AbstractConfig.java | 31 ++- .../com/emc/atmos/AbstractJerseyClient.java | 93 +++++++ .../com/emc/atmos/api/AbstractAtmosApi.java | 11 +- src/main/java/com/emc/atmos/api/AtmosApi.java | 1 + src/main/java/com/emc/atmos/api/RestUtil.java | 18 +- .../api/bean/CreateAccessTokenResponse.java | 2 + .../atmos/api/bean/CreateObjectResponse.java | 1 + .../emc/atmos/api/bean/GenericResponse.java | 2 + .../api/bean/GetAccessTokenResponse.java | 1 + .../api/bean/ListAccessTokensResponse.java | 2 + .../atmos/api/bean/ListDirectoryResponse.java | 2 + .../atmos/api/bean/ListObjectsResponse.java | 2 + .../atmos/api/bean/ListVersionsResponse.java | 1 + .../atmos/api/bean/ReadObjectResponse.java | 1 + .../api/encryption/AtmosEncryptionClient.java | 1 + .../emc/atmos/api/jersey/AtmosApiClient.java | 78 +++--- .../emc/atmos/api/jersey/ChecksumFilter.java | 3 +- .../atmos/api/request/ReadObjectRequest.java | 4 +- .../api/request/UpdateObjectRequest.java | 3 +- ...gmtConfig.java => AbstractMgmtConfig.java} | 23 +- .../com/emc/atmos/mgmt/MgmtConstants.java | 56 +++++ .../com/emc/atmos/mgmt/SubTenantMgmtApi.java | 44 ++++ .../emc/atmos/mgmt/SubTenantMgmtConfig.java | 74 ++++++ .../com/emc/atmos/mgmt/SystemMgmtApi.java | 42 ++++ .../com/emc/atmos/mgmt/SystemMgmtConfig.java | 41 ++- .../com/emc/atmos/mgmt/TenantMgmtApi.java | 49 ++++ .../com/emc/atmos/mgmt/TenantMgmtConfig.java | 44 +++- .../com/emc/atmos/mgmt/api/TenantMgmtApi.java | 30 --- .../mgmt/api/jersey/TenantMgmtApiClient.java | 38 --- .../atmos/mgmt/bean/AbstractSubtenant.java | 81 ++++++ .../com/emc/atmos/mgmt/bean/AdminUser.java | 54 ++++ .../atmos/mgmt/bean/AuthenticationSource.java | 41 +++ .../atmos/mgmt/bean/GetSubtenantResponse.java | 47 ++++ .../mgmt/bean/GetTenantInfoResponse.java | 47 ++++ .../atmos/mgmt/bean/ListPoliciesResponse.java | 54 ++++ .../atmos/mgmt/bean/ListRmgNodesResponse.java | 54 ++++ .../emc/atmos/mgmt/bean/ListRmgsResponse.java | 54 ++++ .../mgmt/bean/ListSubtenantsResponse.java | 54 ++++ .../emc/atmos/mgmt/bean/ListUidsResponse.java | 56 +++++ .../java/com/emc/atmos/mgmt/bean/Node.java | 78 ++++++ .../com/emc/atmos/mgmt/bean/ObjectUser.java | 72 ++++++ .../emc/atmos/mgmt/bean/ObjectUserStatus.java | 37 +++ .../emc/atmos/mgmt/bean/PoxAccessNode.java | 94 +++++++ .../com/emc/atmos/mgmt/bean/PoxAdminUser.java | 47 ++++ .../com/emc/atmos/mgmt/bean/PoxExport.java | 48 ++++ .../com/emc/atmos/mgmt/bean/PoxHandler.java | 76 ++++++ .../emc/atmos/mgmt/bean/PoxNfsCifsNode.java | 88 +++++++ .../com/emc/atmos/mgmt/bean/PoxPolicy.java | 98 ++++++++ .../atmos/mgmt/bean/PoxPolicySelector.java | 75 ++++++ .../com/emc/atmos/mgmt/bean/PoxReplica.java | 75 ++++++ .../com/emc/atmos/mgmt/bean/PoxRetention.java | 54 ++++ .../com/emc/atmos/mgmt/bean/PoxSubtenant.java | 61 +++++ .../com/emc/atmos/mgmt/bean/PoxTenant.java | 187 ++++++++++++++ .../java/com/emc/atmos/mgmt/bean/Rmg.java | 108 ++++++++ .../com/emc/atmos/mgmt/bean/SharedSecret.java | 95 +++++++ .../java/com/emc/atmos/mgmt/bean/Status.java | 38 +++ .../com/emc/atmos/mgmt/bean/Subtenant.java | 52 ++++ .../emc/atmos/mgmt/bean/SubtenantDetails.java | 95 +++++++ .../com/emc/atmos/mgmt/jersey/AuthFilter.java | 152 +++++++++++ .../mgmt/{api => }/jersey/JerseyUtil.java | 8 +- .../SubTenantMgmtClient.java} | 33 ++- .../atmos/mgmt/jersey/SystemMgmtClient.java | 61 +++++ .../atmos/mgmt/jersey/TenantMgmtClient.java | 103 ++++++++ .../api/bean => util}/BasicResponse.java | 2 +- src/main/java/com/emc/util/HttpUtil.java | 8 + .../atmos/api/test/AtmosApiClientTest.java | 149 +++++++++++ .../mgmt/test/SubTenantMgmtClientTest.java | 122 +++++++++ .../atmos/mgmt/test/SystemMgmtClientTest.java | 138 ++++++++++ .../atmos/mgmt/test/TenantMgmtClientTest.java | 235 ++++++++++++++++++ .../emc/atmos/util/AtmosClientFactory.java | 17 +- src/test/java/com/emc/util/TestConstants.java | 55 ++++ src/test/resources/test.properties.template | 11 + 73 files changed, 3638 insertions(+), 193 deletions(-) create mode 100644 src/main/java/com/emc/atmos/AbstractJerseyClient.java rename src/main/java/com/emc/atmos/mgmt/{AtmosMgmtConfig.java => AbstractMgmtConfig.java} (79%) create mode 100644 src/main/java/com/emc/atmos/mgmt/MgmtConstants.java create mode 100644 src/main/java/com/emc/atmos/mgmt/SubTenantMgmtApi.java create mode 100644 src/main/java/com/emc/atmos/mgmt/SubTenantMgmtConfig.java create mode 100644 src/main/java/com/emc/atmos/mgmt/SystemMgmtApi.java create mode 100644 src/main/java/com/emc/atmos/mgmt/TenantMgmtApi.java delete mode 100644 src/main/java/com/emc/atmos/mgmt/api/TenantMgmtApi.java delete mode 100644 src/main/java/com/emc/atmos/mgmt/api/jersey/TenantMgmtApiClient.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/AbstractSubtenant.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/AdminUser.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/AuthenticationSource.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/GetSubtenantResponse.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/GetTenantInfoResponse.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/ListPoliciesResponse.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/ListRmgNodesResponse.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/ListRmgsResponse.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/ListSubtenantsResponse.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/ListUidsResponse.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/Node.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/ObjectUser.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/ObjectUserStatus.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxAccessNode.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxAdminUser.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxExport.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxHandler.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxNfsCifsNode.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxPolicy.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxPolicySelector.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxReplica.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxRetention.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxSubtenant.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/PoxTenant.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/Rmg.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/SharedSecret.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/Status.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/Subtenant.java create mode 100644 src/main/java/com/emc/atmos/mgmt/bean/SubtenantDetails.java create mode 100644 src/main/java/com/emc/atmos/mgmt/jersey/AuthFilter.java rename src/main/java/com/emc/atmos/mgmt/{api => }/jersey/JerseyUtil.java (93%) rename src/main/java/com/emc/atmos/mgmt/{api/jersey/AuthFilter.java => jersey/SubTenantMgmtClient.java} (61%) create mode 100644 src/main/java/com/emc/atmos/mgmt/jersey/SystemMgmtClient.java create mode 100644 src/main/java/com/emc/atmos/mgmt/jersey/TenantMgmtClient.java rename src/main/java/com/emc/{atmos/api/bean => util}/BasicResponse.java (99%) create mode 100644 src/test/java/com/emc/atmos/mgmt/test/SubTenantMgmtClientTest.java create mode 100644 src/test/java/com/emc/atmos/mgmt/test/SystemMgmtClientTest.java create mode 100644 src/test/java/com/emc/atmos/mgmt/test/TenantMgmtClientTest.java create mode 100644 src/test/java/com/emc/util/TestConstants.java diff --git a/readme.tests.txt b/readme.tests.txt index 4173c60..96622f8 100644 --- a/readme.tests.txt +++ b/readme.tests.txt @@ -14,20 +14,21 @@ atmos.secret - Shared secret key for the uid atmos.endpoints - Comma separated list of endpoint URIs (more than one is optional) ACDP: -acdp.admin.endpoint - ACDP admin endpoint, usually http://admin_node:8080/ +acdp.admin.endpoint - ACDP admin endpoint, usually http://admin_node:8080 acdp.admin.username - ACDP administrator username acdp.admin.password - ACDP administrator password -acdp.mgmt.endpoint - ACDP management endpoint, usually http://portal_node:8080/ +acdp.mgmt.endpoint - ACDP management endpoint, usually http://portal_node:8080 acdp.mgmt.username - ACDP management user (account user) acdp.mgmt.password - ACDP management password -Atmos System Management: -atmos.sysmgmt.proto - System management protocol (usually https) -atmos.sysmgmt.host - System management host (primary or secondary node in RMG) -atmos.sysmgmt.port - System management port (usually 443) -atmos.sysmgmt.username - System management user -atmos.sysmgmt.password - System management password - +Atmos Management API: +atmos.mgmt.endpoints - Management REST API endpoints, usually https://:443 (multiple optional) +atmos.mgmt.sysadmin.user - System admin user +atmos.mgmt.sysadmin.password - System admin password +atmos.mgmt.tenant - Existing tenant for testing +atmos.mgmt.tenantadmin.user - Tenant admin user +atmos.mgmt.tenantadmin.password - Tenant admin password + If a particular configuration key is missing, that test group will be skipped. diff --git a/src/main/java/com/emc/atmos/AbstractConfig.java b/src/main/java/com/emc/atmos/AbstractConfig.java index 378e2c1..5e606f7 100644 --- a/src/main/java/com/emc/atmos/AbstractConfig.java +++ b/src/main/java/com/emc/atmos/AbstractConfig.java @@ -50,30 +50,41 @@ public AbstractConfig( String context, URI... endpoints ) { this.endpoints = endpoints; } + /** + * @deprecated Please use {@link #resolveHostAndPath(String, String)} instead + */ + public URI resolvePath( String relativePath, String query ) { + return resolveHostAndPath(relativePath, query); + } + /** * Resolves a path relative to the API context. The returned URI will be of the format * scheme://host[:port]/context/relativePath?query. The scheme, host and port (endpoint) to use is delegated to the * configured loadBalancingAlgorithm to balance load across multiple endpoints. */ - public URI resolvePath( String relativePath, String query ) { + public URI resolveHostAndPath(String relativePath, String query) { String path = relativePath; // make sure we have a root path - if ( path.length() == 0 || path.charAt( 0 ) != '/' ) path = '/' + path; + if (path.length() == 0 || path.charAt(0) != '/') path = '/' + path; // don't add the context if it's already there - if ( !path.startsWith( context ) ) path = context + path; + if (!path.startsWith(context)) path = context + path; + + return resolveHost(path, query); + } - URI endpoint = loadBalancingAlgorithm.getNextEndpoint( endpoints ); + public URI resolveHost(String absolutePath, String query) { + URI endpoint = loadBalancingAlgorithm.getNextEndpoint(endpoints); try { - URI uri = new URI( endpoint.getScheme(), null, endpoint.getHost(), endpoint.getPort(), - path, query, null ); - l4j.debug( "raw path & query: " + path + "?" + query ); - l4j.debug( "encoded URI: " + uri ); + URI uri = new URI(endpoint.getScheme(), null, endpoint.getHost(), endpoint.getPort(), + absolutePath, query, null); + l4j.debug("raw path & query: " + absolutePath + "?" + query); + l4j.debug("encoded URI: " + uri); return uri; - } catch ( URISyntaxException e ) { - throw new RuntimeException( "Invalid URI syntax", e ); + } catch (URISyntaxException e) { + throw new RuntimeException("Invalid URI syntax", e); } } diff --git a/src/main/java/com/emc/atmos/AbstractJerseyClient.java b/src/main/java/com/emc/atmos/AbstractJerseyClient.java new file mode 100644 index 0000000..e84bf69 --- /dev/null +++ b/src/main/java/com/emc/atmos/AbstractJerseyClient.java @@ -0,0 +1,93 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos; + +import com.emc.util.BasicResponse; +import com.emc.util.HttpUtil; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.net.URI; + +public abstract class AbstractJerseyClient { + protected C config; + protected Client client; + + public AbstractJerseyClient(C config) { + this.config = config; + this.client = createClient(config); + } + + protected abstract Client createClient(C config); + + /** + * Populates a response object with data from the ClientResponse. + */ + protected T fillResponse(T response, ClientResponse clientResponse) { + Response.StatusType statusType = clientResponse.getStatusInfo(); + MediaType type = clientResponse.getType(); + URI location = clientResponse.getLocation(); + response.setHttpStatus(clientResponse.getStatus()); + response.setHttpMessage(statusType == null ? null : statusType.getReasonPhrase()); + response.setHeaders(clientResponse.getHeaders()); + response.setContentType(type == null ? null : type.toString()); + response.setContentLength(clientResponse.getLength()); + response.setLocation(location == null ? null : location.toString()); + if (clientResponse.getHeaders() != null) { + // workaround for Github Issue #3 + response.setDate(HttpUtil.safeHeaderParse(clientResponse.getHeaders().getFirst(HttpUtil.HEADER_DATE))); + response.setLastModified(HttpUtil.safeHeaderParse(clientResponse.getHeaders().getFirst(HttpUtil.HEADER_LAST_MODIFIED))); + response.setETag(clientResponse.getHeaders().getFirst(HttpUtil.HEADER_ETAG)); + } + return response; + } + + protected R executeAndClose(WebResource.Builder builder, Class responseType) { + ClientResponse response = builder.get(ClientResponse.class); + + R ret = response.getEntity(responseType); + + response.close(); + + return fillResponse(ret, response); + } + + protected WebResource.Builder buildRequest(String pathWithinContext, String query) { + URI uri = config.resolveHostAndPath(pathWithinContext, query); + + return client.resource(uri).getRequestBuilder(); + } +} diff --git a/src/main/java/com/emc/atmos/api/AbstractAtmosApi.java b/src/main/java/com/emc/atmos/api/AbstractAtmosApi.java index e910929..3c38d16 100644 --- a/src/main/java/com/emc/atmos/api/AbstractAtmosApi.java +++ b/src/main/java/com/emc/atmos/api/AbstractAtmosApi.java @@ -26,6 +26,7 @@ */ package com.emc.atmos.api; +import com.emc.atmos.AbstractJerseyClient; import com.emc.atmos.api.bean.GetAccessTokenResponse; import com.emc.atmos.api.request.*; import com.emc.util.HttpUtil; @@ -39,13 +40,11 @@ import java.util.List; import java.util.Map; -public abstract class AbstractAtmosApi implements AtmosApi { +public abstract class AbstractAtmosApi extends AbstractJerseyClient implements AtmosApi { public static final String DEFAULT_CONTENT_TYPE = "application/octet-stream"; - protected AtmosConfig config; - public AbstractAtmosApi( AtmosConfig config ) { - this.config = config; + super( config ); } @Override @@ -91,7 +90,7 @@ public URL getShareableUrl( ObjectIdentifier identifier, Date expirationDate, St if ( identifier instanceof ObjectKey ) throw new IllegalArgumentException( "You cannot create shareable URLs using a key; try using the object ID" ); - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), null ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), null ); String path = uri.getPath().toLowerCase(); long expiresTime = expirationDate.getTime() / 1000; @@ -125,7 +124,7 @@ public void deleteAccessToken( URL url ) { @Override public PreSignedRequest preSignRequest( Request request, Date expiration ) throws MalformedURLException { - URI uri = config.resolvePath( request.getServiceRelativePath(), request.getQuery() ); + URI uri = config.resolveHostAndPath( request.getServiceRelativePath(), request.getQuery() ); Map> headers = request.generateHeaders( config.isEncodeUtf8() ); String contentType = null; diff --git a/src/main/java/com/emc/atmos/api/AtmosApi.java b/src/main/java/com/emc/atmos/api/AtmosApi.java index 9925e6c..c003085 100644 --- a/src/main/java/com/emc/atmos/api/AtmosApi.java +++ b/src/main/java/com/emc/atmos/api/AtmosApi.java @@ -28,6 +28,7 @@ import com.emc.atmos.api.bean.*; import com.emc.atmos.api.request.*; +import com.emc.util.BasicResponse; import java.io.IOException; import java.io.InputStream; diff --git a/src/main/java/com/emc/atmos/api/RestUtil.java b/src/main/java/com/emc/atmos/api/RestUtil.java index 313ca04..f0a629c 100644 --- a/src/main/java/com/emc/atmos/api/RestUtil.java +++ b/src/main/java/com/emc/atmos/api/RestUtil.java @@ -45,14 +45,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * @see HttpUtil + */ public final class RestUtil { - public static final String HEADER_CONTENT_TYPE = "Content-Type"; - public static final String HEADER_DATE = "Date"; - public static final String HEADER_EXPECT = "Expect"; - public static final String HEADER_RANGE = "Range"; - public static final String HEADER_ETAG = "ETag"; - public static final String HEADER_LAST_MODIFIED = "Last-Modified"; - public static final String XHEADER_CONTENT_CHECKSUM = "x-emc-content-checksum"; public static final String XHEADER_DATE = "x-emc-date"; public static final String XHEADER_EXPIRES = "x-emc-expires"; @@ -143,7 +139,7 @@ public static void signRequest( String method, String path, String query, Map extends BasicResponse { T content; diff --git a/src/main/java/com/emc/atmos/api/bean/GetAccessTokenResponse.java b/src/main/java/com/emc/atmos/api/bean/GetAccessTokenResponse.java index a43df0f..2ea26ee 100644 --- a/src/main/java/com/emc/atmos/api/bean/GetAccessTokenResponse.java +++ b/src/main/java/com/emc/atmos/api/bean/GetAccessTokenResponse.java @@ -28,6 +28,7 @@ import com.emc.atmos.api.Acl; import com.emc.atmos.api.RestUtil; +import com.emc.util.BasicResponse; public class GetAccessTokenResponse extends BasicResponse { AccessToken token; diff --git a/src/main/java/com/emc/atmos/api/bean/ListAccessTokensResponse.java b/src/main/java/com/emc/atmos/api/bean/ListAccessTokensResponse.java index c146838..c58b5d4 100644 --- a/src/main/java/com/emc/atmos/api/bean/ListAccessTokensResponse.java +++ b/src/main/java/com/emc/atmos/api/bean/ListAccessTokensResponse.java @@ -26,6 +26,8 @@ */ package com.emc.atmos.api.bean; +import com.emc.util.BasicResponse; + import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; diff --git a/src/main/java/com/emc/atmos/api/bean/ListDirectoryResponse.java b/src/main/java/com/emc/atmos/api/bean/ListDirectoryResponse.java index dab21e1..eb24f23 100644 --- a/src/main/java/com/emc/atmos/api/bean/ListDirectoryResponse.java +++ b/src/main/java/com/emc/atmos/api/bean/ListDirectoryResponse.java @@ -26,6 +26,8 @@ */ package com.emc.atmos.api.bean; +import com.emc.util.BasicResponse; + import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; diff --git a/src/main/java/com/emc/atmos/api/bean/ListObjectsResponse.java b/src/main/java/com/emc/atmos/api/bean/ListObjectsResponse.java index ac4b857..b292e1b 100644 --- a/src/main/java/com/emc/atmos/api/bean/ListObjectsResponse.java +++ b/src/main/java/com/emc/atmos/api/bean/ListObjectsResponse.java @@ -26,6 +26,8 @@ */ package com.emc.atmos.api.bean; +import com.emc.util.BasicResponse; + import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.List; diff --git a/src/main/java/com/emc/atmos/api/bean/ListVersionsResponse.java b/src/main/java/com/emc/atmos/api/bean/ListVersionsResponse.java index c08df37..2e4f87a 100644 --- a/src/main/java/com/emc/atmos/api/bean/ListVersionsResponse.java +++ b/src/main/java/com/emc/atmos/api/bean/ListVersionsResponse.java @@ -27,6 +27,7 @@ package com.emc.atmos.api.bean; import com.emc.atmos.api.ObjectId; +import com.emc.util.BasicResponse; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/src/main/java/com/emc/atmos/api/bean/ReadObjectResponse.java b/src/main/java/com/emc/atmos/api/bean/ReadObjectResponse.java index eba25e8..d2055ec 100644 --- a/src/main/java/com/emc/atmos/api/bean/ReadObjectResponse.java +++ b/src/main/java/com/emc/atmos/api/bean/ReadObjectResponse.java @@ -36,6 +36,7 @@ import com.emc.atmos.api.ChecksumValue; import com.emc.atmos.api.ChecksumValueImpl; import com.emc.atmos.api.RestUtil; +import com.emc.util.BasicResponse; import java.util.Map; import java.util.TreeMap; diff --git a/src/main/java/com/emc/atmos/api/encryption/AtmosEncryptionClient.java b/src/main/java/com/emc/atmos/api/encryption/AtmosEncryptionClient.java index d41cee2..b115434 100644 --- a/src/main/java/com/emc/atmos/api/encryption/AtmosEncryptionClient.java +++ b/src/main/java/com/emc/atmos/api/encryption/AtmosEncryptionClient.java @@ -36,6 +36,7 @@ import com.emc.atmos.api.*; import com.emc.atmos.api.bean.*; import com.emc.atmos.api.request.*; +import com.emc.util.BasicResponse; import com.emc.vipr.transform.*; import com.emc.vipr.transform.encryption.DoesNotNeedRekeyException; import com.emc.vipr.transform.encryption.EncryptionTransformFactory; diff --git a/src/main/java/com/emc/atmos/api/jersey/AtmosApiClient.java b/src/main/java/com/emc/atmos/api/jersey/AtmosApiClient.java index b5091bd..8339c83 100644 --- a/src/main/java/com/emc/atmos/api/jersey/AtmosApiClient.java +++ b/src/main/java/com/emc/atmos/api/jersey/AtmosApiClient.java @@ -37,6 +37,7 @@ import com.emc.atmos.api.bean.*; import com.emc.atmos.api.multipart.MultipartEntity; import com.emc.atmos.api.request.*; +import com.emc.util.BasicResponse; import com.emc.util.HttpUtil; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; @@ -44,8 +45,6 @@ import com.sun.jersey.api.client.filter.ClientFilter; import org.apache.log4j.Logger; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.MessageBodyWriter; import java.io.IOException; @@ -149,6 +148,11 @@ protected AtmosApiClient( AtmosConfig config, Client client, Client client100 ) this.client100 = client100; } + @Override + protected Client createClient( AtmosConfig config ) { + return null; // we do not call any super.execute*() methods from this class or its children + } + /** * Adds a ClientFilter to the Jersey client used to make REST requests. Useful to provide your own in-line content * or header manipulation. @@ -160,7 +164,7 @@ public void addClientFilter( ClientFilter filter ) { @Override public ServiceInformation getServiceInformation() { - ClientResponse response = client.resource( config.resolvePath( "service", null ) ).get( ClientResponse.class ); + ClientResponse response = client.resource( config.resolveHostAndPath( "service", null ) ).get( ClientResponse.class ); ServiceInformation serviceInformation = response.getEntity( ServiceInformation.class ); String featureString = response.getHeaders().getFirst( RestUtil.XHEADER_FEATURES ); @@ -181,7 +185,7 @@ public ServiceInformation getServiceInformation() { @Override public long calculateServerClockSkew() { - WebResource resource = client.resource( config.resolvePath( "", null ) ); + WebResource resource = client.resource( config.resolveHostAndPath( "", null ) ); resource.setProperty( ErrorFilter.NO_EXCEPTIONS, true ); ClientResponse response = resource.get( ClientResponse.class ); @@ -237,7 +241,7 @@ public BasicResponse updateObject( UpdateObjectRequest request ) { @Override public void delete( ObjectIdentifier identifier ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), null ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), null ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -292,7 +296,7 @@ public ListDirectoryResponse listDirectory( ListDirectoryRequest request ) { @Override public void move( ObjectPath oldPath, ObjectPath newPath, boolean overwrite ) { - WebResource resource = client.resource( config.resolvePath( oldPath.getRelativeResourcePath(), "rename" ) ); + WebResource resource = client.resource( config.resolveHostAndPath( oldPath.getRelativeResourcePath(), "rename" ) ); WebResource.Builder builder = resource.getRequestBuilder(); builder.header( RestUtil.XHEADER_PATH, config.isEncodeUtf8() ? HttpUtil.encodeUtf8( newPath.getPath() ) : newPath.getPath() ); @@ -307,7 +311,7 @@ public void move( ObjectPath oldPath, ObjectPath newPath, boolean overwrite ) { @Override public Map getUserMetadataNames( ObjectIdentifier identifier ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), "metadata/tags" ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), "metadata/tags" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -338,7 +342,7 @@ public Map getUserMetadataNames( ObjectIdentifier identifier ) @Override public Map getUserMetadata( ObjectIdentifier identifier, String... metadataNames ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), "metadata/user" ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), "metadata/user" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -368,7 +372,7 @@ public Map getUserMetadata( ObjectIdentifier identifier, Strin @Override public Map getSystemMetadata( ObjectIdentifier identifier, String... metadataNames ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), "metadata/system" ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), "metadata/system" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -404,7 +408,7 @@ public boolean objectExists( ObjectIdentifier identifier ) { @Override public ObjectMetadata getObjectMetadata( ObjectIdentifier identifier ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), null ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), null ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -436,14 +440,14 @@ public ObjectMetadata getObjectMetadata( ObjectIdentifier identifier ) { ObjectMetadata metadata = new ObjectMetadata( metaMap, acl, response.getType().toString(), wsChecksum, serverChecksum ); if ( retentionPeriod != null ) metadata.setRetentionPeriod( Long.parseLong( retentionPeriod ) ); metadata.setRetentionPolicy( response.getHeaders().getFirst( RestUtil.XHEADER_RETENTION_POLICY ) ); - metadata.setETag( response.getHeaders().getFirst( RestUtil.HEADER_ETAG ) ); + metadata.setETag( response.getHeaders().getFirst( HttpUtil.HEADER_ETAG ) ); return metadata; } @Override public void setUserMetadata( ObjectIdentifier identifier, Metadata... metadata ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), "metadata/user" ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), "metadata/user" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -467,7 +471,7 @@ public void setUserMetadata( ObjectIdentifier identifier, Metadata... metadata ) @Override public void deleteUserMetadata( ObjectIdentifier identifier, String... names ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), "metadata/user" ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), "metadata/user" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -485,7 +489,7 @@ public void deleteUserMetadata( ObjectIdentifier identifier, String... names ) { @Override public Set listMetadata( String metadataName ) { - URI uri = config.resolvePath( "objects", "listabletags" ); + URI uri = config.resolveHostAndPath( "objects", "listabletags" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( metadataName != null ) @@ -536,7 +540,7 @@ public ListObjectsResponse listObjects( ListObjectsRequest request ) { @Override public Acl getAcl( ObjectIdentifier identifier ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), "acl" ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), "acl" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -555,7 +559,7 @@ public Acl getAcl( ObjectIdentifier identifier ) { @Override public void setAcl( ObjectIdentifier identifier, Acl acl ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), "acl" ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), "acl" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -573,7 +577,7 @@ public void setAcl( ObjectIdentifier identifier, Acl acl ) { @Override public ObjectInfo getObjectInfo( ObjectIdentifier identifier ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), "info" ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), "info" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -584,7 +588,7 @@ public ObjectInfo getObjectInfo( ObjectIdentifier identifier ) { @Override public ObjectId createVersion( ObjectIdentifier identifier ) { - URI uri = config.resolvePath( identifier.getRelativeResourcePath(), "versions" ); + URI uri = config.resolveHostAndPath( identifier.getRelativeResourcePath(), "versions" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); if ( identifier instanceof ObjectKey ) @@ -616,7 +620,7 @@ public ListVersionsResponse listVersions( ListVersionsRequest request ) { @Override public void restoreVersion( ObjectId objectId, ObjectId versionId ) { - URI uri = config.resolvePath( objectId.getRelativeResourcePath(), "versions" ); + URI uri = config.resolveHostAndPath( objectId.getRelativeResourcePath(), "versions" ); WebResource.Builder builder = client.resource( uri ).getRequestBuilder(); builder.header( RestUtil.XHEADER_VERSION_OID, versionId ).put(); @@ -624,14 +628,14 @@ public void restoreVersion( ObjectId objectId, ObjectId versionId ) { @Override public void deleteVersion( ObjectId versionId ) { - client.resource( config.resolvePath( versionId.getRelativeResourcePath(), "versions" ) ).delete(); + client.resource( config.resolveHostAndPath( versionId.getRelativeResourcePath(), "versions" ) ).delete(); } @Override public CreateAccessTokenResponse createAccessToken( CreateAccessTokenRequest request ) throws MalformedURLException { ClientResponse response = build( request ).post( ClientResponse.class, request.getPolicy() ); - URI tokenUri = config.resolvePath( response.getLocation().getPath(), response.getLocation().getQuery() ); + URI tokenUri = config.resolveHostAndPath( response.getLocation().getPath(), response.getLocation().getQuery() ); response.close(); @@ -640,7 +644,7 @@ public CreateAccessTokenResponse createAccessToken( CreateAccessTokenRequest req @Override public GetAccessTokenResponse getAccessToken( String accessTokenId ) { - URI uri = config.resolvePath( "accesstokens/" + accessTokenId, "info" ); + URI uri = config.resolveHostAndPath( "accesstokens/" + accessTokenId, "info" ); ClientResponse response = client.resource( uri ).get( ClientResponse.class ); GetAccessTokenResponse ret = new GetAccessTokenResponse( response.getEntity( AccessToken.class ) ); @@ -652,7 +656,7 @@ public GetAccessTokenResponse getAccessToken( String accessTokenId ) { @Override public void deleteAccessToken( String accessTokenId ) { - client.resource( config.resolvePath( "accesstokens/" + accessTokenId, null ) ).delete(); + client.resource( config.resolveHostAndPath( "accesstokens/" + accessTokenId, null ) ).delete(); } @Override @@ -694,9 +698,9 @@ protected WebResource.Builder build( Request request ) { if ( request.supports100Continue() && config.isEnableExpect100Continue() && client100 != null ) { // use client with Expect: 100-continue l4j.debug( "Expect: 100-continue is enabled for this request" ); - resource = client100.resource( config.resolvePath( request.getServiceRelativePath(), request.getQuery() ) ); + resource = client100.resource( config.resolveHostAndPath( request.getServiceRelativePath(), request.getQuery() ) ); } else { - resource = client.resource( config.resolvePath( request.getServiceRelativePath(), request.getQuery() ) ); + resource = client.resource( config.resolveHostAndPath( request.getServiceRelativePath(), request.getQuery() ) ); } WebResource.Builder builder = resource.getRequestBuilder(); @@ -722,28 +726,6 @@ protected WebResource.Builder addHeaders( WebResource.Builder builder, Map T fillResponse( T response, ClientResponse clientResponse ) { - Response.StatusType statusType = clientResponse.getStatusInfo(); - MediaType type = clientResponse.getType(); - URI location = clientResponse.getLocation(); - response.setHttpStatus( clientResponse.getStatus() ); - response.setHttpMessage( statusType == null ? null : statusType.getReasonPhrase() ); - response.setHeaders( clientResponse.getHeaders() ); - response.setContentType( type == null ? null : type.toString() ); - response.setContentLength( clientResponse.getLength() ); - response.setLocation( location == null ? null : location.toString() ); - if ( clientResponse.getHeaders() != null ) { - // workaround for Github Issue #3 - response.setDate( HttpUtil.safeHeaderParse( clientResponse.getHeaders().getFirst( RestUtil.HEADER_DATE ) ) ); - response.setLastModified( HttpUtil.safeHeaderParse( clientResponse.getHeaders().getFirst( RestUtil.HEADER_LAST_MODIFIED ) ) ); - response.setETag( clientResponse.getHeaders().getFirst( RestUtil.HEADER_ETAG ) ); - } - return response; - } - protected Object getContent( ContentRequest request ) { Object content = request.getContent(); if ( content == null ) return new byte[0]; // need this to provide Content-Length: 0 @@ -768,6 +750,6 @@ public String createSubtenant(CreateSubtenantRequest request) { @Override public void deleteSubtenant( String subtenantId ) { - client.resource( config.resolvePath( "subtenant/" + subtenantId, null ) ).delete(); + client.resource( config.resolveHostAndPath( "subtenant/" + subtenantId, null ) ).delete(); } } diff --git a/src/main/java/com/emc/atmos/api/jersey/ChecksumFilter.java b/src/main/java/com/emc/atmos/api/jersey/ChecksumFilter.java index 3d4ab1f..a3783bc 100644 --- a/src/main/java/com/emc/atmos/api/jersey/ChecksumFilter.java +++ b/src/main/java/com/emc/atmos/api/jersey/ChecksumFilter.java @@ -30,6 +30,7 @@ import com.emc.atmos.api.ChecksumValueImpl; import com.emc.atmos.api.ChecksummedInputStream; import com.emc.atmos.api.RestUtil; +import com.emc.util.HttpUtil; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; @@ -47,7 +48,7 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio ClientResponse response = getNext().handle(request); String checksumHeader = response.getHeaders().getFirst(RestUtil.XHEADER_WSCHECKSUM); - Object rangeHeader = request.getHeaders().getFirst(RestUtil.HEADER_RANGE); + Object rangeHeader = request.getHeaders().getFirst(HttpUtil.HEADER_RANGE); // only verify checksum if this is a GET complete object request and there is a ws-checksum header in the // response diff --git a/src/main/java/com/emc/atmos/api/request/ReadObjectRequest.java b/src/main/java/com/emc/atmos/api/request/ReadObjectRequest.java index 756436c..c079fcd 100644 --- a/src/main/java/com/emc/atmos/api/request/ReadObjectRequest.java +++ b/src/main/java/com/emc/atmos/api/request/ReadObjectRequest.java @@ -28,11 +28,11 @@ import com.emc.atmos.api.Range; import com.emc.atmos.api.RestUtil; +import com.emc.util.HttpUtil; import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.TreeMap; /** * Represents an Atmos read-object request. @@ -57,7 +57,7 @@ public Map> generateHeaders( boolean encodeUtf8 ) { if ( encodeUtf8 ) RestUtil.addValue( headers, RestUtil.XHEADER_UTF8, "true" ); if ( ranges != null && !ranges.isEmpty() ) - RestUtil.addValue( headers, RestUtil.HEADER_RANGE, "bytes=" + RestUtil.join( ranges, "," ) ); + RestUtil.addValue( headers, HttpUtil.HEADER_RANGE, "bytes=" + RestUtil.join( ranges, "," ) ); return headers; } diff --git a/src/main/java/com/emc/atmos/api/request/UpdateObjectRequest.java b/src/main/java/com/emc/atmos/api/request/UpdateObjectRequest.java index ba787c6..df5db18 100644 --- a/src/main/java/com/emc/atmos/api/request/UpdateObjectRequest.java +++ b/src/main/java/com/emc/atmos/api/request/UpdateObjectRequest.java @@ -28,6 +28,7 @@ import com.emc.atmos.api.Range; import com.emc.atmos.api.RestUtil; +import com.emc.util.HttpUtil; import java.util.List; import java.util.Map; @@ -53,7 +54,7 @@ public Map> generateHeaders( boolean encodeUtf8 ) { Map> headers = super.generateHeaders( encodeUtf8 ); if ( range != null ) - RestUtil.addValue( headers, RestUtil.HEADER_RANGE, "bytes=" + range ); + RestUtil.addValue( headers, HttpUtil.HEADER_RANGE, "bytes=" + range ); return headers; } diff --git a/src/main/java/com/emc/atmos/mgmt/AtmosMgmtConfig.java b/src/main/java/com/emc/atmos/mgmt/AbstractMgmtConfig.java similarity index 79% rename from src/main/java/com/emc/atmos/mgmt/AtmosMgmtConfig.java rename to src/main/java/com/emc/atmos/mgmt/AbstractMgmtConfig.java index 2652cca..2014915 100644 --- a/src/main/java/com/emc/atmos/mgmt/AtmosMgmtConfig.java +++ b/src/main/java/com/emc/atmos/mgmt/AbstractMgmtConfig.java @@ -32,23 +32,24 @@ import java.util.List; import java.util.Map; -public abstract class AtmosMgmtConfig extends AbstractConfig { +public abstract class AbstractMgmtConfig extends AbstractConfig { private static final String DEFAULT_CONTEXT = "/sysmgmt"; private String username; private String password; + private volatile String sessionCookie; - public AtmosMgmtConfig() { - super( DEFAULT_CONTEXT ); - } - - public AtmosMgmtConfig( String username, String password, URI... endpoints ) { + public AbstractMgmtConfig(String username, String password, URI... endpoints) { super( DEFAULT_CONTEXT, endpoints ); this.username = username; this.password = password; } - public abstract Map> getAuthenticationHeaders(); + public abstract Map> getRestAuthenticationHeaders(); + + public abstract String getPoxLoginPath(); + + public abstract Map getPoxLoginParams(); public String getUsername() { return username; @@ -65,4 +66,12 @@ public String getPassword() { public void setPassword( String password ) { this.password = password; } + + public String getSessionCookie() { + return sessionCookie; + } + + public void setSessionCookie(String sessionCookie) { + this.sessionCookie = sessionCookie; + } } diff --git a/src/main/java/com/emc/atmos/mgmt/MgmtConstants.java b/src/main/java/com/emc/atmos/mgmt/MgmtConstants.java new file mode 100644 index 0000000..0f4fba2 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/MgmtConstants.java @@ -0,0 +1,56 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt; + +public final class MgmtConstants { + public static final String X_PREFIX = "x-atmos-"; + + public static final String XHEADER_SYSTEM_ADMIN = X_PREFIX + "systemadmin"; + public static final String XHEADER_SYSTEM_ADMIN_PASSWORD = X_PREFIX + "systemadminpassword"; + public static final String XHEADER_AUTH_TYPE = X_PREFIX + "authType"; + + public static final String XHEADER_TENANT_ADMIN = X_PREFIX + "tenantadmin"; + public static final String XHEADER_TENANT_ADMIN_PASSWORD = X_PREFIX + "tenantadminpassword"; + public static final String XHEADER_SUB_TENANT_ADMIN = X_PREFIX + "subtenantadmin"; + public static final String XHEADER_SUB_TENANT_ADMIN_PASSWORD = X_PREFIX + "subtenantadminpassword"; + + public static final String AUTHTYPE_PASSWORD = "password"; + + public static final String PARAM_TENANT_NAME = "tenant_name"; + public static final String PARAM_SUB_TENANT_NAME = "sub_tenant_name"; + public static final String PARAM_USERNAME = "username"; + public static final String PARAM_PASSWORD = "password"; + + private MgmtConstants() { + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/SubTenantMgmtApi.java b/src/main/java/com/emc/atmos/mgmt/SubTenantMgmtApi.java new file mode 100644 index 0000000..ec7ac37 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/SubTenantMgmtApi.java @@ -0,0 +1,44 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt; + +import com.emc.atmos.mgmt.bean.SharedSecret; +import com.emc.atmos.mgmt.bean.ListUidsResponse; + +public interface SubTenantMgmtApi { + + ListUidsResponse listUids(); + + SharedSecret getSharedSecret(String uid); + +} diff --git a/src/main/java/com/emc/atmos/mgmt/SubTenantMgmtConfig.java b/src/main/java/com/emc/atmos/mgmt/SubTenantMgmtConfig.java new file mode 100644 index 0000000..a833229 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/SubTenantMgmtConfig.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018, EMC Corporation. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * + Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + The name of EMC Corporation may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.emc.atmos.mgmt; + +import com.sun.jersey.core.header.OutBoundHeaders; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.emc.atmos.mgmt.MgmtConstants.*; + +public class SubTenantMgmtConfig extends TenantMgmtConfig { + private String subTenant; + + public SubTenantMgmtConfig(String tenant, String subTenant, String username, String password, URI... endpoints) { + super(tenant, username, password, endpoints); + this.subTenant = subTenant; + } + + @Override + public Map> getRestAuthenticationHeaders() { + OutBoundHeaders authHeaders = new OutBoundHeaders(); + + authHeaders.putSingle(MgmtConstants.XHEADER_SUB_TENANT_ADMIN, getUsername()); + authHeaders.putSingle(MgmtConstants.XHEADER_SUB_TENANT_ADMIN_PASSWORD, getPassword()); + authHeaders.putSingle(MgmtConstants.XHEADER_AUTH_TYPE, MgmtConstants.AUTHTYPE_PASSWORD); + + return authHeaders; + } + + @Override + public String getPoxLoginPath() { + return "/user/verify"; + } + + @Override + public Map getPoxLoginParams() { + Map loginParams = new HashMap(); + loginParams.put(PARAM_SUB_TENANT_NAME, getSubTenant()); + loginParams.put(PARAM_USERNAME, getUsername()); + loginParams.put(PARAM_PASSWORD, getPassword()); + return loginParams; + } + + public String getSubTenant() { + return subTenant; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/SystemMgmtApi.java b/src/main/java/com/emc/atmos/mgmt/SystemMgmtApi.java new file mode 100644 index 0000000..a5c4a27 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/SystemMgmtApi.java @@ -0,0 +1,42 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt; + +import com.emc.atmos.mgmt.bean.ListRmgNodesResponse; +import com.emc.atmos.mgmt.bean.ListRmgsResponse; + +public interface SystemMgmtApi { + ListRmgsResponse listRmgs(); + + ListRmgNodesResponse listRmgNodes(String rmgName); +} diff --git a/src/main/java/com/emc/atmos/mgmt/SystemMgmtConfig.java b/src/main/java/com/emc/atmos/mgmt/SystemMgmtConfig.java index bdb00a5..ce8b494 100644 --- a/src/main/java/com/emc/atmos/mgmt/SystemMgmtConfig.java +++ b/src/main/java/com/emc/atmos/mgmt/SystemMgmtConfig.java @@ -26,5 +26,44 @@ */ package com.emc.atmos.mgmt; -public class SystemMgmtConfig { +import com.sun.jersey.core.header.OutBoundHeaders; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SystemMgmtConfig extends AbstractMgmtConfig { + private static final String PARAM_AUTH_TYPE = "auth_type"; + private static final String PARAM_USERNAME = "username"; + private static final String PARAM_PASSWORD = "password"; + + public SystemMgmtConfig(String username, String password, URI... endpoints) { + super(username, password, endpoints); + } + + @Override + public Map> getRestAuthenticationHeaders() { + OutBoundHeaders authHeaders = new OutBoundHeaders(); + + authHeaders.putSingle(MgmtConstants.XHEADER_SYSTEM_ADMIN, getUsername()); + authHeaders.putSingle(MgmtConstants.XHEADER_SYSTEM_ADMIN_PASSWORD, getPassword()); + authHeaders.putSingle(MgmtConstants.XHEADER_AUTH_TYPE, MgmtConstants.AUTHTYPE_PASSWORD); + + return authHeaders; + } + + @Override + public String getPoxLoginPath() { + return "/mgmt_login/verify"; + } + + @Override + public Map getPoxLoginParams() { + Map loginParams = new HashMap(); + loginParams.put(PARAM_AUTH_TYPE, "local"); + loginParams.put(PARAM_USERNAME, getUsername()); + loginParams.put(PARAM_PASSWORD, getPassword()); + return loginParams; + } } diff --git a/src/main/java/com/emc/atmos/mgmt/TenantMgmtApi.java b/src/main/java/com/emc/atmos/mgmt/TenantMgmtApi.java new file mode 100644 index 0000000..2be4513 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/TenantMgmtApi.java @@ -0,0 +1,49 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt; + +import com.emc.atmos.mgmt.bean.*; + +public interface TenantMgmtApi { + GetTenantInfoResponse getTenantInfo(); + + ListSubtenantsResponse listSubtenants(); + + GetSubtenantResponse getSubtenant(String subtenantName); + + ListPoliciesResponse listPolicies(); + + ListUidsResponse listUids(String subtenantName); + + SharedSecret getSharedSecret(String subtenantName, String uid); +} diff --git a/src/main/java/com/emc/atmos/mgmt/TenantMgmtConfig.java b/src/main/java/com/emc/atmos/mgmt/TenantMgmtConfig.java index ccd87bc..5e9f4d0 100644 --- a/src/main/java/com/emc/atmos/mgmt/TenantMgmtConfig.java +++ b/src/main/java/com/emc/atmos/mgmt/TenantMgmtConfig.java @@ -26,5 +26,47 @@ */ package com.emc.atmos.mgmt; -public class TenantMgmtConfig { +import com.sun.jersey.core.header.OutBoundHeaders; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class TenantMgmtConfig extends AbstractMgmtConfig { + private String tenant; + + public TenantMgmtConfig(String tenant, String username, String password, URI... endpoints) { + super(username, password, endpoints); + this.tenant = tenant; + } + + @Override + public Map> getRestAuthenticationHeaders() { + OutBoundHeaders authHeaders = new OutBoundHeaders(); + + authHeaders.putSingle(MgmtConstants.XHEADER_TENANT_ADMIN, getUsername()); + authHeaders.putSingle(MgmtConstants.XHEADER_TENANT_ADMIN_PASSWORD, getPassword()); + authHeaders.putSingle(MgmtConstants.XHEADER_AUTH_TYPE, MgmtConstants.AUTHTYPE_PASSWORD); + + return authHeaders; + } + + @Override + public String getPoxLoginPath() { + return "/user/verify"; + } + + @Override + public Map getPoxLoginParams() { + Map loginParams = new HashMap(); + loginParams.put(MgmtConstants.PARAM_TENANT_NAME, getTenant()); + loginParams.put(MgmtConstants.PARAM_USERNAME, getUsername()); + loginParams.put(MgmtConstants.PARAM_PASSWORD, getPassword()); + return loginParams; + } + + public String getTenant() { + return tenant; + } } diff --git a/src/main/java/com/emc/atmos/mgmt/api/TenantMgmtApi.java b/src/main/java/com/emc/atmos/mgmt/api/TenantMgmtApi.java deleted file mode 100644 index 95fb320..0000000 --- a/src/main/java/com/emc/atmos/mgmt/api/TenantMgmtApi.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2013-2016, EMC Corporation. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * + Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * + The name of EMC Corporation may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.emc.atmos.mgmt.api; - -public interface TenantMgmtApi { -} diff --git a/src/main/java/com/emc/atmos/mgmt/api/jersey/TenantMgmtApiClient.java b/src/main/java/com/emc/atmos/mgmt/api/jersey/TenantMgmtApiClient.java deleted file mode 100644 index ca68357..0000000 --- a/src/main/java/com/emc/atmos/mgmt/api/jersey/TenantMgmtApiClient.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013-2016, EMC Corporation. - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * + Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * + The name of EMC Corporation may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.emc.atmos.mgmt.api.jersey; - -import com.emc.atmos.mgmt.AtmosMgmtConfig; -import com.emc.atmos.mgmt.api.TenantMgmtApi; - -public class TenantMgmtApiClient implements TenantMgmtApi { - private AtmosMgmtConfig config; - - public TenantMgmtApiClient( AtmosMgmtConfig config ) { - this.config = config; - } -} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/AbstractSubtenant.java b/src/main/java/com/emc/atmos/mgmt/bean/AbstractSubtenant.java new file mode 100644 index 0000000..d6849f4 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/AbstractSubtenant.java @@ -0,0 +1,81 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import java.util.ArrayList; +import java.util.List; + +public abstract class AbstractSubtenant { + private String name; + private String id; + private AuthenticationSource authenticationSource; + private Status status; + + @XmlElement + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlElement + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @XmlElement + public AuthenticationSource getAuthenticationSource() { + return authenticationSource; + } + + public void setAuthenticationSource(AuthenticationSource authenticationSource) { + this.authenticationSource = authenticationSource; + } + + @XmlElement + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/AdminUser.java b/src/main/java/com/emc/atmos/mgmt/bean/AdminUser.java new file mode 100644 index 0000000..e778c97 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/AdminUser.java @@ -0,0 +1,54 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +public class AdminUser { + private String name; + private AuthenticationSource authenticationSource; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public AuthenticationSource getAuthenticationSource() { + return authenticationSource; + } + + public void setAuthenticationSource(AuthenticationSource authenticationSource) { + this.authenticationSource = authenticationSource; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/AuthenticationSource.java b/src/main/java/com/emc/atmos/mgmt/bean/AuthenticationSource.java new file mode 100644 index 0000000..14b6624 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/AuthenticationSource.java @@ -0,0 +1,41 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlEnum; + +@XmlEnum +public enum AuthenticationSource { + Local + // TODO: find the other possible values of this enum +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/GetSubtenantResponse.java b/src/main/java/com/emc/atmos/mgmt/bean/GetSubtenantResponse.java new file mode 100644 index 0000000..4982152 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/GetSubtenantResponse.java @@ -0,0 +1,47 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import com.emc.util.BasicResponse; + +public class GetSubtenantResponse extends BasicResponse { + private SubtenantDetails subtenant; + + public SubtenantDetails getSubtenant() { + return subtenant; + } + + public void setSubtenant(SubtenantDetails subtenant) { + this.subtenant = subtenant; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/GetTenantInfoResponse.java b/src/main/java/com/emc/atmos/mgmt/bean/GetTenantInfoResponse.java new file mode 100644 index 0000000..e644472 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/GetTenantInfoResponse.java @@ -0,0 +1,47 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import com.emc.util.BasicResponse; + +public class GetTenantInfoResponse extends BasicResponse { + private PoxTenant tenant; + + public PoxTenant getTenant() { + return tenant; + } + + public void setTenant(PoxTenant tenant) { + this.tenant = tenant; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/ListPoliciesResponse.java b/src/main/java/com/emc/atmos/mgmt/bean/ListPoliciesResponse.java new file mode 100644 index 0000000..16b5e38 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/ListPoliciesResponse.java @@ -0,0 +1,54 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import com.emc.util.BasicResponse; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "policy_list") +public class ListPoliciesResponse extends BasicResponse { + private List policies = new ArrayList(); + + @XmlElement(name = "policy") + public List getPolicies() { + return policies; + } + + public void setPolicies(List policies) { + this.policies = policies; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/ListRmgNodesResponse.java b/src/main/java/com/emc/atmos/mgmt/bean/ListRmgNodesResponse.java new file mode 100644 index 0000000..2c8a393 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/ListRmgNodesResponse.java @@ -0,0 +1,54 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import com.emc.util.BasicResponse; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "nodeList") +public class ListRmgNodesResponse extends BasicResponse { + private List nodes = new ArrayList(); + + @XmlElement(name = "node") + public List getNodes() { + return nodes; + } + + public void setNodes(List nodes) { + this.nodes = nodes; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/ListRmgsResponse.java b/src/main/java/com/emc/atmos/mgmt/bean/ListRmgsResponse.java new file mode 100644 index 0000000..e89d9e3 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/ListRmgsResponse.java @@ -0,0 +1,54 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import com.emc.util.BasicResponse; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "rmgList") +public class ListRmgsResponse extends BasicResponse { + private List rmgs = new ArrayList(); + + @XmlElement(name = "rmg") + public List getRmgs() { + return rmgs; + } + + public void setRmgs(List rmgs) { + this.rmgs = rmgs; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/ListSubtenantsResponse.java b/src/main/java/com/emc/atmos/mgmt/bean/ListSubtenantsResponse.java new file mode 100644 index 0000000..7db6cb5 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/ListSubtenantsResponse.java @@ -0,0 +1,54 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import com.emc.util.BasicResponse; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "subtenantList") +public class ListSubtenantsResponse extends BasicResponse { + private List subtenants = new ArrayList(); + + @XmlElement(name = "subtenant") + public List getSubtenants() { + return subtenants; + } + + public void setSubtenants(List subtenants) { + this.subtenants = subtenants; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/ListUidsResponse.java b/src/main/java/com/emc/atmos/mgmt/bean/ListUidsResponse.java new file mode 100644 index 0000000..5baed4d --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/ListUidsResponse.java @@ -0,0 +1,56 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import com.emc.util.BasicResponse; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "uid_list") +public class ListUidsResponse extends BasicResponse { + + private List uids = new ArrayList(); + + @XmlElement(name = "uid") + public List getUids() { + return uids; + } + + public void setUids(List uids) { + this.uids = uids; + } + +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/Node.java b/src/main/java/com/emc/atmos/mgmt/bean/Node.java new file mode 100644 index 0000000..81dfaea --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/Node.java @@ -0,0 +1,78 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlAttribute; + +public class Node { + private String name; + private String mgmtIp; + private boolean up; + private String location; + + @XmlAttribute + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlAttribute + public String getMgmtIp() { + return mgmtIp; + } + + public void setMgmtIp(String mgmtIp) { + this.mgmtIp = mgmtIp; + } + + @XmlAttribute + public boolean getUp() { + return up; + } + + public void setUp(boolean up) { + this.up = up; + } + + @XmlAttribute + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/ObjectUser.java b/src/main/java/com/emc/atmos/mgmt/bean/ObjectUser.java new file mode 100644 index 0000000..1be777d --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/ObjectUser.java @@ -0,0 +1,72 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +public class ObjectUser { + private String uid; + private String sharedSecret; + private ObjectUserStatus status; + private String email; + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getSharedSecret() { + return sharedSecret; + } + + public void setSharedSecret(String sharedSecret) { + this.sharedSecret = sharedSecret; + } + + public ObjectUserStatus getStatus() { + return status; + } + + public void setStatus(ObjectUserStatus status) { + this.status = status; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/ObjectUserStatus.java b/src/main/java/com/emc/atmos/mgmt/bean/ObjectUserStatus.java new file mode 100644 index 0000000..2240266 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/ObjectUserStatus.java @@ -0,0 +1,37 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +public enum ObjectUserStatus { + Operational, Disabled, Deleting, Deleted +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxAccessNode.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxAccessNode.java new file mode 100644 index 0000000..e55fb01 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxAccessNode.java @@ -0,0 +1,94 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; + +public class PoxAccessNode { + private String name; + private String id; + private String publicIp; + private String webservice; + private String filesystem; + private String multiSubtenantAccess; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @XmlElement(name = "public_ip") + public String getPublicIp() { + return publicIp; + } + + public void setPublicIp(String publicIp) { + this.publicIp = publicIp; + } + + public String getWebservice() { + return webservice; + } + + public void setWebservice(String webservice) { + this.webservice = webservice; + } + + public String getFilesystem() { + return filesystem; + } + + public void setFilesystem(String filesystem) { + this.filesystem = filesystem; + } + + @XmlElement(name = "multi_subtenant_access") + public String getMultiSubtenantAccess() { + return multiSubtenantAccess; + } + + public void setMultiSubtenantAccess(String multiSubtenantAccess) { + this.multiSubtenantAccess = multiSubtenantAccess; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxAdminUser.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxAdminUser.java new file mode 100644 index 0000000..8a126fb --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxAdminUser.java @@ -0,0 +1,47 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; + +public class PoxAdminUser extends AdminUser { + @XmlElement(name = "authentication_source") + public AuthenticationSource getAuthenticationSource() { + return super.getAuthenticationSource(); + } + + @Override + public void setAuthenticationSource(AuthenticationSource authenticationSource) { + super.setAuthenticationSource(authenticationSource); + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxExport.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxExport.java new file mode 100644 index 0000000..a0a6b84 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxExport.java @@ -0,0 +1,48 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; + +public class PoxExport { + private String ipAddress; + + @XmlElement(name = "ip_address") + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxHandler.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxHandler.java new file mode 100644 index 0000000..d253723 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxHandler.java @@ -0,0 +1,76 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; + +public class PoxHandler { + private String handle; + private String expression; + private String handleId; + private String onEvent; + + public String getHandle() { + return handle; + } + + public void setHandle(String handle) { + this.handle = handle; + } + + public String getExpression() { + return expression; + } + + public void setExpression(String expression) { + this.expression = expression; + } + + @XmlElement(name = "handle_id") + public String getHandleId() { + return handleId; + } + + public void setHandleId(String handleId) { + this.handleId = handleId; + } + + @XmlElement(name = "on_event") + public String getOnEvent() { + return onEvent; + } + + public void setOnEvent(String onEvent) { + this.onEvent = onEvent; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxNfsCifsNode.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxNfsCifsNode.java new file mode 100644 index 0000000..9e050ba --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxNfsCifsNode.java @@ -0,0 +1,88 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; + +public class PoxNfsCifsNode { + private String name; + private String id; + private Type type; + private String publicIp; + private String status; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Type getType() { + return type; + } + + public void setType(Type type) { + this.type = type; + } + + @XmlElement(name = "public_ip") + public String getPublicIp() { + return publicIp; + } + + public void setPublicIp(String publicIp) { + this.publicIp = publicIp; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public enum Type { + nfs, cifs + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxPolicy.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxPolicy.java new file mode 100644 index 0000000..d0b6b6d --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxPolicy.java @@ -0,0 +1,98 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import java.util.ArrayList; +import java.util.List; + +public class PoxPolicy { + private String name; + private String expression; + private String policyId; + private List replicaList = new ArrayList(); + private PoxRetention retention; + private String deletion; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getExpression() { + return expression; + } + + public void setExpression(String expression) { + this.expression = expression; + } + + @XmlElement(name = "policy_id") + public String getPolicyId() { + return policyId; + } + + public void setPolicyId(String policyId) { + this.policyId = policyId; + } + + @XmlElementWrapper(name = "replica_list") + @XmlElement(name = "replica") + public List getReplicaList() { + return replicaList; + } + + public void setReplicaList(List replicaList) { + this.replicaList = replicaList; + } + + public PoxRetention getRetention() { + return retention; + } + + public void setRetention(PoxRetention retention) { + this.retention = retention; + } + + public String getDeletion() { + return deletion; + } + + public void setDeletion(String deletion) { + this.deletion = deletion; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxPolicySelector.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxPolicySelector.java new file mode 100644 index 0000000..f1d0d54 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxPolicySelector.java @@ -0,0 +1,75 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; + +public class PoxPolicySelector { + private String name; + private String expression; + private String onEvent; + private String spec; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getExpression() { + return expression; + } + + public void setExpression(String expression) { + this.expression = expression; + } + + @XmlElement(name = "on_event") + public String getOnEvent() { + return onEvent; + } + + public void setOnEvent(String onEvent) { + this.onEvent = onEvent; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxReplica.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxReplica.java new file mode 100644 index 0000000..20e5c3e --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxReplica.java @@ -0,0 +1,75 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; + +public class PoxReplica { + private String type; + private String storageMechanism; + private String locations; + private String location; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @XmlElement(name = "storage_mechanism") + public String getStorageMechanism() { + return storageMechanism; + } + + public void setStorageMechanism(String storageMechanism) { + this.storageMechanism = storageMechanism; + } + + public String getLocations() { + return locations; + } + + public void setLocations(String locations) { + this.locations = locations; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxRetention.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxRetention.java new file mode 100644 index 0000000..40f99db --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxRetention.java @@ -0,0 +1,54 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +public class PoxRetention { + private String delay; + private String period; + + public String getDelay() { + return delay; + } + + public void setDelay(String delay) { + this.delay = delay; + } + + public String getPeriod() { + return period; + } + + public void setPeriod(String period) { + this.period = period; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxSubtenant.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxSubtenant.java new file mode 100644 index 0000000..35d3ba7 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxSubtenant.java @@ -0,0 +1,61 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import java.util.ArrayList; +import java.util.List; + +public class PoxSubtenant extends Subtenant { + private List subtenantAdminNames = new ArrayList(); + + @XmlElement(name = "authentication_source") + public AuthenticationSource getAuthenticationSource() { + return super.getAuthenticationSource(); + } + + public void setAuthenticationSource(AuthenticationSource authenticationSource) { + super.setAuthenticationSource(authenticationSource); + } + + @XmlElementWrapper(name = "sub_tenant_admin_list") + @XmlElement(name = "sub_tenant_admin") + public List getSubtenantAdminNames() { + return subtenantAdminNames; + } + + public void setSubtenantAdminNames(List subtenantAdminNames) { + this.subtenantAdminNames = subtenantAdminNames; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/PoxTenant.java b/src/main/java/com/emc/atmos/mgmt/bean/PoxTenant.java new file mode 100644 index 0000000..4778b7f --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/PoxTenant.java @@ -0,0 +1,187 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "tenant") +public class PoxTenant { + private String id; + private String name; + private Status status; + private AuthenticationSource authenticationSource; + private List tenantAdminList = new ArrayList(); + private String policyDistributionStatus; + private List accessNodeList = new ArrayList(); + private List nfsCifsNodeList = new ArrayList(); + private long capacity; + private List subtenantList = new ArrayList(); + private List policyList = new ArrayList(); + private List policySelectorList = new ArrayList(); + private List handlerList = new ArrayList(); + private List exportList = new ArrayList(); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + @XmlElement(name = "authentication_source") + public AuthenticationSource getAuthenticationSource() { + return authenticationSource; + } + + public void setAuthenticationSource(AuthenticationSource authenticationSource) { + this.authenticationSource = authenticationSource; + } + + @XmlElementWrapper(name = "tenant_admin_list") + @XmlElement(name = "tenant_admin") + public List getTenantAdminList() { + return tenantAdminList; + } + + public void setTenantAdminList(List tenantAdminList) { + this.tenantAdminList = tenantAdminList; + } + + @XmlElement(name = "policy_distribution_status") + public String getPolicyDistributionStatus() { + return policyDistributionStatus; + } + + public void setPolicyDistributionStatus(String policyDistributionStatus) { + this.policyDistributionStatus = policyDistributionStatus; + } + + @XmlElementWrapper(name = "access_node_list") + @XmlElement(name = "access_node") + public List getAccessNodeList() { + return accessNodeList; + } + + public void setAccessNodeList(List accessNodeList) { + this.accessNodeList = accessNodeList; + } + + @XmlElementWrapper(name = "nfs_cifs_node_list") + @XmlElement(name = "nfs_cifs_node") + public List getNfsCifsNodeList() { + return nfsCifsNodeList; + } + + public void setNfsCifsNodeList(List nfsCifsNodeList) { + this.nfsCifsNodeList = nfsCifsNodeList; + } + + public long getCapacity() { + return capacity; + } + + public void setCapacity(long capacity) { + this.capacity = capacity; + } + + @XmlElementWrapper(name = "sub_tenant_list") + @XmlElement(name = "sub_tenant") + public List getSubtenantList() { + return subtenantList; + } + + public void setSubtenantList(List subtenantList) { + this.subtenantList = subtenantList; + } + + @XmlElementWrapper(name = "policy_list") + @XmlElement(name = "policy") + public List getPolicyList() { + return policyList; + } + + public void setPolicyList(List policyList) { + this.policyList = policyList; + } + + @XmlElementWrapper(name = "policy_selector_list") + @XmlElement(name = "policy_selector") + public List getPolicySelectorList() { + return policySelectorList; + } + + public void setPolicySelectorList(List policySelectorList) { + this.policySelectorList = policySelectorList; + } + + @XmlElementWrapper(name = "handler_list") + @XmlElement(name = "handler") + public List getHandlerList() { + return handlerList; + } + + public void setHandlerList(List handlerList) { + this.handlerList = handlerList; + } + + @XmlElementWrapper(name = "export_list") + @XmlElement(name = "export") + public List getExportList() { + return exportList; + } + + public void setExportList(List exportList) { + this.exportList = exportList; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/Rmg.java b/src/main/java/com/emc/atmos/mgmt/bean/Rmg.java new file mode 100644 index 0000000..731372b --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/Rmg.java @@ -0,0 +1,108 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; + +public class Rmg { + private String name; + private String localTime; + private int nodesUp; + private int nodesDown; + private float avgLoad15; + private float avgLoad5; + private float avgLoad1; + + @XmlElement + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlElement + public String getLocalTime() { + return localTime; + } + + public void setLocalTime(String localTime) { + this.localTime = localTime; + } + + @XmlElement + public int getNodesUp() { + return nodesUp; + } + + public void setNodesUp(int nodesUp) { + this.nodesUp = nodesUp; + } + + @XmlElement + public int getNodesDown() { + return nodesDown; + } + + public void setNodesDown(int nodesDown) { + this.nodesDown = nodesDown; + } + + @XmlElement + public float getAvgLoad15() { + return avgLoad15; + } + + public void setAvgLoad15(float avgLoad15) { + this.avgLoad15 = avgLoad15; + } + + @XmlElement + public float getAvgLoad5() { + return avgLoad5; + } + + public void setAvgLoad5(float avgLoad5) { + this.avgLoad5 = avgLoad5; + } + + @XmlElement + public float getAvgLoad1() { + return avgLoad1; + } + + public void setAvgLoad1(float avgLoad1) { + this.avgLoad1 = avgLoad1; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/SharedSecret.java b/src/main/java/com/emc/atmos/mgmt/bean/SharedSecret.java new file mode 100644 index 0000000..27bc11d --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/SharedSecret.java @@ -0,0 +1,95 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; + +import com.emc.util.BasicResponse; + +@XmlRootElement(name="sharedSecret") +public class SharedSecret extends BasicResponse { + + @XmlAttribute + private String keyCreateTime; + + @XmlAttribute + private String keyExpireTime; + + @XmlValue + private String sharedSecret; + + /** + * @return the keyCreateTime + */ + public String getKeyCreateTime() { + return keyCreateTime; + } + + /** + * @param keyCreateTime the keyCreateTime to set + */ + public void setKeyCreateTime(String keyCreateTime) { + this.keyCreateTime = keyCreateTime; + } + + /** + * @return the keyExpireTime + */ + public String getKeyExpireTime() { + return keyExpireTime; + } + + /** + * @param keyExpireTime the keyExpireTime to set + */ + public void setKeyExpireTime(String keyExpireTime) { + this.keyExpireTime = keyExpireTime; + } + + /** + * @return the sharedSecret + */ + public String getSharedSecret() { + return sharedSecret; + } + + /** + * @param sharedSecret the sharedSecret to set + */ + public void setSharedSecret(String sharedSecret) { + this.sharedSecret = sharedSecret; + } + +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/Status.java b/src/main/java/com/emc/atmos/mgmt/bean/Status.java new file mode 100644 index 0000000..f0ddf51 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/Status.java @@ -0,0 +1,38 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +public enum Status { + Initialized + // TODO: find the other possible values of this enum +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/Subtenant.java b/src/main/java/com/emc/atmos/mgmt/bean/Subtenant.java new file mode 100644 index 0000000..8f02755 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/Subtenant.java @@ -0,0 +1,52 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import java.util.ArrayList; +import java.util.List; + +public class Subtenant extends AbstractSubtenant { + private List subtenantAdminNames = new ArrayList(); + + @XmlElementWrapper(name = "subtenantAdminList") + @XmlElement(name = "subtenantAdmin") + public List getSubtenantAdminNames() { + return subtenantAdminNames; + } + + public void setSubtenantAdminNames(List subtenantAdminNames) { + this.subtenantAdminNames = subtenantAdminNames; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/bean/SubtenantDetails.java b/src/main/java/com/emc/atmos/mgmt/bean/SubtenantDetails.java new file mode 100644 index 0000000..3b0775b --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/bean/SubtenantDetails.java @@ -0,0 +1,95 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.bean; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name = "subtenant") +public class SubtenantDetails extends AbstractSubtenant { + private int capacity; + private String defaultPolicySpec; + private List objectUsers; + private boolean secCompliant; + private List subtenantAdminList = new ArrayList(); + + @XmlElement + public int getCapacity() { + return capacity; + } + + public void setCapacity(int capacity) { + this.capacity = capacity; + } + + @XmlElement + public String getDefaultPolicySpec() { + return defaultPolicySpec; + } + + public void setDefaultPolicySpec(String defaultPolicySpec) { + this.defaultPolicySpec = defaultPolicySpec; + } + + @XmlElementWrapper(name = "uidSecretList") + @XmlElement(name = "uidSecret") + public List getObjectUsers() { + return objectUsers; + } + + public void setObjectUsers(List objectUsers) { + this.objectUsers = objectUsers; + } + + @XmlElement + public boolean isSecCompliant() { + return secCompliant; + } + + public void setSecCompliant(boolean secCompliant) { + this.secCompliant = secCompliant; + } + + @XmlElementWrapper + @XmlElement(name = "subtenantAdmin") + public List getSubtenantAdminList() { + return subtenantAdminList; + } + + public void setSubtenantAdminList(List subtenantAdminList) { + this.subtenantAdminList = subtenantAdminList; + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/jersey/AuthFilter.java b/src/main/java/com/emc/atmos/mgmt/jersey/AuthFilter.java new file mode 100644 index 0000000..df3b009 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/jersey/AuthFilter.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2013-2016, EMC Corporation. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * + Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + The name of EMC Corporation may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.emc.atmos.mgmt.jersey; + +import com.emc.atmos.AtmosException; +import com.emc.atmos.mgmt.AbstractMgmtConfig; +import com.emc.util.HttpUtil; +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.ClientRequest; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.filter.ClientFilter; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.*; +import java.net.URI; +import java.util.Map; + +public class AuthFilter extends ClientFilter { + public static final String PROP_POX_REQUEST = AuthFilter.class.getName() + ".poxRequest"; + public static final String SESSION_COOKIE = "_gui_session_id"; + + private AbstractMgmtConfig config; + + public AuthFilter(AbstractMgmtConfig config) { + this.config = config; + } + + @Override + public ClientResponse handle(ClientRequest request) throws ClientHandlerException { + if (request.getPropertyAsFeature(PROP_POX_REQUEST, false)) return handlePox(request); + else return handleRest(request); + } + + private ClientResponse handleRest(ClientRequest request) { + request.getHeaders().putAll(config.getRestAuthenticationHeaders()); + return getNext().handle(request); + } + + private ClientResponse handlePox(ClientRequest request) throws ClientHandlerException { + if (config.getSessionCookie() == null) { + + // first login + poxLogin(request); + } + + attachSessionCookie(request); + + ClientResponse response; + try { + response = getNext().handle(request); + + // if unauthorized, try one more time after logging in + } catch (AtmosException e) { + // apparently Atmos returns a 302 redirect to the login page instead of a 401 when the cookie is expired + if (e.getHttpCode() == 302) { + invalidateCookie(); + poxLogin(request); + + attachSessionCookie(request); + + response = getNext().handle((request)); + } else { + throw e; + } + } + + return response; + } + + private void attachSessionCookie(ClientRequest request) { + request.getHeaders().putSingle(HttpUtil.HEADER_COOKIE, new Cookie(SESSION_COOKIE, config.getSessionCookie())); + } + + private synchronized void invalidateCookie() { + config.setSessionCookie(null); + } + + private synchronized void poxLogin(ClientRequest request) { + if (config.getSessionCookie() != null) return; + + // hold existing request configuration (we can't create a new request here) + String holdMethod = request.getMethod(); + URI holdUri = request.getURI(); + Object holdEntity = request.getEntity(); + Object holdType = request.getHeaders().getFirst(HttpHeaders.CONTENT_TYPE); + Object holdAccept = request.getHeaders().getFirst(HttpHeaders.ACCEPT); + + // login + + // get login POST params + MultivaluedMap params = new MultivaluedMapImpl(); + for (Map.Entry entry : config.getPoxLoginParams().entrySet()) { + params.putSingle(entry.getKey(), entry.getValue()); + } + + // build login request + request.setMethod(HttpMethod.POST); + request.setURI(request.getURI().resolve(config.getPoxLoginPath())); + request.setEntity(params); + request.getHeaders().putSingle(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_TYPE); + request.getHeaders().putSingle(HttpHeaders.ACCEPT, "application/xml"); + + // make login call + ClientResponse response = getNext().handle(request); + + // get cookie from response + String sessionCookie = null; + for (NewCookie cookie : response.getCookies()) { + if (SESSION_COOKIE.equals(cookie.getName())) { + sessionCookie = cookie.getValue(); + break; + } + } + + if (sessionCookie == null) // there was a problem + throw new RuntimeException("Auth failure"); + else // save session cookie + config.setSessionCookie(sessionCookie); + + // reset initial request configuration + request.setMethod(holdMethod); + request.setURI(holdUri); + request.setEntity(holdEntity); + request.getHeaders().putSingle(HttpHeaders.CONTENT_TYPE, holdType); + request.getHeaders().putSingle(HttpHeaders.ACCEPT, holdAccept); + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/api/jersey/JerseyUtil.java b/src/main/java/com/emc/atmos/mgmt/jersey/JerseyUtil.java similarity index 93% rename from src/main/java/com/emc/atmos/mgmt/api/jersey/JerseyUtil.java rename to src/main/java/com/emc/atmos/mgmt/jersey/JerseyUtil.java index 48eeb18..fed1481 100644 --- a/src/main/java/com/emc/atmos/mgmt/api/jersey/JerseyUtil.java +++ b/src/main/java/com/emc/atmos/mgmt/jersey/JerseyUtil.java @@ -24,11 +24,11 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package com.emc.atmos.mgmt.api.jersey; +package com.emc.atmos.mgmt.jersey; import com.emc.acdp.AcdpException; import com.emc.atmos.api.jersey.ErrorFilter; -import com.emc.atmos.mgmt.AtmosMgmtConfig; +import com.emc.atmos.mgmt.AbstractMgmtConfig; import com.emc.util.SslUtil; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.config.ClientConfig; @@ -36,7 +36,7 @@ import com.sun.jersey.client.urlconnection.HTTPSProperties; public class JerseyUtil { - public static Client createClient( AtmosMgmtConfig config ) { + public static Client createClient(AbstractMgmtConfig config) { try { ClientConfig clientConfig = new DefaultClientConfig(); @@ -60,7 +60,7 @@ public static Client createClient( AtmosMgmtConfig config ) { * Note that this method cannot disable SSL validation, so that configuration option is ignored here. You are * responsible for configuring the client with any proxy, ssl or other options prior to calling this constructor. */ - public static void configureClient( Client client, AtmosMgmtConfig config ) { + public static void configureClient(Client client, AbstractMgmtConfig config) { client.addFilter( new ErrorFilter() ); client.addFilter( new AuthFilter( config ) ); } diff --git a/src/main/java/com/emc/atmos/mgmt/api/jersey/AuthFilter.java b/src/main/java/com/emc/atmos/mgmt/jersey/SubTenantMgmtClient.java similarity index 61% rename from src/main/java/com/emc/atmos/mgmt/api/jersey/AuthFilter.java rename to src/main/java/com/emc/atmos/mgmt/jersey/SubTenantMgmtClient.java index b7a5f77..2e09e7c 100644 --- a/src/main/java/com/emc/atmos/mgmt/api/jersey/AuthFilter.java +++ b/src/main/java/com/emc/atmos/mgmt/jersey/SubTenantMgmtClient.java @@ -24,25 +24,34 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package com.emc.atmos.mgmt.api.jersey; +package com.emc.atmos.mgmt.jersey; -import com.emc.atmos.mgmt.AtmosMgmtConfig; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.ClientRequest; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.filter.ClientFilter; +import com.emc.atmos.mgmt.SubTenantMgmtApi; +import com.emc.atmos.mgmt.SubTenantMgmtConfig; +import com.emc.atmos.mgmt.TenantMgmtApi; +import com.emc.atmos.mgmt.bean.ListUidsResponse; +import com.emc.atmos.mgmt.bean.SharedSecret; -public class AuthFilter extends ClientFilter { - private AtmosMgmtConfig config; +/** + * This class is basically a delegator to a {@link TenantMgmtClient} instance, exposing only the subtenant operations + * and always using the subtenant specified by the {@link SubTenantMgmtConfig} + */ +public class SubTenantMgmtClient implements SubTenantMgmtApi { + private SubTenantMgmtConfig config; + private TenantMgmtApi tenantClient; - public AuthFilter( AtmosMgmtConfig config ) { + public SubTenantMgmtClient(SubTenantMgmtConfig config) { this.config = config; + tenantClient = new TenantMgmtClient(config); } @Override - public ClientResponse handle( ClientRequest request ) throws ClientHandlerException { - request.getHeaders().putAll( config.getAuthenticationHeaders() ); + public ListUidsResponse listUids() { + return tenantClient.listUids(config.getSubTenant()); + } - return getNext().handle( request ); + @Override + public SharedSecret getSharedSecret(String uid) { + return tenantClient.getSharedSecret(config.getSubTenant(), uid); } } diff --git a/src/main/java/com/emc/atmos/mgmt/jersey/SystemMgmtClient.java b/src/main/java/com/emc/atmos/mgmt/jersey/SystemMgmtClient.java new file mode 100644 index 0000000..d44ed87 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/jersey/SystemMgmtClient.java @@ -0,0 +1,61 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.jersey; + +import com.emc.atmos.AbstractJerseyClient; +import com.emc.atmos.mgmt.SystemMgmtApi; +import com.emc.atmos.mgmt.SystemMgmtConfig; +import com.emc.atmos.mgmt.bean.ListRmgNodesResponse; +import com.emc.atmos.mgmt.bean.ListRmgsResponse; +import com.sun.jersey.api.client.Client; + +public class SystemMgmtClient extends AbstractJerseyClient implements SystemMgmtApi { + public SystemMgmtClient(SystemMgmtConfig config) { + super(config); + } + + @Override + protected Client createClient(SystemMgmtConfig config) { + return JerseyUtil.createClient(config); + } + + @Override + public ListRmgsResponse listRmgs() { + return executeAndClose(buildRequest("/rmgs", null), ListRmgsResponse.class); + } + + @Override + public ListRmgNodesResponse listRmgNodes(String rmgName) { + return executeAndClose(buildRequest("/rmgs/" + rmgName + "/nodes", null), ListRmgNodesResponse.class); + } +} diff --git a/src/main/java/com/emc/atmos/mgmt/jersey/TenantMgmtClient.java b/src/main/java/com/emc/atmos/mgmt/jersey/TenantMgmtClient.java new file mode 100644 index 0000000..effd130 --- /dev/null +++ b/src/main/java/com/emc/atmos/mgmt/jersey/TenantMgmtClient.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2013-2016, EMC Corporation. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * + Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + The name of EMC Corporation may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.emc.atmos.mgmt.jersey; + +import com.emc.atmos.AbstractJerseyClient; +import com.emc.atmos.mgmt.TenantMgmtApi; +import com.emc.atmos.mgmt.TenantMgmtConfig; +import com.emc.atmos.mgmt.bean.*; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; + +import java.net.URI; + +public class TenantMgmtClient extends AbstractJerseyClient implements TenantMgmtApi { + public TenantMgmtClient(TenantMgmtConfig config) { + super(config); + } + + @Override + protected Client createClient(TenantMgmtConfig config) { + return JerseyUtil.createClient(config); + } + + @Override + public GetTenantInfoResponse getTenantInfo() { + URI uri = config.resolveHost("/tenant_admin/get_tenant_info", null); + + WebResource resource = client.resource(uri); + resource.setProperty(AuthFilter.PROP_POX_REQUEST, Boolean.TRUE); + + ClientResponse response = resource.get(ClientResponse.class); + + GetTenantInfoResponse tenantResponse = new GetTenantInfoResponse(); + tenantResponse.setTenant(response.getEntity(PoxTenant.class)); + response.close(); + + fillResponse(tenantResponse, response); + + return tenantResponse; + } + + @Override + public ListSubtenantsResponse listSubtenants() { + return executeAndClose(buildRequest(tenantPrefix() + "/subtenants", null), ListSubtenantsResponse.class); + } + + @Override + public GetSubtenantResponse getSubtenant(String subtenantName) { + ClientResponse response = buildRequest(tenantPrefix() + "/subtenants/" + subtenantName, null).get(ClientResponse.class); + + GetSubtenantResponse subtenantResponse = new GetSubtenantResponse(); + subtenantResponse.setSubtenant(response.getEntity(SubtenantDetails.class)); + response.close(); + + fillResponse(subtenantResponse, response); + + return subtenantResponse; + } + + @Override + public ListPoliciesResponse listPolicies() { + return executeAndClose(buildRequest("/" + config.getTenant() + "/policies", null), ListPoliciesResponse.class); + } + + @Override + public ListUidsResponse listUids(String subtenantName) { + return executeAndClose(buildRequest(tenantPrefix() + "/subtenants/" + subtenantName + "/uids", null), ListUidsResponse.class); + } + + @Override + public SharedSecret getSharedSecret(String subtenantName, String uid) { + return executeAndClose(buildRequest(tenantPrefix() + "/subtenants/" + subtenantName + "/uids/" + uid, null), SharedSecret.class); + } + + protected String tenantPrefix() { + return "/tenants/" + config.getTenant(); + } +} diff --git a/src/main/java/com/emc/atmos/api/bean/BasicResponse.java b/src/main/java/com/emc/util/BasicResponse.java similarity index 99% rename from src/main/java/com/emc/atmos/api/bean/BasicResponse.java rename to src/main/java/com/emc/util/BasicResponse.java index 9c12b40..0681857 100644 --- a/src/main/java/com/emc/atmos/api/bean/BasicResponse.java +++ b/src/main/java/com/emc/util/BasicResponse.java @@ -30,7 +30,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -package com.emc.atmos.api.bean; +package com.emc.util; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/emc/util/HttpUtil.java b/src/main/java/com/emc/util/HttpUtil.java index d116a4f..314d831 100644 --- a/src/main/java/com/emc/util/HttpUtil.java +++ b/src/main/java/com/emc/util/HttpUtil.java @@ -48,6 +48,14 @@ public final class HttpUtil { private static final Logger log = Logger.getLogger( HttpUtil.class ); + public static final String HEADER_CONTENT_TYPE = "Content-Type"; + public static final String HEADER_DATE = "Date"; + public static final String HEADER_EXPECT = "Expect"; + public static final String HEADER_RANGE = "Range"; + public static final String HEADER_ETAG = "ETag"; + public static final String HEADER_LAST_MODIFIED = "Last-Modified"; + public static final String HEADER_COOKIE = "Cookie"; + private static final String HEADER_FORMAT = "EEE, d MMM yyyy HH:mm:ss z"; private static final ThreadLocal headerFormat = new ThreadLocal(); diff --git a/src/test/java/com/emc/atmos/api/test/AtmosApiClientTest.java b/src/test/java/com/emc/atmos/api/test/AtmosApiClientTest.java index 88169b9..6418218 100644 --- a/src/test/java/com/emc/atmos/api/test/AtmosApiClientTest.java +++ b/src/test/java/com/emc/atmos/api/test/AtmosApiClientTest.java @@ -30,6 +30,7 @@ import com.emc.atmos.StickyThreadAlgorithm; import com.emc.atmos.api.*; import com.emc.atmos.api.bean.*; +import com.emc.atmos.api.bean.adapter.Iso8601Adapter; import com.emc.atmos.api.jersey.AtmosApiBasicClient; import com.emc.atmos.api.jersey.AtmosApiClient; import com.emc.atmos.api.multipart.MultipartEntity; @@ -1684,6 +1685,154 @@ public void testCreateRetentionPolicy() throws Exception { } } + @Test + public void testCreateExpiration() throws Exception { + Assume.assumeTrue(isEcs); + byte[] data = "hello create-expiration".getBytes("UTF-8"); + + Calendar exp = Calendar.getInstance(); + exp.add(Calendar.SECOND, 5); + + CreateObjectRequest request = new CreateObjectRequest().content(data).contentType("text/plain"); + request.userMetadata(new Metadata(RestUtil.METADATA_KEY_EXPIRATION_ENABLE, "true", false), + new Metadata(RestUtil.METADATA_KEY_EXPIRATION_END, Iso8601Adapter.getFormat().format(exp.getTime()), false)); + + CreateObjectResponse response = this.api.createObject(request); + cleanup.add(response.getObjectId()); + + ReadObjectResponse response1 = this.api.readObject(new ReadObjectRequest().identifier(response.getObjectId()), + byte[].class); + Assert.assertNotNull("Null object returned", response1.getObject()); + Map metadata = response1.getMetadata().getMetadata(); + Assert.assertEquals("Expiration not enabled", "true", + metadata.get(RestUtil.METADATA_KEY_EXPIRATION_ENABLE).getValue()); + Assert.assertNotNull("Expiration not set", metadata.get(RestUtil.METADATA_KEY_EXPIRATION_END)); + Date expEnd = Iso8601Adapter.getFormat().parse(metadata.get(RestUtil.METADATA_KEY_EXPIRATION_END).getValue()); + + // wait for object to expire + Thread.sleep(expEnd.getTime() - System.currentTimeMillis() + 1000); // add a second in case of skew + Assert.assertFalse(this.api.objectExists(response.getObjectId())); + } + + @Test + public void testSetExpiration() throws Exception { + Assume.assumeTrue(isEcs); + byte[] data = "hello expiration".getBytes("UTF-8"); + + ObjectId objectId = this.api.createObject(data, "text/plain"); + cleanup.add(objectId); + Map metadata = this.api.getUserMetadata(objectId); + Assert.assertNull("Expiration already enabled", metadata.get(RestUtil.METADATA_KEY_EXPIRATION_ENABLE)); + Assert.assertNull("Expiration already enabled", metadata.get(RestUtil.METADATA_KEY_EXPIRATION_END)); + + Calendar exp = Calendar.getInstance(); + exp.add(Calendar.SECOND, 5); + + this.api.setUserMetadata(objectId, new Metadata(RestUtil.METADATA_KEY_EXPIRATION_ENABLE, "true", false), + new Metadata(RestUtil.METADATA_KEY_EXPIRATION_END, Iso8601Adapter.getFormat().format(exp.getTime()), false)); + + ReadObjectResponse response = this.api.readObject(new ReadObjectRequest().identifier(objectId), + byte[].class); + Assert.assertNotNull("Null object returned", response.getObject()); + metadata = response.getMetadata().getMetadata(); + Assert.assertEquals("Expiration not enabled", "true", + metadata.get(RestUtil.METADATA_KEY_EXPIRATION_ENABLE).getValue()); + Assert.assertNotNull("Expiration not set", metadata.get(RestUtil.METADATA_KEY_EXPIRATION_END)); + Date expEnd = Iso8601Adapter.getFormat().parse(metadata.get(RestUtil.METADATA_KEY_EXPIRATION_END).getValue()); + + // wait for object to expire + Thread.sleep(expEnd.getTime() - System.currentTimeMillis() + 1000); // add a second in case of skew + Assert.assertFalse(this.api.objectExists(objectId)); + } + + @Test + public void testCreateRetentionExpiration() throws Exception { + Assume.assumeTrue(isEcs); + + byte[] data = "hello retention expiration".getBytes("UTF-8"); + Long retentionPeriod = 4L; + Calendar exp = Calendar.getInstance(); + exp.add(Calendar.SECOND, 5); + boolean waited = false; + + try { + CreateObjectRequest request = new CreateObjectRequest().content(data).contentType("text/plain"); + request.retentionPeriod(retentionPeriod); + request.userMetadata(new Metadata(RestUtil.METADATA_KEY_EXPIRATION_ENABLE, "true", false), + new Metadata(RestUtil.METADATA_KEY_EXPIRATION_END, Iso8601Adapter.getFormat().format(exp.getTime()), false)); + + ObjectId objectId = this.api.createObject(request).getObjectId(); + cleanup.add(objectId); + + ReadObjectResponse response = this.api.readObject(new ReadObjectRequest().identifier(objectId), + byte[].class); + Assert.assertNotNull("Null object returned", response.getObject()); + Map metadata = response.getMetadata().getMetadata(); + Assert.assertEquals("Retention period doesn't match", retentionPeriod, response.getMetadata().getRetentionPeriod()); + Assert.assertEquals("Expiration not enabled", "true", + metadata.get(RestUtil.METADATA_KEY_EXPIRATION_ENABLE).getValue()); + Assert.assertNotNull("Expiration not set", metadata.get(RestUtil.METADATA_KEY_EXPIRATION_END)); + Date expEnd = Iso8601Adapter.getFormat().parse(metadata.get(RestUtil.METADATA_KEY_EXPIRATION_END).getValue()); + + // wait for object to expire + Thread.sleep(expEnd.getTime() - System.currentTimeMillis() + 1000); // add a second in case of skew + waited = true; + Assert.assertFalse(this.api.objectExists(objectId)); + } finally { + if (!waited) Thread.sleep(retentionPeriod * 1000); // let retention expire + } + } + + @Test + public void testRetentionExpirationUMD() throws Exception { + Assume.assumeTrue(isEcs); + + byte[] data = "hello retention expiration umd".getBytes("UTF-8"); + Calendar ret = Calendar.getInstance(); + ret.add(Calendar.SECOND, 4); + Calendar exp = Calendar.getInstance(); + exp.add(Calendar.SECOND, 5); + boolean waited = false; + + try { + CreateObjectRequest request = new CreateObjectRequest().content(data).contentType("text/plain"); + request.userMetadata(new Metadata(RestUtil.METADATA_KEY_RETENTION_ENABLE, "true", false), + new Metadata(RestUtil.METADATA_KEY_RETENTION_END, Iso8601Adapter.getFormat().format(ret.getTime()), false), + new Metadata(RestUtil.METADATA_KEY_EXPIRATION_ENABLE, "true", false), + new Metadata(RestUtil.METADATA_KEY_EXPIRATION_END, Iso8601Adapter.getFormat().format(exp.getTime()), false)); + + ObjectId objectId = this.api.createObject(request).getObjectId(); + cleanup.add(objectId); + + ReadObjectResponse response = this.api.readObject(new ReadObjectRequest().identifier(objectId), + byte[].class); + Assert.assertNotNull("Null object returned", response.getObject()); + Map metadata = response.getMetadata().getMetadata(); + Assert.assertEquals("Retention not enabled", "true", + metadata.get(RestUtil.METADATA_KEY_RETENTION_ENABLE).getValue()); + Assert.assertNotNull("Retention not set", metadata.get(RestUtil.METADATA_KEY_RETENTION_END)); + Assert.assertEquals("Expiration not enabled", "true", + metadata.get(RestUtil.METADATA_KEY_EXPIRATION_ENABLE).getValue()); + Assert.assertNotNull("Expiration not set", metadata.get(RestUtil.METADATA_KEY_EXPIRATION_END)); + Date expEnd = Iso8601Adapter.getFormat().parse(metadata.get(RestUtil.METADATA_KEY_EXPIRATION_END).getValue()); + + // try to overwrite (should fail) + try { + this.api.updateObject(objectId, "updated during retention"); + Assert.fail("Update allowed during retention period"); + } catch (AtmosException e) { + Assert.assertEquals("Wrong error code from update during retention", 2003, e.getErrorCode()); + } + + // wait for object to expire + Thread.sleep(expEnd.getTime() - System.currentTimeMillis() + 1000); // add a second in case of skew + waited = true; + Assert.assertFalse(this.api.objectExists(objectId)); + } finally { + if (!waited) Thread.sleep(4 * 1000); // let retention expire + } + } + @Test public void testCreateChecksum() throws Exception { byte[] data = "hello".getBytes( "UTF-8" ); diff --git a/src/test/java/com/emc/atmos/mgmt/test/SubTenantMgmtClientTest.java b/src/test/java/com/emc/atmos/mgmt/test/SubTenantMgmtClientTest.java new file mode 100644 index 0000000..c7f1943 --- /dev/null +++ b/src/test/java/com/emc/atmos/mgmt/test/SubTenantMgmtClientTest.java @@ -0,0 +1,122 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.test; + +import com.emc.atmos.mgmt.SubTenantMgmtApi; +import com.emc.atmos.mgmt.SubTenantMgmtConfig; +import com.emc.atmos.mgmt.bean.*; +import com.emc.atmos.mgmt.jersey.SubTenantMgmtClient; +import com.emc.util.TestConfig; +import com.emc.util.TestConstants; +import org.apache.log4j.Logger; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +public class SubTenantMgmtClientTest { + private static final Logger l4j = Logger.getLogger(SubTenantMgmtClientTest.class); + + protected SubTenantMgmtApi client; + + @Before + public void setup() { + SubTenantMgmtConfig config = createSubTenantMgmtConfig(); + Assume.assumeNotNull(config); + client = new SubTenantMgmtClient(config); + } + + private SubTenantMgmtConfig createSubTenantMgmtConfig() { + try { + Properties props = TestConfig.getProperties(); + + String endpoints = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_ENDPOINTS); + String tenant = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_TENANT); + String subTenant = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_SUB_TENANT); + String user = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_SUB_TENANTADMIN_USER); + String password = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_SUB_TENANTADMIN_PASS); + String proxyUrl = props.getProperty(TestConstants.PROP_PROXY); + + List endpointUris = new ArrayList(); + for (String endpoint : endpoints.split(",")) { + endpointUris.add(new URI(endpoint)); + } + + SubTenantMgmtConfig config = new SubTenantMgmtConfig(tenant, subTenant, user, password, endpointUris.toArray(new URI[0])); + config.setDisableSslValidation(true); + + if (proxyUrl != null) { + URI proxyUri = new URI(proxyUrl); + System.setProperty("http.proxyHost", proxyUri.getHost()); + System.setProperty("https.proxyHost", proxyUri.getHost()); + if (proxyUri.getPort() > 0) { + System.setProperty("http.proxyPort", "" + proxyUri.getPort()); + System.setProperty("https.proxyPort", "" + proxyUri.getPort()); + } + } + + return config; + } catch (IOException e) { + l4j.info("Could not load properties file: " + e); + return null; + } catch (URISyntaxException e) { + l4j.info("Invalid endpoint or proxy URI: " + e); + return null; + } + } + + @Test + public void testListUids() { + ListUidsResponse response = client.listUids(); + Assert.assertNotNull(response); + Assert.assertNotNull(response.getUids()); + Assert.assertTrue(response.getUids().size() > 0); + Assert.assertNotNull((response.getUids().get(0))); + } + + @Test + public void testGetSharedSecret() { + ListUidsResponse listResult = client.listUids(); + SharedSecret response = client.getSharedSecret(listResult.getUids().get(0)); + Assert.assertNotNull(response); + Assert.assertNotNull(response.getKeyCreateTime()); + Assert.assertNotNull(response.getSharedSecret()); + } +} diff --git a/src/test/java/com/emc/atmos/mgmt/test/SystemMgmtClientTest.java b/src/test/java/com/emc/atmos/mgmt/test/SystemMgmtClientTest.java new file mode 100644 index 0000000..3ba5c1d --- /dev/null +++ b/src/test/java/com/emc/atmos/mgmt/test/SystemMgmtClientTest.java @@ -0,0 +1,138 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.test; + +import com.emc.atmos.mgmt.SystemMgmtApi; +import com.emc.atmos.mgmt.SystemMgmtConfig; +import com.emc.atmos.mgmt.bean.ListRmgNodesResponse; +import com.emc.atmos.mgmt.bean.ListRmgsResponse; +import com.emc.atmos.mgmt.jersey.SystemMgmtClient; +import com.emc.util.TestConfig; +import com.emc.util.TestConstants; +import org.apache.log4j.Logger; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +public class SystemMgmtClientTest { + private static final Logger l4j = Logger.getLogger(SystemMgmtClientTest.class); + + protected SystemMgmtApi client; + + @Before + public void setup() { + SystemMgmtConfig config = createSystemMgmtConfig(); + Assume.assumeNotNull(config); + client = new SystemMgmtClient(config); + } + + private SystemMgmtConfig createSystemMgmtConfig() { + try { + Properties props = TestConfig.getProperties(); + + String endpoints = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_ENDPOINTS); + String user = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_SYSADMIN_USER); + String password = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_SYSADMIN_PASS); + String proxyUrl = props.getProperty(TestConstants.PROP_PROXY); + + List endpointUris = new ArrayList(); + for (String endpoint : endpoints.split(",")) { + endpointUris.add(new URI(endpoint)); + } + + SystemMgmtConfig config = new SystemMgmtConfig(user, password, endpointUris.toArray(new URI[0])); + config.setDisableSslValidation(true); + + if (proxyUrl != null) { + URI proxyUri = new URI(proxyUrl); + System.setProperty("http.proxyHost", proxyUri.getHost()); + System.setProperty("https.proxyHost", proxyUri.getHost()); + if (proxyUri.getPort() > 0) { + System.setProperty("http.proxyPort", "" + proxyUri.getPort()); + System.setProperty("https.proxyPort", "" + proxyUri.getPort()); + } + } + + return config; + } catch (IOException e) { + l4j.info("Could not load properties file: " + e); + return null; + } catch (URISyntaxException e) { + l4j.info("Invalid endpoint or proxy URI: " + e); + return null; + } + } + + @Test + public void testListRmgs() { + ListRmgsResponse result = client.listRmgs(); + Assert.assertNotNull(result); + Assert.assertNotNull(result.getRmgs()); + Assert.assertTrue(result.getRmgs().size() > 0); + Assert.assertNotNull(result.getRmgs().get(0).getName()); + Assert.assertTrue(result.getRmgs().get(0).getName().trim().length() > 0); + Assert.assertNotNull(result.getRmgs().get(0).getLocalTime()); + Assert.assertTrue(result.getRmgs().get(0).getLocalTime().trim().length() > 0); + Assert.assertTrue(result.getRmgs().get(0).getNodesUp() > 0); + } + + @Test + public void testListRmgNodes() { + ListRmgsResponse rmgResult = client.listRmgs(); + Assert.assertNotNull(rmgResult); + Assert.assertNotNull(rmgResult.getRmgs()); + Assert.assertTrue(rmgResult.getRmgs().size() > 0); + Assert.assertNotNull(rmgResult.getRmgs().get(0).getName()); + String rmgName = rmgResult.getRmgs().get(0).getName().trim(); + + ListRmgNodesResponse result = client.listRmgNodes(rmgName); + Assert.assertNotNull(result); + Assert.assertNotNull(result.getNodes()); + Assert.assertTrue(result.getNodes().size() > 0); + Assert.assertNotNull(result.getNodes().get(0).getName()); + Assert.assertTrue(result.getNodes().get(0).getName().trim().length() > 0); + Assert.assertNotNull(result.getNodes().get(0).getMgmtIp()); + Assert.assertTrue(result.getNodes().get(0).getMgmtIp().trim().length() > 0); + Assert.assertNotNull(result.getNodes().get(0).getUp()); + Assert.assertNotNull(result.getNodes().get(0).getLocation()); + Assert.assertTrue(result.getNodes().get(0).getLocation().trim().length() > 0); + } +} diff --git a/src/test/java/com/emc/atmos/mgmt/test/TenantMgmtClientTest.java b/src/test/java/com/emc/atmos/mgmt/test/TenantMgmtClientTest.java new file mode 100644 index 0000000..08967a8 --- /dev/null +++ b/src/test/java/com/emc/atmos/mgmt/test/TenantMgmtClientTest.java @@ -0,0 +1,235 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.atmos.mgmt.test; + +import com.emc.atmos.mgmt.TenantMgmtApi; +import com.emc.atmos.mgmt.TenantMgmtConfig; +import com.emc.atmos.mgmt.bean.*; +import com.emc.atmos.mgmt.jersey.TenantMgmtClient; +import com.emc.util.TestConfig; +import com.emc.util.TestConstants; +import org.apache.log4j.Logger; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +public class TenantMgmtClientTest { + private static final Logger l4j = Logger.getLogger(TenantMgmtClientTest.class); + + private TenantMgmtApi client; + private String subtenant; + + @Before + public void setup() { + TenantMgmtConfig config = createTenantMgmtConfig(); + Assume.assumeNotNull(config); + client = new TenantMgmtClient(config); + } + + private TenantMgmtConfig createTenantMgmtConfig() { + try { + Properties props = TestConfig.getProperties(); + + String endpoints = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_ENDPOINTS); + String tenant = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_TENANT); + subtenant = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_SUB_TENANT); + String user = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_TENANTADMIN_USER); + String password = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_MGMT_TENANTADMIN_PASS); + String proxyUrl = props.getProperty(TestConstants.PROP_PROXY); + + List endpointUris = new ArrayList(); + for (String endpoint : endpoints.split(",")) { + endpointUris.add(new URI(endpoint)); + } + + TenantMgmtConfig config = new TenantMgmtConfig(tenant, user, password, endpointUris.toArray(new URI[0])); + config.setDisableSslValidation(true); + + if (proxyUrl != null) { + URI proxyUri = new URI(proxyUrl); + System.setProperty("http.proxyHost", proxyUri.getHost()); + System.setProperty("https.proxyHost", proxyUri.getHost()); + if (proxyUri.getPort() > 0) { + System.setProperty("http.proxyPort", "" + proxyUri.getPort()); + System.setProperty("https.proxyPort", "" + proxyUri.getPort()); + } + } + + return config; + } catch (IOException e) { + l4j.info("Could not load properties file: " + e); + return null; + } catch (URISyntaxException e) { + l4j.info("Invalid endpoint or proxy URI: " + e); + return null; + } + } + + @Test + public void testGetTenantInfo() { + GetTenantInfoResponse result = client.getTenantInfo(); + Assert.assertNotNull(result); + Assert.assertNotNull(result.getTenant()); + checkTenant(result.getTenant()); + } + + private void checkTenant(PoxTenant tenant) { + Assert.assertNotNull(tenant); + Assert.assertNotNull(tenant.getName()); + Assert.assertTrue(tenant.getName().trim().length() > 0); + Assert.assertNotNull(tenant.getId()); + Assert.assertTrue(tenant.getId().trim().length() > 0); + + Assert.assertNotNull(tenant.getTenantAdminList()); + Assert.assertTrue(tenant.getTenantAdminList().size() > 0); + checkAdminUser(tenant.getTenantAdminList().get(0)); + + Assert.assertNotNull(tenant.getSubtenantList()); + Assert.assertTrue(tenant.getSubtenantList().size() > 0); + checkSubtenant(tenant.getSubtenantList().get(0)); + } + + @Test + public void testListSubtenants() { + ListSubtenantsResponse response = client.listSubtenants(); + Assert.assertNotNull(response); + Assert.assertNotNull(response.getSubtenants()); + Assert.assertTrue(response.getSubtenants().size() > 0); + for (Subtenant subtenant : response.getSubtenants()) { + if (this.subtenant.equals(subtenant.getName())) + checkSubtenant(subtenant); + } + } + + private void checkSubtenant(AbstractSubtenant subtenant) { + Assert.assertNotNull(subtenant); + Assert.assertNotNull(subtenant.getName()); + Assert.assertTrue(subtenant.getName().trim().length() > 0); + Assert.assertNotNull(subtenant.getId()); + Assert.assertTrue(subtenant.getId().trim().length() > 0); + Assert.assertNotNull(subtenant.getAuthenticationSource()); + Assert.assertNotNull(subtenant.getStatus()); + if (subtenant instanceof Subtenant) { + Subtenant subt = (Subtenant) subtenant; + Assert.assertNotNull(subt.getSubtenantAdminNames()); + if (subt.getSubtenantAdminNames().size() > 0) + Assert.assertNotNull(subt.getSubtenantAdminNames().get(0)); + } else if (subtenant instanceof SubtenantDetails) { + SubtenantDetails subt = (SubtenantDetails) subtenant; + Assert.assertNotNull(subt.getSubtenantAdminList()); + if (subt.getSubtenantAdminList().size() > 0) + checkAdminUser(subt.getSubtenantAdminList().get(0)); + } + } + + private void checkAdminUser(AdminUser adminUser) { + Assert.assertNotNull(adminUser); + Assert.assertNotNull(adminUser.getName()); + Assert.assertNotNull(adminUser.getAuthenticationSource()); + } + + private void checkObjectUser(ObjectUser objectUser) { + Assert.assertNotNull(objectUser); + Assert.assertNotNull(objectUser.getUid()); + Assert.assertTrue(objectUser.getUid().trim().length() > 0); + Assert.assertNotNull(objectUser.getSharedSecret()); + Assert.assertTrue(objectUser.getSharedSecret().trim().length() > 0); + Assert.assertNotNull(objectUser.getStatus()); + } + + @Test + public void testGetSubtenantDetails() { + ListSubtenantsResponse listResult = client.listSubtenants(); + GetSubtenantResponse response = client.getSubtenant(listResult.getSubtenants().get(0).getName()); + Assert.assertNotNull(response); + checkSubtenant(response.getSubtenant()); + Assert.assertNotNull(response.getSubtenant().getDefaultPolicySpec()); + Assert.assertTrue(response.getSubtenant().getDefaultPolicySpec().trim().length() > 0); + Assert.assertNotNull(response.getSubtenant().getObjectUsers()); + Assert.assertTrue(response.getSubtenant().getObjectUsers().size() > 0); + checkObjectUser(response.getSubtenant().getObjectUsers().get(0)); + } + + @Test + public void testListPolicies() { + ListPoliciesResponse response = client.listPolicies(); + Assert.assertNotNull(response); + Assert.assertNotNull(response.getPolicies()); + Assert.assertTrue(response.getPolicies().size() > 0); + checkPolicy(response.getPolicies().get(0)); + } + + private void checkPolicy(PoxPolicy policy) { + Assert.assertNotNull(policy); + Assert.assertNotNull(policy.getName()); + Assert.assertTrue(policy.getName().trim().length() > 0); + if (policy.getReplicaList().size() > 0) + checkReplica(policy.getReplicaList().get(0)); + } + + private void checkReplica(PoxReplica replica) { + Assert.assertNotNull(replica); + Assert.assertNotNull(replica.getType()); + Assert.assertTrue(replica.getType().trim().length() > 0); + Assert.assertNotNull(replica.getLocations()); + Assert.assertTrue(replica.getLocations().trim().length() > 0); + Assert.assertNotNull(replica.getLocation()); + Assert.assertTrue(replica.getLocation().trim().length() > 0); + } + + @Test + public void testListUids() { + ListUidsResponse response = client.listUids(subtenant); + Assert.assertNotNull(response); + Assert.assertNotNull(response.getUids()); + Assert.assertTrue(response.getUids().size() > 0); + Assert.assertNotNull((response.getUids().get(0))); + } + + @Test + public void testGetSharedSecret() { + ListUidsResponse listResult = client.listUids(subtenant); + SharedSecret response = client.getSharedSecret(subtenant, listResult.getUids().get(0)); + Assert.assertNotNull(response); + Assert.assertNotNull(response.getKeyCreateTime()); + Assert.assertNotNull(response.getSharedSecret()); + } +} diff --git a/src/test/java/com/emc/atmos/util/AtmosClientFactory.java b/src/test/java/com/emc/atmos/util/AtmosClientFactory.java index aeef93f..be609b9 100644 --- a/src/test/java/com/emc/atmos/util/AtmosClientFactory.java +++ b/src/test/java/com/emc/atmos/util/AtmosClientFactory.java @@ -30,6 +30,7 @@ import com.emc.atmos.api.AtmosConfig; import com.emc.atmos.api.jersey.AtmosApiClient; import com.emc.util.TestConfig; +import com.emc.util.TestConstants; import org.apache.log4j.Logger; import java.io.IOException; @@ -54,12 +55,6 @@ public class AtmosClientFactory { private static final Logger l4j = Logger.getLogger(AtmosClientFactory.class); - public static final String PROP_ATMOS_UID = "atmos.uid"; - public static final String PROP_ATMOS_SECRET = "atmos.secret"; - public static final String PROP_ATMOS_ENDPOINTS = "atmos.endpoints"; - public static final String PROP_ATMOS_IS_ECS = "atmos.is_ecs"; - public static final String PROP_PROXY = "http.proxyUri"; - public static AtmosApi getAtmosClient() { AtmosConfig config = getAtmosConfig(); if(config == null) { @@ -72,10 +67,10 @@ public static AtmosConfig getAtmosConfig() { try { Properties props = TestConfig.getProperties(); - String uid = TestConfig.getPropertyNotEmpty(props, PROP_ATMOS_UID); - String secret = TestConfig.getPropertyNotEmpty(props, PROP_ATMOS_SECRET); - String endpoints = TestConfig.getPropertyNotEmpty(props, PROP_ATMOS_ENDPOINTS); - String proxyUrl = props.getProperty(PROP_PROXY); + String uid = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_ATMOS_UID); + String secret = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_ATMOS_SECRET); + String endpoints = TestConfig.getPropertyNotEmpty(props, TestConstants.PROP_ATMOS_ENDPOINTS); + String proxyUrl = props.getProperty(TestConstants.PROP_PROXY); List endpointUris = new ArrayList(); for (String endpoint : endpoints.split(",")) { @@ -99,7 +94,7 @@ public static boolean atmosIsEcs() { try { Properties props = TestConfig.getProperties(); - return Boolean.parseBoolean(props.getProperty(PROP_ATMOS_IS_ECS, "false")); + return Boolean.parseBoolean(props.getProperty(TestConstants.PROP_ATMOS_IS_ECS, "false")); } catch (IOException e) { l4j.info("Could not load properties file: " + e); diff --git a/src/test/java/com/emc/util/TestConstants.java b/src/test/java/com/emc/util/TestConstants.java new file mode 100644 index 0000000..efac266 --- /dev/null +++ b/src/test/java/com/emc/util/TestConstants.java @@ -0,0 +1,55 @@ +/* + * BSD 3-Clause License + * + * Copyright (c) 2013-2018, Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package com.emc.util; + +public final class TestConstants { + public static final String PROP_ATMOS_UID = "atmos.uid"; + public static final String PROP_ATMOS_SECRET = "atmos.secret"; + public static final String PROP_ATMOS_ENDPOINTS = "atmos.endpoints"; + public static final String PROP_ATMOS_IS_ECS = "atmos.is_ecs"; + + public static final String PROP_MGMT_ENDPOINTS = "atmos.mgmt.endpoints"; + public static final String PROP_MGMT_SYSADMIN_USER = "atmos.mgmt.sysadmin.user"; + public static final String PROP_MGMT_SYSADMIN_PASS = "atmos.mgmt.sysadmin.password"; + public static final String PROP_MGMT_TENANT = "atmos.mgmt.tenant"; + public static final String PROP_MGMT_TENANTADMIN_USER = "atmos.mgmt.tenantadmin.user"; + public static final String PROP_MGMT_TENANTADMIN_PASS = "atmos.mgmt.tenantadmin.password"; + public static final String PROP_MGMT_SUB_TENANT = "atmos.mgmt.sub_tenant"; + public static final String PROP_MGMT_SUB_TENANTADMIN_USER = "atmos.mgmt.subtenantadmin.user"; + public static final String PROP_MGMT_SUB_TENANTADMIN_PASS = "atmos.mgmt.subtenantadmin.password"; + + public static final String PROP_PROXY = "http.proxyUri"; + + private TestConstants() { + } +} diff --git a/src/test/resources/test.properties.template b/src/test/resources/test.properties.template index 539fb72..5930477 100644 --- a/src/test/resources/test.properties.template +++ b/src/test/resources/test.properties.template @@ -20,5 +20,16 @@ atmos.is_ecs=true encryption.public_key=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCXwte+fuZHBt07GP+idU3K+pSpZl3dt5O6iS9Am14G3/3JlqsdkDPdcyk6YWvn6J3SIreaty9csnf4OOSkWATrCwYnCP562FnbwcVZQ5LjKoJodCxRkbZSOD8feWFzNtg6PWPagoxeAS1hAyjuUHLbCgcyCVEdr0Nu5rybrEWVDwIDAQAB encryption.private_key=MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJfC175+5kcG3TsY/6J1Tcr6lKlmXd23k7qJL0CbXgbf/cmWqx2QM91zKTpha+fondIit5q3L1yyd/g45KRYBOsLBicI/nrYWdvBxVlDkuMqgmh0LFGRtlI4Px95YXM22Do9Y9qCjF4BLWEDKO5QctsKBzIJUR2vQ27mvJusRZUPAgMBAAECgYAeKen7wPlAMMsUDfnxbmNR7tBRgzkw8mX4c3/i1X6w2yB0SvAj5h+I6nTNV8O8ym1j8OaRZ8uQHyDdQ2GekKgZRuPu/Fl2CxcvygbxLvyFeMDSeQQiuZZbmOMvBJL+FjelFRjDm1lPOZslw7WZYrJloxtgVyx/SVRezO2BZ4lRMQJBAPsd5+QGUyKy0WDxPolkx2CTM4tx/IdmkmqD6mHIPoHHI74wA5wyVCCEioNoyhxZvfAPKoT47jN8LHkF4McDDv0CQQCatlSZlNxFQKGQiBojmsfYbrsGPBYd52hm5DSWAaECx62TGCd5kvFBB9BFlxWde1Uza1Mhg0F9MzsDdrGtbl/7AkBYDkuTbRhX8YZ0TQQV363+Un/fpQ/dVv1+tlVJBpPMpE0HUwThD9DqOi/sFqHQwTNWa6sIR9YXXbKmmYYRoyPtAkAjZzfi0Tq6qjiOj2aT4TZ8I5KusY9KFotAiFY0QXkr3q+sqmlWG7cTb4tMcW9j0zZDBvtF/vg8gz2s5DtyeYCDAkAbstmaj40dU/HCUCEQE387aZceXndvd9jRngOKvixFHi7rPAC8Ja3XcPmLaD29nyqawpQL2nSI8pomKBnCUKTX +## Mgmt endpoint and credentials for mgmt API tests +atmos.mgmt.endpoints=https://,https:// +atmos.mgmt.sysadmin.user= +atmos.mgmt.sysadmin.password= +atmos.mgmt.tenant= +atmos.mgmt.tenantadmin.user= +atmos.mgmt.tenantadmin.password= +atmos.mgmt.sub_tenant= +atmos.mgmt.subtenantadmin.user= +atmos.mgmt.subtenantadmin.password= + ## Optional -- HTTP proxy host and port. Useful for debugging. #http.proxy=http://localhost:8888