Optimize collection usage
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 12 Dec 2008 10:37:40 +0000 (10:37 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 12 Dec 2008 10:37:40 +0000 (10:37 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/branches/REL_2@2820 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/main/java/edu/internet2/middleware/shibboleth/idp/authn/AuthenticationEngine.java
src/main/java/edu/internet2/middleware/shibboleth/idp/authn/LoginContext.java
src/main/java/edu/internet2/middleware/shibboleth/idp/authn/Saml2LoginContext.java
src/main/java/edu/internet2/middleware/shibboleth/idp/authn/provider/AbstractLoginHandler.java

index 5b363bf..bc30e0d 100644 (file)
@@ -716,15 +716,15 @@ public class AuthenticationEngine extends HttpServlet {
             return new Subject();
         }
 
-        Set<Principal> principals = new HashSet<Principal>();
+        Set<Principal> principals = new HashSet<Principal>(3);
         principals.addAll(subject1.getPrincipals());
         principals.addAll(subject2.getPrincipals());
 
-        Set<Object> publicCredentials = new HashSet<Object>();
+        Set<Object> publicCredentials = new HashSet<Object>(3);
         publicCredentials.addAll(subject1.getPublicCredentials());
         publicCredentials.addAll(subject2.getPublicCredentials());
 
-        Set<Object> privateCredentials = new HashSet<Object>();
+        Set<Object> privateCredentials = new HashSet<Object>(3);
         privateCredentials.addAll(subject1.getPrivateCredentials());
         privateCredentials.addAll(subject2.getPrivateCredentials());
 
index 633aa0d..ed6c63d 100644 (file)
 package edu.internet2.middleware.shibboleth.idp.authn;
 
 import java.io.Serializable;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.joda.time.DateTime;
+import org.opensaml.xml.util.LazyList;
 
 import edu.internet2.middleware.shibboleth.idp.session.AuthenticationMethodInformation;
 
@@ -87,14 +87,14 @@ public class LoginContext implements Serializable {
     private String sessionID;
 
     /** List of request authentication methods. */
-    private ArrayList<String> requestAuthenticationMethods;
+    private List<String> requestAuthenticationMethods;
 
     /** Information about the authentication method. */
     private AuthenticationMethodInformation authenticationMethodInformation;
 
     /** Creates a new instance of LoginContext. */
     public LoginContext() {
-        requestAuthenticationMethods = new ArrayList<String>();
+        requestAuthenticationMethods = new LazyList<String>();
     }
 
     /**
@@ -106,7 +106,7 @@ public class LoginContext implements Serializable {
     public LoginContext(boolean force, boolean passive) {
         forceAuth = force;
         passiveAuth = passive;
-        requestAuthenticationMethods = new ArrayList<String>();
+        requestAuthenticationMethods = new LazyList<String>();
     }
 
     /**
index 6426f94..7919922 100644 (file)
@@ -18,7 +18,6 @@ package edu.internet2.middleware.shibboleth.idp.authn;
 
 import java.io.Serializable;
 import java.io.StringWriter;
-import java.util.ArrayList;
 import java.util.List;
 
 import org.opensaml.Configuration;
@@ -32,6 +31,7 @@ import org.opensaml.xml.io.Marshaller;
 import org.opensaml.xml.io.MarshallingException;
 import org.opensaml.xml.io.UnmarshallingException;
 import org.opensaml.xml.util.DatatypeHelper;
+import org.opensaml.xml.util.LazyList;
 import org.opensaml.xml.util.XMLHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -123,7 +123,7 @@ public class Saml2LoginContext extends LoginContext implements Serializable {
      * @return requested authentication methods, or an empty list if no preference
      */
     protected List<String> extractRequestedAuthenticationMethods(AuthnRequest request){
-        ArrayList<String> requestedMethods = new ArrayList<String>();
+        LazyList<String> requestedMethods = new LazyList<String>();
 
         RequestedAuthnContext authnContext = request.getRequestedAuthnContext();
         if (authnContext == null) {
index 79eea69..972bd77 100644 (file)
 
 package edu.internet2.middleware.shibboleth.idp.authn.provider;
 
-import java.util.ArrayList;
 import java.util.List;
 
+import org.opensaml.xml.util.LazyList;
+
 import edu.internet2.middleware.shibboleth.idp.authn.LoginHandler;
 
 /**
@@ -27,7 +28,7 @@ import edu.internet2.middleware.shibboleth.idp.authn.LoginHandler;
 public abstract class AbstractLoginHandler implements LoginHandler {
     
     /** Authentication methods this handler supports. */
-    private ArrayList<String> supportedAuthenticationMethods;
+    private List<String> supportedAuthenticationMethods;
 
     /** Length of time, in milliseconds, after which a user should be re-authenticated. */
     private long authenticationDuration;
@@ -40,7 +41,7 @@ public abstract class AbstractLoginHandler implements LoginHandler {
     
     /** Constructor. */
     protected AbstractLoginHandler(){
-        supportedAuthenticationMethods = new ArrayList<String>();
+        supportedAuthenticationMethods = new LazyList<String>();
         supportsForceAuthentication = false;
         supportsPassive = false;
     }