[java-identity-provider] branch master updated: JPAR-128 - Upgrade Velocity to 2.0

Scott Cantor cantor.2 at osu.edu
Wed Jan 23 12:17:39 EST 2019


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=2ae72e60bbcdc49758e0f182c41f955e45879c7e

The following commit(s) were added to refs/heads/master by this push:
       new  2ae72e6   JPAR-128 - Upgrade Velocity to 2.0
2ae72e6 is described below

commit 2ae72e60bbcdc49758e0f182c41f955e45879c7e
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jan 23 12:17:35 2019 -0500

    JPAR-128 - Upgrade Velocity to 2.0
    
    https://issues.shibboleth.net/jira/browse/JPAR-128
---
 idp-attribute-resolver-impl/pom.xml                            |  2 +-
 .../dc/ldap/impl/TemplatedExecutableSearchFilterBuilder.java   |  3 ++-
 .../dc/rdbms/impl/FormatExecutableStatementBuilder.java        | 10 ++++++----
 .../dc/rdbms/impl/TemplatedExecutableStatementBuilder.java     |  8 ++++----
 idp-authn-api/pom.xml                                          |  2 +-
 .../shibboleth/idp/authn/AbstractTemplateSearchDnResolver.java |  3 ++-
 idp-authn-impl/pom.xml                                         |  4 ----
 idp-conf/src/main/resources/system/conf/global-system.xml      |  3 +--
 idp-conf/src/main/resources/system/conf/mvc-beans.xml          |  6 ------
 9 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/idp-attribute-resolver-impl/pom.xml b/idp-attribute-resolver-impl/pom.xml
index d51cb5a..0c89e24 100644
--- a/idp-attribute-resolver-impl/pom.xml
+++ b/idp-attribute-resolver-impl/pom.xml
@@ -40,7 +40,7 @@
 
 		<dependency>
 			<groupId>org.apache.velocity</groupId>
-			<artifactId>velocity</artifactId>
+			<artifactId>velocity-engine-core</artifactId>
 		</dependency>
 		<dependency>
 			<groupId>commons-codec</groupId>
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/ldap/impl/TemplatedExecutableSearchFilterBuilder.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/ldap/impl/TemplatedExecutableSearchFilterBuilder.java
index 8ba8d61..fefeef4 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/ldap/impl/TemplatedExecutableSearchFilterBuilder.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/ldap/impl/TemplatedExecutableSearchFilterBuilder.java
@@ -38,6 +38,7 @@ import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.app.event.EventCartridge;
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+import org.apache.velocity.context.Context;
 import org.apache.velocity.exception.VelocityException;
 import org.ldaptive.SearchFilter;
 import org.slf4j.Logger;
@@ -233,7 +234,7 @@ public class TemplatedExecutableSearchFilterBuilder extends AbstractExecutableSe
     /** Escapes LDAP attribute values added to the template context. */
     protected static class EscapingReferenceInsertionEventHandler implements ReferenceInsertionEventHandler {
 
-        @Override public Object referenceInsert(final String reference, final Object value) {
+        @Override public Object referenceInsert(final Context context, final String reference, final Object value) {
             if (value == null) {
                 return null;
             } else if (value instanceof Object[]) {
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/FormatExecutableStatementBuilder.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/FormatExecutableStatementBuilder.java
index ed45389..bdb2c17 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/FormatExecutableStatementBuilder.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/FormatExecutableStatementBuilder.java
@@ -30,8 +30,6 @@ import net.shibboleth.utilities.java.support.logic.Constraint;
 import net.shibboleth.utilities.java.support.primitive.DeprecationSupport;
 import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
 
-import org.apache.commons.lang.StringEscapeUtils;
-
 /**
  * An {@link net.shibboleth.idp.attribute.resolver.dc.impl.ExecutableSearchBuilder}. It generates the SQL statement to
  * be executed by invoking {@link String#format(String, Object...)} with
@@ -109,14 +107,18 @@ public class FormatExecutableStatementBuilder extends AbstractExecutableStatemen
             for (final Map.Entry<String, List<IdPAttributeValue<?>>> entry : dependencyAttributes.entrySet()) {
                 for (final IdPAttributeValue<?> value : entry.getValue()) {
                     if (value.getValue() instanceof String){ 
-                        args.add(StringEscapeUtils.escapeSql((String) value.getValue()));
+                        args.add(((String) value.getValue()).replace("'", "''"));
                     } else {
                         args.add(value.getValue());
                     }
                 }
             }
         } else {
-            args.add(StringEscapeUtils.escapeSql(resolutionContext.getPrincipal()));
+            if (resolutionContext.getPrincipal() != null) {
+                args.add(resolutionContext.getPrincipal().replace("'", "''"));
+            } else {
+                args.add(null);
+            }
         }
         return String.format(sqlQuery, args.toArray());
     }
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/TemplatedExecutableStatementBuilder.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/TemplatedExecutableStatementBuilder.java
index f5eb571..8d56377 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/TemplatedExecutableStatementBuilder.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/TemplatedExecutableStatementBuilder.java
@@ -34,11 +34,11 @@ import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.primitive.StringSupport;
 import net.shibboleth.utilities.java.support.velocity.Template;
 
-import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.app.event.EventCartridge;
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+import org.apache.velocity.context.Context;
 import org.apache.velocity.exception.VelocityException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -232,7 +232,7 @@ public class TemplatedExecutableStatementBuilder extends AbstractExecutableState
     protected static class EscapingReferenceInsertionEventHandler implements ReferenceInsertionEventHandler {
 
         @Override
-        public Object referenceInsert(final String reference, final Object value) {
+        public Object referenceInsert(final Context context, final String reference, final Object value) {
             if (value == null) {
                 return null;
             } else if (value instanceof Object[]) {
@@ -253,7 +253,7 @@ public class TemplatedExecutableStatementBuilder extends AbstractExecutableState
         }
         
         /**
-         * Returns {@link StringEscapeUtils#escapeSql(String)} if value is a string.
+         * Replaces single quotes with two single quotes if value is a {@link String}.
          * 
          * @param value to encode
          *
@@ -261,7 +261,7 @@ public class TemplatedExecutableStatementBuilder extends AbstractExecutableState
          */
         private Object encode(final Object value) {
             if (value instanceof String){ 
-                return StringEscapeUtils.escapeSql((String) value);
+                return ((String) value).replace("'", "''");
             }
             return value;
         }
diff --git a/idp-authn-api/pom.xml b/idp-authn-api/pom.xml
index 7df765a..871a97e 100644
--- a/idp-authn-api/pom.xml
+++ b/idp-authn-api/pom.xml
@@ -46,7 +46,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.velocity</groupId>
-            <artifactId>velocity</artifactId>
+            <artifactId>velocity-engine-core</artifactId>
         </dependency>
 
         <dependency>
diff --git a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractTemplateSearchDnResolver.java b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractTemplateSearchDnResolver.java
index 5b5a54f..7c99cc1 100644
--- a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractTemplateSearchDnResolver.java
+++ b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractTemplateSearchDnResolver.java
@@ -27,6 +27,7 @@ import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.app.event.EventCartridge;
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+import org.apache.velocity.context.Context;
 import org.apache.velocity.exception.VelocityException;
 import org.ldaptive.SearchFilter;
 import org.ldaptive.auth.AbstractSearchDnResolver;
@@ -94,7 +95,7 @@ public abstract class AbstractTemplateSearchDnResolver extends AbstractSearchDnR
     /** Escapes LDAP attribute values added to the template context. */
     protected static class EscapingReferenceInsertionEventHandler implements ReferenceInsertionEventHandler {
 
-        @Override public Object referenceInsert(final String reference, final Object value) {
+        @Override public Object referenceInsert(final Context context, final String reference, final Object value) {
             if (value == null) {
                 return null;
             } else if (value instanceof Object[]) {
diff --git a/idp-authn-impl/pom.xml b/idp-authn-impl/pom.xml
index 23273f7..dda28ce 100644
--- a/idp-authn-impl/pom.xml
+++ b/idp-authn-impl/pom.xml
@@ -86,10 +86,6 @@
             <artifactId>spring-webflow</artifactId>
         </dependency>
         <dependency>
-          <groupId>org.apache.velocity</groupId>
-          <artifactId>velocity</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.ldaptive</groupId>
             <artifactId>ldaptive</artifactId>
         </dependency>
diff --git a/idp-conf/src/main/resources/system/conf/global-system.xml b/idp-conf/src/main/resources/system/conf/global-system.xml
index c27b039..f6e1ecb 100644
--- a/idp-conf/src/main/resources/system/conf/global-system.xml
+++ b/idp-conf/src/main/resources/system/conf/global-system.xml
@@ -97,8 +97,7 @@
             depends-on="shibboleth.LoggingService">
         <property name="velocityProperties">
             <props>
-                <prop key="input.encoding">UTF-8</prop>
-                <prop key="output.encoding">UTF-8</prop>
+                <prop key="space.gobbling">%{idp.velocity.space.gobbling:bc}</prop>
                 <prop key="resource.loader">file, classpath, string</prop>
                 <prop key="classpath.resource.loader.class">
                     org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
diff --git a/idp-conf/src/main/resources/system/conf/mvc-beans.xml b/idp-conf/src/main/resources/system/conf/mvc-beans.xml
index a67a3b2..036de12 100644
--- a/idp-conf/src/main/resources/system/conf/mvc-beans.xml
+++ b/idp-conf/src/main/resources/system/conf/mvc-beans.xml
@@ -102,12 +102,6 @@
 
     <bean class="net.shibboleth.ext.spring.velocity.VelocityConfigurer">
         <property name="resourceLoaderPath" value="#{'%{idp.views:%{idp.home}/views}'.trim()},%{idp.home}/system/views" />
-        <property name="velocityProperties">
-            <props>
-                <prop key="input.encoding">UTF-8</prop>
-                <prop key="output.encoding">UTF-8</prop>
-            </props>
-        </property>
     </bean>
     
     <!-- Import any user defined beans or overrides for the MVC config. -->

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list