Repository: cxf-fediz
Updated Branches:
  refs/heads/master 731b9e8b6 -> 1f42f03a4


Allow to specify an additional TLD for the CommonsURLValidator in the IdP


Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/1f42f03a
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/1f42f03a
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/1f42f03a

Branch: refs/heads/master
Commit: 1f42f03a41915866d481ecc7fcefab9900f1b8a0
Parents: 731b9e8
Author: Colm O hEigeartaigh <cohei...@apache.org>
Authored: Tue Apr 11 17:09:03 2017 +0100
Committer: Colm O hEigeartaigh <cohei...@apache.org>
Committed: Tue Apr 11 17:09:03 2017 +0100

----------------------------------------------------------------------
 .../service/idp/beans/CommonsURLValidator.java   | 19 +++++++++++++++++--
 .../src/main/webapp/WEB-INF/security-config.xml  |  3 +++
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/1f42f03a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/CommonsURLValidator.java
----------------------------------------------------------------------
diff --git 
a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/CommonsURLValidator.java
 
b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/CommonsURLValidator.java
index fa40a55..f1f245b 100644
--- 
a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/CommonsURLValidator.java
+++ 
b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/CommonsURLValidator.java
@@ -18,16 +18,19 @@
  */
 package org.apache.cxf.fediz.service.idp.beans;
 
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.validator.routines.DomainValidator;
 import org.apache.commons.validator.routines.UrlValidator;
+import org.apache.commons.validator.routines.DomainValidator.ArrayType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
 import org.springframework.webflow.execution.RequestContext;
 
 /**
  * Validate a URL using Commons Validator
  */
-@Component
 public class CommonsURLValidator {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(CommonsURLValidator.class);
@@ -49,4 +52,16 @@ public class CommonsURLValidator {
         return true;
     }
 
+    public void setAdditionalTLDs(List<String> additionalTLDs) {
+        // Support additional top level domains
+        if (additionalTLDs != null && !additionalTLDs.isEmpty()) {
+            try {
+                String[] tldsToAddArray = additionalTLDs.toArray(new 
String[additionalTLDs.size()]);
+                LOG.info("Adding the following additional Top Level Domains: " 
+ Arrays.toString(tldsToAddArray));
+                DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, 
tldsToAddArray);
+            } catch (IllegalStateException ex) {
+                //
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/1f42f03a/services/idp/src/main/webapp/WEB-INF/security-config.xml
----------------------------------------------------------------------
diff --git a/services/idp/src/main/webapp/WEB-INF/security-config.xml 
b/services/idp/src/main/webapp/WEB-INF/security-config.xml
index 0bbafe3..da92d66 100644
--- a/services/idp/src/main/webapp/WEB-INF/security-config.xml
+++ b/services/idp/src/main/webapp/WEB-INF/security-config.xml
@@ -73,5 +73,8 @@
        
     <bean id="entitlementsEnricher" 
           
class="org.apache.cxf.fediz.service.idp.service.security.GrantedAuthorityEntitlements"
 />
+
+    <bean id="commonsURLValidator"
+          class="org.apache.cxf.fediz.service.idp.beans.CommonsURLValidator" />
        
 </beans>

Reply via email to