stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pradee...@apache.org
Subject [1/2] git commit: cookie endpoint to mockContext as well
Date Thu, 06 Feb 2014 04:26:08 GMT
Updated Branches:
  refs/heads/master 101a4ec26 -> e5d7e1fd3


cookie endpoint to mockContext as well


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/d7208b90
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/d7208b90
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/d7208b90

Branch: refs/heads/master
Commit: d7208b902c06b01dda74f72c6dc5b656ad626209
Parents: f44be60
Author: Pradeep Fernando <pradeepfn@gmail.com>
Authored: Thu Feb 6 09:55:04 2014 +0530
Committer: Pradeep Fernando <pradeepfn@gmail.com>
Committed: Thu Feb 6 09:55:04 2014 +0530

----------------------------------------------------------------------
 .../rest/endpoint/mock/StratosTestAdmin.java    | 21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d7208b90/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosTestAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosTestAdmin.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosTestAdmin.java
index 208d521..79704f1 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosTestAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosTestAdmin.java
@@ -25,6 +25,7 @@ import org.apache.stratos.common.beans.TenantInfoBean;
 import org.apache.stratos.manager.dto.Cartridge;
 import org.apache.stratos.manager.dto.SubscriptionInfo;
 import org.apache.stratos.manager.exception.ADCException;
+import org.apache.stratos.rest.endpoint.Utils;
 import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction;
 import org.apache.stratos.rest.endpoint.annotation.SuperTenantService;
 import org.apache.stratos.rest.endpoint.bean.CartridgeInfoBean;
@@ -35,11 +36,31 @@ import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.Deploy
 import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean;
 import org.apache.stratos.rest.endpoint.exception.RestAPIException;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
 import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 
 @Path("/admin/")
 public class StratosTestAdmin {
     private static Log log = LogFactory.getLog(StratosTestAdmin.class);
+    @Context
+    HttpServletRequest httpServletRequest;
+
+    
+    @GET
+    @Path("/cookie")
+    @Produces("application/json")
+    @Consumes("application/json")
+    @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+    public Response getCookie(){
+        HttpSession httpSession = httpServletRequest.getSession(true);//create session if
not found
+        String sessionId = httpSession.getId();
+        return Response.ok().header("WWW-Authenticate", "Basic").type(MediaType.APPLICATION_JSON).
+                entity(Utils.buildAuthenticationSuccessMessage(sessionId)).build();
+    }
 
     @GET
     @Path("/cartridge/tenanted/list")


Mime
View raw message