summaryrefslogtreecommitdiffstats
path: root/com.gluster.storage.management.client/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'com.gluster.storage.management.client/src/com')
-rw-r--r--com.gluster.storage.management.client/src/com/gluster/storage/management/client/AuthManager.java32
-rw-r--r--com.gluster.storage.management.client/src/com/gluster/storage/management/client/RESTClientTest.java24
2 files changed, 56 insertions, 0 deletions
diff --git a/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AuthManager.java b/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AuthManager.java
new file mode 100644
index 00000000..3adae9d0
--- /dev/null
+++ b/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AuthManager.java
@@ -0,0 +1,32 @@
+package com.gluster.storage.management.client;
+
+import java.net.URI;
+
+import javax.ws.rs.core.UriBuilder;
+
+import com.gluster.storage.management.core.model.ConnectionDetails;
+
+public class AuthManager {
+ public boolean authenticate(ConnectionDetails connectionDetails) {
+// WebResource service = Client.create(new DefaultClientConfig()).resource(getBaseURI());
+//
+// AuthStatus authStatus = service.path("services").path("login")
+// .queryParam("user", connectionDetails.getUserId())
+// .queryParam("password", connectionDetails.getPassword()).accept(MediaType.TEXT_XML)
+// .get(AuthStatus.class);
+//
+// return authStatus.getIsAuthenticated();
+
+ // Dummy authentication for demo application
+ return (connectionDetails.getPassword().equals("gluster") ? true : false);
+ }
+
+ public static void main(String[] args) {
+ AuthManager authManager = new AuthManager();
+ System.out.println(authManager.authenticate(new ConnectionDetails("", "gluster", "gluster")));
+ }
+
+ private static URI getBaseURI() {
+ return UriBuilder.fromUri("http://localhost:8080/glustersp").build();
+ }
+}
diff --git a/com.gluster.storage.management.client/src/com/gluster/storage/management/client/RESTClientTest.java b/com.gluster.storage.management.client/src/com/gluster/storage/management/client/RESTClientTest.java
new file mode 100644
index 00000000..0afb488f
--- /dev/null
+++ b/com.gluster.storage.management.client/src/com/gluster/storage/management/client/RESTClientTest.java
@@ -0,0 +1,24 @@
+package com.gluster.storage.management.client;
+
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+
+public class RESTClientTest {
+ public static void main(String args[]) {
+ WebResource service = Client.create(new DefaultClientConfig()).resource(getBaseURI());
+ String name = service.path("services").path("name").accept(MediaType.TEXT_PLAIN).get(String.class);
+ System.out.println(name);
+ name = service.path("services").path("name/xml").accept(MediaType.TEXT_XML).get(String.class);
+ System.out.println(name);
+ }
+
+ private static URI getBaseURI() {
+ return UriBuilder.fromUri("http://localhost:8080/glustermc").build();
+ }
+}