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