mcconnell 2004/03/01 08:31:42
Modified: merlin/activation/impl/src/test/org/apache/avalon/activation/impl/test
AbstractTestCase.java
CodeSecurityEnabledTestCase.java
merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
DefaultContainmentModel.java
DefaultSystemContext.java
DefaultSystemContextFactory.java
merlin/composition/impl/src/test/org/apache/avalon/composition/model/test
AbstractTestCase.java
merlin/composition/spi/src/java/org/apache/avalon/composition/provider
SystemContextFactory.java
merlin/kernel/api/src/java/org/apache/avalon/merlin
KernelCriteria.java
merlin/kernel/impl maven.xml project.properties
merlin/kernel/impl/conf merlin.template
merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl
DefaultCriteria.java DefaultFactory.java
Log:
Fix code security testcase error - propery based constraints/permissions are not
working as expected.
Revision Changes Path
1.6 +9 -5
avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/impl/test/AbstractTestCase.java
Index: AbstractTestCase.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/impl/test/AbstractTestCase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractTestCase.java 29 Feb 2004 22:25:25 -0000 1.5
+++ AbstractTestCase.java 1 Mar 2004 16:31:41 -0000 1.6
@@ -68,7 +68,6 @@
private static final XMLSecurityProfileBuilder SECURITY_BUILDER =
new XMLSecurityProfileBuilder();
-
//-------------------------------------------------------
// state
//-------------------------------------------------------
@@ -155,8 +154,9 @@
if( m_secured )
{
SecurityProfile[] profiles =
- SECURITY_BUILDER.createSecurityProfiles( config );
+ SECURITY_BUILDER.createSecurityProfiles( secConfig );
factory.setSecurityProfiles( profiles );
+ factory.setSecurityEnabled( true );
}
Repository repository =
@@ -165,6 +165,7 @@
factory.setRuntime( DefaultRuntime.class );
m_system = factory.createSystemContext();
+
m_logger = m_system.getLogger();
//
@@ -176,7 +177,8 @@
m_model = m_system.getModelFactory().createRootContainmentModel( profile );
}
- InitialContext setUpInitialContext( File base, Configuration config ) throws
Exception
+ InitialContext setUpInitialContext(
+ File base, Configuration config ) throws Exception
{
InitialContextFactory initial =
new DefaultInitialContextFactory( "test", base );
@@ -185,7 +187,8 @@
return initial.createInitialContext();
}
- private Repository createTestRepository( InitialContext context, File cache )
throws Exception
+ private Repository createTestRepository(
+ InitialContext context, File cache ) throws Exception
{
Factory factory = context.getInitialFactory();
RepositoryCriteria criteria =
@@ -195,7 +198,8 @@
return (Repository) factory.create( criteria );
}
- private void registerSystemArtifacts( InitialContextFactory factory,
Configuration config )
+ private void registerSystemArtifacts(
+ InitialContextFactory factory, Configuration config )
throws Exception
{
Artifact[] artifacts = getArtifactsToRegister( config );
1.4 +2 -12
avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/impl/test/CodeSecurityEnabledTestCase.java
Index: CodeSecurityEnabledTestCase.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/impl/test/CodeSecurityEnabledTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CodeSecurityEnabledTestCase.java 29 Feb 2004 22:25:25 -0000 1.3
+++ CodeSecurityEnabledTestCase.java 1 Mar 2004 16:31:41 -0000 1.4
@@ -88,11 +88,10 @@
*/
public void testInterfaceMethods() throws Exception
{
- System.out.println( "## testing interface methods" );
TestService test = getTestService();
try
{
- test.createDirectory();
+ test.createDirectory();
// TODO::::
// fail( "CodeSecurityTest primary failure: This operation should not be
allowed." );
@@ -128,8 +127,6 @@
getLogger().error( message );
throw new Exception( message );
}
-
- System.out.println( "## testing property read" );
try
{
@@ -137,11 +134,9 @@
// system properties in the security policy.
String ver = test.getJavaVersion();
- System.out.println( "## property read ok" );
}
catch( Throwable e )
{
- System.out.println( "## property read failed: " + e.toString() );
releaseTestService( test );
final String error = "CodeSecurityTest secondary failure.";
final String message = ExceptionHelper.packException( error, e, true );
@@ -149,17 +144,13 @@
throw new Exception( message );
}
- System.out.println( "## testing setProperty" );
try
{
test.setJavaVersion( "1.0.2" );
-// TODO::::
-// fail( "CodeSecurityTest failure: This operation should not be
allowed." );
- System.out.println( "## set version succeeded - BAD " );
+ fail( "CodeSecurityTest failure: This operation should not be allowed."
);
}
catch( SecurityException e )
{
- System.out.println( "## set version failed - GOOD" );
// ignore, expected
}
catch( Throwable e )
@@ -172,6 +163,5 @@
}
releaseTestService( test );
-
}
}
1.38 +2 -4
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
Index: DefaultContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- DefaultContainmentModel.java 29 Feb 2004 22:25:26 -0000 1.37
+++ DefaultContainmentModel.java 1 Mar 2004 16:31:41 -0000 1.38
@@ -141,8 +141,6 @@
private final DefaultState m_assembly = new DefaultState();
- private final Map m_models = new Hashtable();
-
private final ContainmentContext m_context;
private final String m_partition;
@@ -722,7 +720,7 @@
}
else
{
- m_context.getDependencyGraph().add( model );
+ m_context.getDependencyGraph().remove( model );
repository.removeModel( model );
CompositionEvent event = new CompositionEvent( this, model );
fireModelRemovedEvent( event );
1.24 +5 -82
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContext.java
Index: DefaultSystemContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContext.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- DefaultSystemContext.java 29 Feb 2004 22:25:26 -0000 1.23
+++ DefaultSystemContext.java 1 Mar 2004 16:31:41 -0000 1.24
@@ -110,81 +110,6 @@
/**
* Creation of a new system context.
*
- * @param context a repository initial context
- * @param artifact an artifact identifying the default runtime
- * @param logging the logging manager
- * @param base the base directory from which relative references
- * within a classpath or library directive shall be resolved
- * @param home the home directory
- * @param temp the temp directory
- * @param repository the application repository to be used when resolving
- * resource directives
- * @param category the kernel logging category name
- * @param trace flag indicating if internal logging is enabled
- * @param timeout a system wide default deployment timeout
- * @param security the security profiles
- */
- /*
- public DefaultSystemContext(
- InitialContext context,
- Artifact artifact,
- LoggingManager logging,
- File base,
- File home,
- File temp,
- Repository repository,
- String category,
- boolean trace,
- long timeout,
- SecurityProfile[] security,
- TargetDirective[] targets ) throws SystemException
- {
- this(
- context, artifact, null, logging, base, home, temp,
- repository, category, trace, timeout, security,
- targets );
- }
- */
-
- /**
- * Creation of a new system context.
- *
- * @param clazz the runtime class
- * @param logging the logging manager
- * @param base the base directory from which relative references
- * within a classpath or library directive shall be resolved
- * @param home the home directory
- * @param temp the temp directory
- * @param repository the application repository to be used when resolving
- * resource directives
- * @param category the kernel logging category name
- * @param trace flag indicating if internal logging is enabled
- * @param timeout a system wide default deployment timeout
- * @param security the security profiles
- */
- /*
- public DefaultSystemContext(
- Class clazz,
- LoggingManager logging,
- File base,
- File home,
- File temp,
- Repository repository,
- String category,
- boolean trace,
- long timeout,
- SecurityProfile[] security,
- TargetDirective[] targets ) throws SystemException
- {
- this(
- null, null, clazz, logging, base, home, temp, repository, category,
- trace, timeout, security, targets );
- }
- */
-
- /**
- * Creation of a new system context.
- *
* @param context the repository intial context
* @param artifact the runtime artifact
* @param runtime the runtime class
@@ -213,6 +138,7 @@
String category,
boolean trace,
long timeout,
+ boolean secure,
SecurityProfile[] security,
TargetDirective[] targets ) throws SystemException
{
@@ -248,17 +174,14 @@
m_system = SystemContext.class.getClassLoader();
m_common = DeploymentModel.class.getClassLoader();
- if( security.length > 0 )
+ m_secure = secure;
+
+ if( m_secure )
{
- m_secure = true;
if( System.getSecurityManager() == null )
{
System.setSecurityManager( new SecurityManager() );
}
- }
- else
- {
- m_secure = false;
}
m_factory = new DefaultModelFactory( this, security, targets );
1.3 +14 -1
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContextFactory.java
Index: DefaultSystemContextFactory.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContextFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultSystemContextFactory.java 29 Feb 2004 22:25:26 -0000 1.2
+++ DefaultSystemContextFactory.java 1 Mar 2004 16:31:41 -0000 1.3
@@ -110,6 +110,8 @@
private Context m_parent;
+ private boolean m_secure = false;
+
//--------------------------------------------------------------
// constructor
//--------------------------------------------------------------
@@ -128,6 +130,11 @@
// SystemContextFactory
//--------------------------------------------------------------
+ public void setSecurityEnabled( boolean secure )
+ {
+ m_secure = secure;
+ }
+
public void setParentContext( Context parent )
{
m_parent = parent;
@@ -224,9 +231,15 @@
getName(),
isTraceEnabled(),
getDefaultDeploymentTimeout(),
+ getSecurityEnabled(),
getSecurityProfiles(),
getTargetDirectives()
);
+ }
+
+ public boolean getSecurityEnabled()
+ {
+ return m_secure;
}
public Context getParentContext()
1.6 +1 -0
avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/test/AbstractTestCase.java
Index: AbstractTestCase.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/test/AbstractTestCase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractTestCase.java 29 Feb 2004 22:25:26 -0000 1.5
+++ AbstractTestCase.java 1 Mar 2004 16:31:41 -0000 1.6
@@ -113,6 +113,7 @@
SecurityProfile[] profiles =
SECURITY_BUILDER.createSecurityProfiles( secConfig );
factory.setSecurityProfiles( profiles );
+ factory.setSecurityEnabled( true );
Repository repository =
createTestRepository( context, new File( test, "repository" ) );
1.3 +7 -1
avalon/merlin/composition/spi/src/java/org/apache/avalon/composition/provider/SystemContextFactory.java
Index: SystemContextFactory.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/spi/src/java/org/apache/avalon/composition/provider/SystemContextFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SystemContextFactory.java 29 Feb 2004 22:25:26 -0000 1.2
+++ SystemContextFactory.java 1 Mar 2004 16:31:41 -0000 1.3
@@ -39,6 +39,12 @@
public interface SystemContextFactory
{
/**
+ * Set the security enabled status.
+ * @param secure the security enabled flag
+ */
+ void setSecurityEnabled( boolean secure );
+
+ /**
* Set the parent context.
* @param context a parent context instance
*/
1.10 +3 -22
avalon/merlin/kernel/api/src/java/org/apache/avalon/merlin/KernelCriteria.java
Index: KernelCriteria.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/kernel/api/src/java/org/apache/avalon/merlin/KernelCriteria.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- KernelCriteria.java 1 Mar 2004 13:40:20 -0000 1.9
+++ KernelCriteria.java 1 Mar 2004 16:31:41 -0000 1.10
@@ -85,16 +85,10 @@
"merlin.logging.implementation";
/**
- * The default merlin runtime for non-secure execution.
+ * The default merlin runtime artifact spec.
*/
String MERLIN_RUNTIME_IMPLEMENTATION =
- "merlin.runtime.standard.implementation";
-
- /**
- * The default secure runtime.
- */
- String MERLIN_CS_RUNTIME_IMPLEMENTATION =
- "merlin.runtime.csi.implementation";
+ "merlin.runtime.implementation";
/**
* The preferred runtime.
@@ -241,19 +235,6 @@
* @return the runtime implementation artifact
*/
Artifact getRuntimeImplementation();
-
- /**
- * Return the standard non-secure runtime implementation artifact.
- * @return the runtime implementation artifact
- */
- Artifact getStandardRuntimeImplementation();
-
- /**
- * Return the code secure runtime implementation artifact.
- * @return the runtime implementation artifact
- */
- Artifact getSecureRuntimeImplementation();
-
/**
* Return the url to the configuration override targets.
1.9 +3 -27 avalon/merlin/kernel/impl/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/avalon/merlin/kernel/impl/maven.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- maven.xml 20 Feb 2004 22:49:56 -0000 1.8
+++ maven.xml 1 Mar 2004 16:31:42 -0000 1.9
@@ -3,7 +3,8 @@
<postGoal name="java:prepare-filesystem">
<attainGoal name="avalon:artifact"/>
<ant:copy toDir="${maven.repo.local}/${pom.groupId}/jars"
- file="${maven.build.dir}/${pom.artifactId}-${pom.currentVersion}.jar.meta"
verbose="yes"/>
+ file="${maven.build.dir}/${pom.artifactId}-${pom.currentVersion}.jar.meta"
+ verbose="yes"/>
</postGoal>
<!--
@@ -27,35 +28,10 @@
<filter token="LOGGING_IMPLEMENTATION"
value="${merlin.logging.implementation}"/>
<filter token="STANDARD_RUNTIME"
- value="${merlin.runtime.standard.implementation}"/>
- <filter token="SECURE_RUNTIME"
- value="${merlin.runtime.csi.implementation}"/>
+ value="${merlin.runtime.implementation}"/>
</filterset>
</ant:copy>
- <!--
- <ant:echo file="${maven.build.dir}/classes/merlin.properties">
-#
-# merlin system implementation
-merlin.implementation = ${pom.groupId}:${pom.artifactId};${pom.currentVersion}
-
-#
-# logging implementation
-merlin.logging.implementation = ${merlin.logging.implementation}
-
-#
-# runtime implementation
-merlin.runtime.standard.implementation = ${merlin.runtime.standard.implementation}
-
-#
-# runtime code secure implementation
-merlin.runtime.csi.implementation = ${merlin.runtime.csi.implementation}
-
-#
-# EOF
-#
-</ant:echo>
- -->
<ant:mkdir dir="${maven.repo.local}/${pom.groupId}/properties"/>
<ant:copy toDir="${maven.repo.local}/${pom.groupId}/properties"
file="${maven.build.dir}/classes/merlin.properties" verbose="yes"/>
1.7 +1 -2 avalon/merlin/kernel/impl/project.properties
Index: project.properties
===================================================================
RCS file: /home/cvs/avalon/merlin/kernel/impl/project.properties,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- project.properties 20 Feb 2004 22:49:56 -0000 1.6
+++ project.properties 1 Mar 2004 16:31:42 -0000 1.7
@@ -9,5 +9,4 @@
#
merlin.logging.implementation =
artifact:avalon-logging/avalon-logkit-impl#1.0-SNAPSHOT
-merlin.runtime.standard.implementation =
artifact:avalon-activation/avalon-activation-impl#2.0-SNAPSHOT
-merlin.runtime.csi.implementation =
artifact:avalon-activation/avalon-activation-csi#2.0-SNAPSHOT
+merlin.runtime.implementation =
artifact:avalon-activation/avalon-activation-impl#2.0-SNAPSHOT
1.3 +1 -5 avalon/merlin/kernel/impl/conf/merlin.template
Index: merlin.template
===================================================================
RCS file: /home/cvs/avalon/merlin/kernel/impl/conf/merlin.template,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- merlin.template 21 Feb 2004 23:54:42 -0000 1.2
+++ merlin.template 1 Mar 2004 16:31:42 -0000 1.3
@@ -18,11 +18,7 @@
#
# runtime implementation
-merlin.runtime.standard.implementation = @STANDARD_RUNTIME@
-
-#
-# runtime code secure implementation
-merlin.runtime.csi.implementation = @SECURE_RUNTIME@
+merlin.runtime.implementation = @STANDARD_RUNTIME@
#
# server mode
1.27 +8 -28
avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultCriteria.java
Index: DefaultCriteria.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultCriteria.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- DefaultCriteria.java 1 Mar 2004 13:40:20 -0000 1.26
+++ DefaultCriteria.java 1 Mar 2004 16:31:42 -0000 1.27
@@ -171,12 +171,6 @@
MERLIN_RUNTIME,
String.class, null ),
new Parameter(
- MERLIN_RUNTIME_IMPLEMENTATION,
- String.class, null ),
- new Parameter(
- MERLIN_CS_RUNTIME_IMPLEMENTATION,
- String.class, null ),
- new Parameter(
MERLIN_OVERRIDE, String.class, null ),
new Parameter(
MERLIN_DIR, File.class, context.getInitialWorkingDirectory() ),
@@ -233,13 +227,15 @@
final File work = context.getInitialWorkingDirectory();
DefaultsBuilder builder = new DefaultsBuilder( key, work );
Properties defaults =
- Defaults.getStaticProperties( DefaultCriteria.class,
"/merlin.properties" );
+ Defaults.getStaticProperties(
+ DefaultCriteria.class, "/merlin.properties" );
//
// set the ${merlin.dir} value
//
- defaults.setProperty( "merlin.dir", getWorkingDirectory().toString() );
+ defaults.setProperty(
+ "merlin.dir", getWorkingDirectory().toString() );
//
// get the consolidated properties
@@ -263,7 +259,8 @@
for( int i=0; i<keys.length; i++ )
{
final String propertyKey = keys[i];
- final String value = properties.getProperty( propertyKey );
+ final String value =
+ properties.getProperty( propertyKey );
if( null != value )
{
put( propertyKey, value );
@@ -453,14 +450,7 @@
}
else
{
- if( isCodeSecurityEnabled() )
- {
- return getSecureRuntimeImplementation();
- }
- else
- {
- return getStandardRuntimeImplementation();
- }
+ return getStandardRuntimeImplementation();
}
}
@@ -471,16 +461,6 @@
public Artifact getStandardRuntimeImplementation()
{
String value = (String) get( MERLIN_RUNTIME_IMPLEMENTATION );
- return Artifact.createArtifact( value );
- }
-
- /**
- * Return the artifact reference to the secure runtime implementation factory .
- * @return the secure runtime implementation factory artifact
- */
- public Artifact getSecureRuntimeImplementation()
- {
- String value = (String) get( MERLIN_CS_RUNTIME_IMPLEMENTATION );
return Artifact.createArtifact( value );
}
1.36 +7 -3
avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java
Index: DefaultFactory.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- DefaultFactory.java 1 Mar 2004 13:40:21 -0000 1.35
+++ DefaultFactory.java 1 Mar 2004 16:31:42 -0000 1.36
@@ -411,9 +411,13 @@
//
Configuration secConfig = config.getChild( "security" );
- SecurityProfile[] profiles =
- SECURITY_CREATOR.createSecurityProfiles( secConfig );
- factory.setSecurityProfiles( profiles );
+ if( context.isCodeSecurityEnabled() )
+ {
+ SecurityProfile[] profiles =
+ SECURITY_CREATOR.createSecurityProfiles( secConfig );
+ factory.setSecurityProfiles( profiles );
+ }
+ factory.
//
// create the application repository
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]