fe97c5
diff --git a/src/org/apache/xalan/processor/TransformerFactoryImpl.java b/src/org/apache/xalan/processor/TransformerFactoryImpl.java
fe97c5
index 1298943..96a5e58 100644
fe97c5
--- a/src/org/apache/xalan/processor/TransformerFactoryImpl.java
fe97c5
+++ b/src/org/apache/xalan/processor/TransformerFactoryImpl.java
fe97c5
@@ -335,6 +335,10 @@ public class TransformerFactoryImpl extends SAXTransformerFactory
fe97c5
           reader = XMLReaderFactory.createXMLReader();
fe97c5
         }
fe97c5
 
fe97c5
+        if(m_isSecureProcessing)
fe97c5
+        {
fe97c5
+            reader.setFeature("http://xml.org/sax/features/external-general-entities",false);
fe97c5
+        }
fe97c5
         // Need to set options!
fe97c5
         reader.setContentHandler(handler);
fe97c5
         reader.parse(isource);
fe97c5
diff --git a/src/org/apache/xalan/processor/XSLTElementProcessor.java b/src/org/apache/xalan/processor/XSLTElementProcessor.java
fe97c5
index b946743..17b7395 100644
fe97c5
--- a/src/org/apache/xalan/processor/XSLTElementProcessor.java
fe97c5
+++ b/src/org/apache/xalan/processor/XSLTElementProcessor.java
fe97c5
@@ -338,17 +338,31 @@ public class XSLTElementProcessor extends ElemTemplateElement
fe97c5
       }
fe97c5
       else
fe97c5
       {
fe97c5
-        // Can we switch the order here:
fe97c5
-
fe97c5
-        boolean success = attrDef.setAttrValue(handler, attrUri, attrLocalName,
fe97c5
-                             attributes.getQName(i), attributes.getValue(i),
fe97c5
-                             target);
fe97c5
-                             
fe97c5
-        // Now we only add the element if it passed a validation check
fe97c5
-        if (success)
fe97c5
-            processedDefs.add(attrDef);
fe97c5
-        else
fe97c5
-            errorDefs.add(attrDef);
fe97c5
+        //handle secure processing
fe97c5
+        if(handler.getStylesheetProcessor()==null)
fe97c5
+            System.out.println("stylesheet processor null");
fe97c5
+        if(attrDef.getName().compareTo("*")==0 && handler.getStylesheetProcessor().isSecureProcessing())
fe97c5
+        {
fe97c5
+            //foreign attributes are not allowed in secure processing mode
fe97c5
+            // Then barf, because this element does not allow this attribute.
fe97c5
+            handler.error(XSLTErrorResources.ER_ATTR_NOT_ALLOWED, new Object[]{attributes.getQName(i), rawName}, null);//"\""+attributes.getQName(i)+"\""
fe97c5
+            //+ " attribute is not allowed on the " + rawName
fe97c5
+            // + " element!", null);
fe97c5
+        }
fe97c5
+        else
fe97c5
+        {
fe97c5
+
fe97c5
+
fe97c5
+            boolean success = attrDef.setAttrValue(handler, attrUri, attrLocalName,
fe97c5
+                                 attributes.getQName(i), attributes.getValue(i),
fe97c5
+                                 target);
fe97c5
+
fe97c5
+            // Now we only add the element if it passed a validation check
fe97c5
+            if (success)
fe97c5
+                processedDefs.add(attrDef);
fe97c5
+            else
fe97c5
+                errorDefs.add(attrDef);
fe97c5
+        }
fe97c5
       }
fe97c5
     }
fe97c5
 
fe97c5
diff --git a/src/org/apache/xalan/transformer/TransformerImpl.java b/src/org/apache/xalan/transformer/TransformerImpl.java
fe97c5
index dd0d4d9..0906d24 100644
fe97c5
--- a/src/org/apache/xalan/transformer/TransformerImpl.java
fe97c5
+++ b/src/org/apache/xalan/transformer/TransformerImpl.java
fe97c5
@@ -438,7 +438,9 @@ public class TransformerImpl extends Transformer
fe97c5
     try
fe97c5
     {
fe97c5
       if (sroot.getExtensions() != null)
fe97c5
-        m_extensionsTable = new ExtensionsTable(sroot);
fe97c5
+        //only load extensions if secureProcessing is disabled
fe97c5
+        if(!sroot.isSecureProcessing())
fe97c5
+            m_extensionsTable = new ExtensionsTable(sroot);
fe97c5
     }
fe97c5
     catch (javax.xml.transform.TransformerException te)
fe97c5
     {te.printStackTrace();}
fe97c5
diff --git a/src/org/apache/xpath/functions/FuncSystemProperty.java b/src/org/apache/xpath/functions/FuncSystemProperty.java
fe97c5
index 4bea356..78ac980 100644
fe97c5
--- a/src/org/apache/xpath/functions/FuncSystemProperty.java
fe97c5
+++ b/src/org/apache/xpath/functions/FuncSystemProperty.java
fe97c5
@@ -58,7 +58,7 @@ public class FuncSystemProperty extends FunctionOneArg
fe97c5
 
fe97c5
     String fullName = m_arg0.execute(xctxt).str();
fe97c5
     int indexOfNSSep = fullName.indexOf(':');
fe97c5
-    String result;
fe97c5
+    String result = null;
fe97c5
     String propName = "";
fe97c5
 
fe97c5
     // List of properties where the name of the
fe97c5
@@ -98,14 +98,20 @@ public class FuncSystemProperty extends FunctionOneArg
fe97c5
 
fe97c5
         try
fe97c5
         {
fe97c5
-          result = System.getProperty(propName);
fe97c5
-
fe97c5
-          if (null == result)
fe97c5
-          {
fe97c5
-
fe97c5
-            // result = System.getenv(propName);
fe97c5
-            return XString.EMPTYSTRING;
fe97c5
-          }
fe97c5
+            //if secure procession is enabled only handle required properties do not not map any valid system property
fe97c5
+            if(!xctxt.isSecureProcessing())
fe97c5
+            {
fe97c5
+                result = System.getProperty(propName);
fe97c5
+            }
fe97c5
+            else
fe97c5
+            {
fe97c5
+                warn(xctxt, XPATHErrorResources.WG_SECURITY_EXCEPTION,
fe97c5
+                        new Object[]{ fullName });  //"SecurityException when trying to access XSL system property: "+fullName);
fe97c5
+            }
fe97c5
+            if (null == result)
fe97c5
+            {
fe97c5
+                return XString.EMPTYSTRING;
fe97c5
+            }
fe97c5
         }
fe97c5
         catch (SecurityException se)
fe97c5
         {
fe97c5
@@ -120,14 +126,20 @@ public class FuncSystemProperty extends FunctionOneArg
fe97c5
     {
fe97c5
       try
fe97c5
       {
fe97c5
-        result = System.getProperty(fullName);
fe97c5
-
fe97c5
-        if (null == result)
fe97c5
-        {
fe97c5
-
fe97c5
-          // result = System.getenv(fullName);
fe97c5
-          return XString.EMPTYSTRING;
fe97c5
-        }
fe97c5
+          //if secure procession is enabled only handle required properties do not not map any valid system property
fe97c5
+          if(!xctxt.isSecureProcessing())
fe97c5
+          {
fe97c5
+              result = System.getProperty(fullName);
fe97c5
+          }
fe97c5
+          else
fe97c5
+          {
fe97c5
+              warn(xctxt, XPATHErrorResources.WG_SECURITY_EXCEPTION,
fe97c5
+                      new Object[]{ fullName });  //"SecurityException when trying to access XSL system property: "+fullName);
fe97c5
+          }
fe97c5
+          if (null == result)
fe97c5
+          {
fe97c5
+              return XString.EMPTYSTRING;
fe97c5
+          }
fe97c5
       }
fe97c5
       catch (SecurityException se)
fe97c5
       {