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