[Carbon-commits] [Carbon-Core] svn commit r68131 - in trunk/carbon/core/org.wso2.carbon.server: . src/main/java/org/wso2/carbon/server

azeez at wso2.com azeez at wso2.com
Thu Jun 17 08:17:01 PDT 2010


Author: azeez
Date: Thu Jun 17 08:17:01 2010
New Revision: 68131
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=68131

Log:
Adding UserRealm integration

Modified:
   trunk/carbon/core/org.wso2.carbon.server/pom.xml
   trunk/carbon/core/org.wso2.carbon.server/src/main/java/org/wso2/carbon/server/TomcatServer.java

Modified: trunk/carbon/core/org.wso2.carbon.server/pom.xml
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/core/org.wso2.carbon.server/pom.xml?rev=68131&r1=68130&r2=68131&view=diff
==============================================================================
--- trunk/carbon/core/org.wso2.carbon.server/pom.xml	(original)
+++ trunk/carbon/core/org.wso2.carbon.server/pom.xml	Thu Jun 17 08:17:01 2010
@@ -170,6 +170,11 @@
             <groupId>org.apache.synapse</groupId>
             <artifactId>synapse-securevault</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.user.core</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
     </dependencies>
 
     <build>

Modified: trunk/carbon/core/org.wso2.carbon.server/src/main/java/org/wso2/carbon/server/TomcatServer.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/core/org.wso2.carbon.server/src/main/java/org/wso2/carbon/server/TomcatServer.java?rev=68131&r1=68130&r2=68131&view=diff
==============================================================================
--- trunk/carbon/core/org.wso2.carbon.server/src/main/java/org/wso2/carbon/server/TomcatServer.java	(original)
+++ trunk/carbon/core/org.wso2.carbon.server/src/main/java/org/wso2/carbon/server/TomcatServer.java	Thu Jun 17 08:17:01 2010
@@ -19,7 +19,9 @@
 import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
 import org.apache.catalina.Host;
+import org.apache.catalina.realm.GenericPrincipal;
 import org.apache.catalina.realm.MemoryRealm;
+import org.apache.catalina.realm.RealmBase;
 import org.apache.catalina.startup.Embedded;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -28,6 +30,7 @@
 
 import java.io.File;
 import java.lang.management.ManagementPermission;
+import java.security.Principal;
 
 /**
  * Represents a Tomcat Server instance
@@ -125,6 +128,7 @@
 
         // Create an engine
         engine = embedded.createEngine();
+        engine.setRealm(new CarbonTomcatRealm());
         embedded.addEngine(engine);
         TomcatServerCache.setEngine(engine);
         TransportManager.init();
@@ -204,4 +208,39 @@
         checkPermission();
         embedded.stop();
     }
+
+    private static class CarbonTomcatRealm extends RealmBase {
+        public CarbonTomcatRealm() {
+            
+        }
+
+        @Override
+        protected String getName() {
+            //TODO: Method implementation
+            return null;
+        }
+
+        @Override
+        protected String getPassword(String username) {
+            //TODO: If username has @ in it, it is a tenant request, so get the relevant tenant realm & get the password
+            // if no @, assume super-tenant call
+            return "admin123";
+        }
+
+        @Override
+        protected Principal getPrincipal(String s) {
+//             GenericPrincipal(Realm realm, String name, String password,
+//                              List roles)
+            //TODO: Get the tenant/super-tenant realm, and set the password & roles
+            GenericPrincipal principal = new GenericPrincipal(this, "admin", "admin123", null){
+
+                @Override
+                public boolean hasRole(String role) {
+                    return true;
+                }
+            };
+
+            return principal;
+        }
+    }
 }



More information about the Carbon-commits mailing list