]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-229 to enable authn on the client, system properties required are cspace.auth...
authorSanjay Dalal <sanjay.dalal@berkeley.edu>
Tue, 30 Jun 2009 18:37:32 +0000 (18:37 +0000)
committerSanjay Dalal <sanjay.dalal@berkeley.edu>
Tue, 30 Jun 2009 18:37:32 +0000 (18:37 +0000)
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java

index f50212f9648af9e46fa147f21560b2e40b96764f..af6f4b37e6c8d29a0ed134f3cc29b8e6587a29e9 100644 (file)
@@ -8,8 +8,10 @@ import org.slf4j.LoggerFactory;
 \r
 public abstract class CollectionSpaceClient {\r
 \r
-    static final String AUTH_PROPERTY = "org.collectionspace.auth";\r
-    static final String SSL_PROPERTY = "org.collectionspace.ssl";\r
+    static final String USER_PROPERTY = "cspace.user";\r
+    static final String PASSWORD_PROPERTY = "cspace.password";\r
+    static final String AUTH_PROPERTY = "cspace.auth";\r
+    static final String SSL_PROPERTY = "cspace.ssl";\r
     static final String URL_PROPERTY = "org.collectionspace.url";\r
     /*\r
     static final String URL_PROPERTY_SCHEME = "org.collectionspace.url.schme";\r
@@ -40,9 +42,20 @@ public abstract class CollectionSpaceClient {
         useAuth = Boolean.getBoolean(AUTH_PROPERTY);\r
         if(useAuth){\r
             httpClient = new HttpClient();\r
+            String user = System.getProperty(USER_PROPERTY);\r
+            if(user == null || "".equals(user)){\r
+                user = "test";\r
+            }\r
+            String password = System.getProperty(PASSWORD_PROPERTY);\r
+            if(password == null || "".equals(password)){\r
+                password = "test";\r
+            }\r
+            if(logger.isDebugEnabled()){\r
+                logger.debug("using user=" + user + " password=" + password);\r
+            }\r
             httpClient.getState().setCredentials(\r
                     new AuthScope(HOST, PORT, AuthScope.ANY_REALM),\r
-                    new UsernamePasswordCredentials("test", "test"));\r
+                    new UsernamePasswordCredentials(user, password));\r
             httpClient.getParams().setAuthenticationPreemptive(true);\r
             if(logger.isDebugEnabled()){\r
                 logger.debug("set up httpClient for authentication");\r