Repository: sqoop Updated Branches: refs/heads/sqoop2 a18d27e37 -> 391f9cfa7
SQOOP-2273: Sqoop2: Move authorizationServlet into v1 package (Richard Zhou via Abraham Elmahrek) Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/391f9cfa Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/391f9cfa Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/391f9cfa Branch: refs/heads/sqoop2 Commit: 391f9cfa76ae65100e134187106875977ca79c2a Parents: a18d27e Author: Abraham Elmahrek <[email protected]> Authored: Mon Mar 30 10:03:43 2015 -0700 Committer: Abraham Elmahrek <[email protected]> Committed: Mon Mar 30 10:03:43 2015 -0700 ---------------------------------------------------------------------- .../sqoop/server/AuthorizationServlet.java | 89 ------------------- .../sqoop/server/v1/AuthorizationServlet.java | 92 ++++++++++++++++++++ server/src/main/webapp/WEB-INF/web.xml | 2 +- 3 files changed, 93 insertions(+), 90 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sqoop/blob/391f9cfa/server/src/main/java/org/apache/sqoop/server/AuthorizationServlet.java ---------------------------------------------------------------------- diff --git a/server/src/main/java/org/apache/sqoop/server/AuthorizationServlet.java b/server/src/main/java/org/apache/sqoop/server/AuthorizationServlet.java deleted file mode 100644 index 4af26d9..0000000 --- a/server/src/main/java/org/apache/sqoop/server/AuthorizationServlet.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sqoop.server; - -import org.apache.sqoop.handler.AuthorizationRequestHandler; -import org.apache.sqoop.json.JsonBean; - -/** - * Provides operations for authorization - * - * POST /authorization/roles/create - * Create new role with {name} - * - * DELETE /authorization/role/{role-name} - * - * GET /authorization/roles - * Show all roles - * - * GET /authorization/principals?role_name={name} - * Show all principals in role with {name} - * - * GET /authorization/roles?principal_type={type}&principal_name={name} - * Show all roles in principal with {name, type} - * - * PUT /authorization/roles/grant - * Grant a role to a user/group/role - * PUT data of JsonObject role(name) and principal (name, type) - * - * PUT /authorization/roles/revoke - * Revoke a role to a user/group/role - * PUT data of JsonObject role(name) and principal (name, type) - * - * PUT /authorization/privileges/grant - * Grant a privilege to a principal - * PUT data of JsonObject principal(name, type) and privilege (resource-name, resource-type, action, with-grant-option) - * - * PUT /authorization/privileges/revoke - * Revoke a privilege to a principal - * PUT data of JsonObject principal(name, type) and privilege (resource-name, resource-type, action, with-grant-option) - * If privilege is null, then revoke all privileges for principal(name, type) - * - * GET /authorization/privileges?principal_type={type}&principal_name={name}&resource_type={type}&resource_name={name} - * Show all privileges in principal with {name, type} and resource with {resource-name, resource-type} - * If resource is null, then show all privileges in principal with {name, type} - */ -@SuppressWarnings("serial") -public class AuthorizationServlet extends SqoopProtocolServlet { - - private RequestHandler authorizationRequestHandler; - - public AuthorizationServlet() { - authorizationRequestHandler = new AuthorizationRequestHandler(); - } - - @Override - protected JsonBean handleGetRequest(RequestContext ctx) throws Exception { - return authorizationRequestHandler.handleEvent(ctx); - } - - @Override - protected JsonBean handlePostRequest(RequestContext ctx) throws Exception { - return authorizationRequestHandler.handleEvent(ctx); - } - - @Override - protected JsonBean handlePutRequest(RequestContext ctx) throws Exception { - return authorizationRequestHandler.handleEvent(ctx); - } - - @Override - protected JsonBean handleDeleteRequest(RequestContext ctx) throws Exception { - return authorizationRequestHandler.handleEvent(ctx); - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/391f9cfa/server/src/main/java/org/apache/sqoop/server/v1/AuthorizationServlet.java ---------------------------------------------------------------------- diff --git a/server/src/main/java/org/apache/sqoop/server/v1/AuthorizationServlet.java b/server/src/main/java/org/apache/sqoop/server/v1/AuthorizationServlet.java new file mode 100644 index 0000000..162fbee --- /dev/null +++ b/server/src/main/java/org/apache/sqoop/server/v1/AuthorizationServlet.java @@ -0,0 +1,92 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sqoop.server.v1; + +import org.apache.sqoop.handler.AuthorizationRequestHandler; +import org.apache.sqoop.json.JsonBean; +import org.apache.sqoop.server.RequestContext; +import org.apache.sqoop.server.RequestHandler; +import org.apache.sqoop.server.SqoopProtocolServlet; + +/** + * Provides operations for authorization + * + * POST v1/authorization/roles/create + * Create new role with {name} + * + * DELETE v1/authorization/role/{role-name} + * + * GET v1/authorization/roles + * Show all roles + * + * GET v1/authorization/principals?role_name={name} + * Show all principals in role with {name} + * + * GET v1/authorization/roles?principal_type={type}&principal_name={name} + * Show all roles in principal with {name, type} + * + * PUT v1/authorization/roles/grant + * Grant a role to a user/group/role + * PUT data of JsonObject role(name) and principal (name, type) + * + * PUT v1/authorization/roles/revoke + * Revoke a role to a user/group/role + * PUT data of JsonObject role(name) and principal (name, type) + * + * PUT v1/authorization/privileges/grant + * Grant a privilege to a principal + * PUT data of JsonObject principal(name, type) and privilege (resource-name, resource-type, action, with-grant-option) + * + * PUT v1/authorization/privileges/revoke + * Revoke a privilege to a principal + * PUT data of JsonObject principal(name, type) and privilege (resource-name, resource-type, action, with-grant-option) + * If privilege is null, then revoke all privileges for principal(name, type) + * + * GET v1/authorization/privileges?principal_type={type}&principal_name={name}&resource_type={type}&resource_name={name} + * Show all privileges in principal with {name, type} and resource with {resource-name, resource-type} + * If resource is null, then show all privileges in principal with {name, type} + */ +@SuppressWarnings("serial") +public class AuthorizationServlet extends SqoopProtocolServlet { + + private RequestHandler authorizationRequestHandler; + + public AuthorizationServlet() { + authorizationRequestHandler = new AuthorizationRequestHandler(); + } + + @Override + protected JsonBean handleGetRequest(RequestContext ctx) throws Exception { + return authorizationRequestHandler.handleEvent(ctx); + } + + @Override + protected JsonBean handlePostRequest(RequestContext ctx) throws Exception { + return authorizationRequestHandler.handleEvent(ctx); + } + + @Override + protected JsonBean handlePutRequest(RequestContext ctx) throws Exception { + return authorizationRequestHandler.handleEvent(ctx); + } + + @Override + protected JsonBean handleDeleteRequest(RequestContext ctx) throws Exception { + return authorizationRequestHandler.handleEvent(ctx); + } +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/391f9cfa/server/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/server/src/main/webapp/WEB-INF/web.xml b/server/src/main/webapp/WEB-INF/web.xml index 60ee8c4..94cea1c 100644 --- a/server/src/main/webapp/WEB-INF/web.xml +++ b/server/src/main/webapp/WEB-INF/web.xml @@ -161,7 +161,7 @@ limitations under the License. <!-- Authorization servlet --> <servlet> <servlet-name>authorization.AuthorizationServlet</servlet-name> - <servlet-class>org.apache.sqoop.server.AuthorizationServlet</servlet-class> + <servlet-class>org.apache.sqoop.server.v1.AuthorizationServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet>
