Update multivalued properties to use getArrayProperty from ConfigurationService. Update specific config names based on renamed config keys.

This commit is contained in:
Tim Donohue
2015-08-20 12:26:51 -05:00
parent a428d5a24e
commit 1c8ed977c2
14 changed files with 129 additions and 134 deletions

View File

@@ -8,7 +8,11 @@
package org.dspace.authenticate;
import java.sql.SQLException;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -22,6 +26,7 @@ import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group;
import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.eperson.service.GroupService;
import org.dspace.utils.DSpace;
/**
* Adds users to special groups based on IP address. Configuration parameter
@@ -80,24 +85,20 @@ public class IPAuthentication implements AuthenticationMethod
ipMatcherGroupNames = new HashMap<>();
groupService = EPersonServiceFactory.getInstance().getGroupService();
Enumeration e = ConfigurationManager.propertyNames("authentication-ip");
List<String> propNames = new DSpace().getConfigurationService().getPropertyKeys("authentication-ip");
while (e.hasMoreElements())
for(String propName : propNames)
{
String propName = (String) e.nextElement();
if (propName.startsWith("ip."))
{
String[] nameParts = propName.split("\\.");
String[] nameParts = propName.split("\\.");
if (nameParts.length == 2)
{
addMatchers(nameParts[1], ConfigurationManager.getProperty("authentication-ip", propName));
}
else
{
log.warn("Malformed configuration property name: "
+ propName);
}
if (nameParts.length == 2)
{
addMatchers(nameParts[1], new DSpace().getConfigurationService().getProperty(propName));
}
else
{
log.warn("Malformed configuration property name: "
+ propName);
}
}
}