felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1459226 - in /felix/trunk/jaas/src: main/java/org/apache/felix/jaas/internal/ test/java/org/apache/felix/jaas/integration/
Date Thu, 21 Mar 2013 11:20:02 GMT
Author: chetanm
Date: Thu Mar 21 11:20:01 2013
New Revision: 1459226

URL: http://svn.apache.org/r1459226
Log:
FELIX-3985 - ConfigSpiOsgi should be registered by default

The ConfigSpi now registers upon activation with default config

Modified:
    felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/ConfigSpiOsgi.java
    felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/ITJaasWithBootClasspath.java
    felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/ITJaasWithConfigBasedLoginModule.java
    felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/JaasTestBase.java

Modified: felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/ConfigSpiOsgi.java
URL: http://svn.apache.org/viewvc/felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/ConfigSpiOsgi.java?rev=1459226&r1=1459225&r2=1459226&view=diff
==============================================================================
--- felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/ConfigSpiOsgi.java (original)
+++ felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/ConfigSpiOsgi.java Thu Mar
21 11:20:01 2013
@@ -23,12 +23,24 @@ import java.security.NoSuchAlgorithmExce
 import java.security.NoSuchProviderException;
 import java.security.Provider;
 import java.security.Security;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.security.auth.Subject;
 import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.*;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.ConfigurationSpi;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
 
 import org.apache.felix.jaas.LoginContextFactory;
 import org.apache.felix.jaas.LoginModuleFactory;
@@ -115,10 +127,11 @@ public class ConfigSpiOsgi extends Confi
 
     private ServiceRegistration spiReg;
 
-    public ConfigSpiOsgi(BundleContext context, Logger log)
-    {
+    public ConfigSpiOsgi(BundleContext context, Logger log) throws ConfigurationException
{
         this.context = context;
         this.log = log;
+
+        updated(getDefaultConfig());
         this.tracker = new ServiceTracker(context, LoginModuleFactory.class.getName(),
             this);
 
@@ -331,6 +344,21 @@ public class ConfigSpiOsgi extends Confi
         }
     }
 
+    private Dictionary<String,String> getDefaultConfig() throws ConfigurationException
+    {
+        //Determine default config. Value can still be overridden by BundleContext properties
+        Dictionary<String,String> dict = new Hashtable<String,String>();
+        put(dict,JAAS_DEFAULT_REALM_NAME,DEFAULT_REALM_NAME);
+        put(dict,JAAS_CONFIG_PROVIDER_NAME,DEFAULT_CONFIG_PROVIDER_NAME);
+        put(dict, JAAS_CONFIG_POLICY, GlobalConfigurationPolicy.DEFAULT.name());
+        return dict;
+    }
+
+    private void put(Dictionary<String,String> dict, String key, String defaultValue)
+    {
+        dict.put(key,PropertiesUtil.toString(context.getProperty(key),defaultValue));
+    }
+
     // --------------JAAS/JCA/Security ----------------------------------------
 
     private void registerProvider(String providerName)

Modified: felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/ITJaasWithBootClasspath.java
URL: http://svn.apache.org/viewvc/felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/ITJaasWithBootClasspath.java?rev=1459226&r1=1459225&r2=1459226&view=diff
==============================================================================
--- felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/ITJaasWithBootClasspath.java
(original)
+++ felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/ITJaasWithBootClasspath.java
Thu Mar 21 11:20:01 2013
@@ -20,8 +20,6 @@
 package org.apache.felix.jaas.integration;
 
 import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
 
 import javax.security.auth.Subject;
 import javax.security.auth.callback.CallbackHandler;
@@ -93,7 +91,6 @@ public class ITJaasWithBootClasspath ext
     public void testJaasWithBoot() throws Exception
     {
         String realmName = name.getMethodName();
-        createConfigSpiConfig();
         createLoginModuleConfig(realmName);
         delay();
 

Modified: felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/ITJaasWithConfigBasedLoginModule.java
URL: http://svn.apache.org/viewvc/felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/ITJaasWithConfigBasedLoginModule.java?rev=1459226&r1=1459225&r2=1459226&view=diff
==============================================================================
--- felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/ITJaasWithConfigBasedLoginModule.java
(original)
+++ felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/ITJaasWithConfigBasedLoginModule.java
Thu Mar 21 11:20:01 2013
@@ -19,12 +19,6 @@
 
 package org.apache.felix.jaas.integration;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.composite;
-import static org.ops4j.pax.exam.CoreOptions.streamBundle;
-
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Dictionary;
@@ -51,6 +45,12 @@ import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class ITJaasWithConfigBasedLoginModule extends JaasTestBase
@@ -78,7 +78,6 @@ public class ITJaasWithConfigBasedLoginM
     @Test
     public void testJaasWithTCCL() throws Exception {
         String realmName = name.getMethodName();
-        createConfigSpiConfig();
         createLoginModuleConfig(realmName);
         delay();
 
@@ -105,7 +104,6 @@ public class ITJaasWithConfigBasedLoginM
     public void testJaasWithFactory() throws Exception
     {
         String realmName = name.getMethodName();
-        createConfigSpiConfig();
         createLoginModuleConfig(realmName);
         delay();
 
@@ -137,7 +135,6 @@ public class ITJaasWithConfigBasedLoginM
     @Test
     public void testJaasConfigPassing() throws Exception {
         String realmName = name.getMethodName();
-        createConfigSpiConfig();
 
         //1. Create sample config
         org.osgi.service.cm.Configuration config =
@@ -184,7 +181,6 @@ public class ITJaasWithConfigBasedLoginM
     @Test
     public void testJaasConfigOrderedViaRanking() throws Exception {
         String realmName = name.getMethodName();
-        createConfigSpiConfig();
         List<Integer> ranks = Arrays.asList(1,2,3,4,5,6);
         Collections.shuffle(ranks);
 
@@ -221,7 +217,6 @@ public class ITJaasWithConfigBasedLoginM
     @Test
     public void testJaasConfigWithEmptyRealm() throws Exception {
         String realmName = name.getMethodName();
-        createConfigSpiConfig();
 
         //Scenario 1 - Create a config with no realm name set. So its default name would
         //be set to the defaultRealmName setting of ConfigurationSpi. Which defaults to 'other'

Modified: felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/JaasTestBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/JaasTestBase.java?rev=1459226&r1=1459225&r2=1459226&view=diff
==============================================================================
--- felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/JaasTestBase.java (original)
+++ felix/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/JaasTestBase.java Thu
Mar 21 11:20:01 2013
@@ -37,7 +37,6 @@ import org.ops4j.pax.exam.OptionUtils;
 import org.ops4j.pax.exam.ProbeBuilder;
 import org.ops4j.pax.exam.TestProbeBuilder;
 import org.ops4j.pax.exam.options.DefaultCompositeOption;
-import org.ops4j.pax.exam.util.PathUtils;
 import org.ops4j.pax.tinybundles.core.TinyBundles;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -66,6 +65,7 @@ public abstract class JaasTestBase
     protected static final String BUNDLE_JAR_DEFAULT = "target/jaas.jar";
 
     // the JVM option to set to enable remote debugging
+    @SuppressWarnings("UnusedDeclaration")
     protected static final String DEBUG_VM_OPTION = "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=31313";
 
     // the actual JVM option set, extensions may implement a static
@@ -76,7 +76,6 @@ public abstract class JaasTestBase
     @Configuration
     public Option[] config()
     {
-        String baseDir = PathUtils.getBaseDir();
         final String bundleFileName = System.getProperty(BUNDLE_JAR_SYS_PROP,
             BUNDLE_JAR_DEFAULT);
         final File bundleFile = new File(bundleFileName);
@@ -130,13 +129,6 @@ public abstract class JaasTestBase
                 .build(withBnd());
     }
 
-    protected String createConfigSpiConfig() throws IOException {
-        org.osgi.service.cm.Configuration config = ca.getConfiguration("org.apache.felix.jaas.ConfigurationSpi",null);
-        Properties p = new Properties();
-        config.update(p);
-        return config.getPid();
-    }
-
     protected Option addExtraOptions()
     {
         return new DefaultCompositeOption();



Mime
View raw message