Updated OpenSAML library.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 6 Jun 2002 22:30:21 +0000 (22:30 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 6 Jun 2002 22:30:21 +0000 (22:30 +0000)
Moved around some common components.
Converted HS to use the new OpenSAML. (with useless random response key)

git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@37 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

13 files changed:
.classpath
src/edu/internet2/middleware/eduPerson/Init.java
src/edu/internet2/middleware/shibboleth/common/ClubShibPOSTProfile.java [moved from src/edu/internet2/middleware/shibboleth/ClubShibPOSTProfile.java with 97% similarity]
src/edu/internet2/middleware/shibboleth/common/Constants.java [moved from src/edu/internet2/middleware/shibboleth/Constants.java with 90% similarity]
src/edu/internet2/middleware/shibboleth/common/Init.java [moved from src/edu/internet2/middleware/shibboleth/Init.java with 86% similarity]
src/edu/internet2/middleware/shibboleth/common/OriginSiteMapper.java [moved from src/edu/internet2/middleware/shibboleth/OriginSiteMapper.java with 97% similarity, mode: 0644]
src/edu/internet2/middleware/shibboleth/common/SAMLBindingFactory.java [moved from src/edu/internet2/middleware/shibboleth/SAMLBindingFactory.java with 91% similarity]
src/edu/internet2/middleware/shibboleth/common/ShibPOSTProfile.java [moved from src/edu/internet2/middleware/shibboleth/ShibPOSTProfile.java with 99% similarity]
src/edu/internet2/middleware/shibboleth/common/ShibPOSTProfileFactory.java [moved from src/edu/internet2/middleware/shibboleth/ShibPOSTProfileFactory.java with 97% similarity]
src/edu/internet2/middleware/shibboleth/common/XML.java [moved from src/edu/internet2/middleware/shibboleth/XML.java with 97% similarity]
src/edu/internet2/middleware/shibboleth/hs/HandleService.java
webApplication/WEB-INF/lib/opensaml.jar [new file with mode: 0644]
webApplication/WEB-INF/lib/shibboleth.jar [deleted file]

index 96e7faa..e9c2694 100644 (file)
@@ -2,7 +2,6 @@
 <classpath>
     <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
     <classpathentry kind="src" path="source"/>
-    <classpathentry kind="lib" path="webApplication/WEB-INF/lib/shibboleth.jar"/>
     <classpathentry kind="lib" path="buildlibs/servlet.jar" sourcepath="/shib-java/buildlibs/servlet-src.jar"/>
     <classpathentry kind="lib" path="webApplication/WEB-INF/lib/log4j-1.2.jar"/>
     <classpathentry kind="lib" path="webApplication/WEB-INF/lib/commons-beanutils.jar"/>
     <classpathentry kind="lib" path="buildlibs/xmlParserAPIs.jar" sourcepath="/shib-java/buildlibs/xerces-src.jar"/>
     <classpathentry kind="lib" path="buildlibs/xalan.jar"/>
     <classpathentry kind="lib" path="buildlibs/xml-apis.jar"/>
-    <classpathentry kind="lib" path="webApplication/WEB-INF/lib/bc-jce-jdk13-112.jar"/>
+    <classpathentry kind="lib"
+        path="webApplication/WEB-INF/lib/bc-jce-jdk13-112.jar"
+        rootpath="" sourcepath="/Shibboleth/buildlibs/jce-bc-src.jar"/>
     <classpathentry kind="lib" path="webApplication/WEB-INF/lib/struts.jar"/>
     <classpathentry kind="lib" path="webApplication/WEB-INF/lib/xmlsec.jar"/>
+    <classpathentry kind="lib" path="webApplication/WEB-INF/lib/opensaml.jar"/>
     <classpathentry kind="output" path="webApplication\WEB-INF\classes"/>
 </classpath>
index d52867f..18a997a 100755 (executable)
@@ -20,7 +20,7 @@ public class Init
 
         initialized = true;
         
-        edu.internet2.middleware.shibboleth.Init.init();
+        edu.internet2.middleware.shibboleth.common.Init.init();
         try
         {
             org.opensaml.XML.parserPool.registerExtension(XML.EDUPERSON_NS, XML.EDUPERSON_SCHEMA_ID, new XML.SchemaResolver());
@@ -1,4 +1,4 @@
-package edu.internet2.middleware.shibboleth;
+package edu.internet2.middleware.shibboleth.common;
 
 import java.util.Date;
 import java.security.Key;
@@ -10,6 +10,9 @@ import org.apache.xml.security.signature.XMLSignature;
 import org.opensaml.*;
 import org.w3c.dom.*;
 
+import edu.internet2.middleware.shibboleth.common.*;
+import edu.internet2.middleware.shibboleth.shire.*;
+
 /**
  *  ClubShib-specific POST browser profile implementation
  *
@@ -1,4 +1,4 @@
-package edu.internet2.middleware.shibboleth;
+package edu.internet2.middleware.shibboleth.common;
 
 /**
  *  Collection of Shibboleth constants
@@ -1,7 +1,9 @@
-package edu.internet2.middleware.shibboleth;
+package edu.internet2.middleware.shibboleth.common;
 
 import javax.xml.parsers.ParserConfigurationException;
 
+import edu.internet2.middleware.shibboleth.common.XML.SchemaResolver;
+
 /**
  *  Handles one-time library initialization
  *
old mode 100755 (executable)
new mode 100644 (file)
similarity index 97%
rename from src/edu/internet2/middleware/shibboleth/OriginSiteMapper.java
rename to src/edu/internet2/middleware/shibboleth/common/OriginSiteMapper.java
index e557884..a175c83
@@ -1,4 +1,4 @@
-package edu.internet2.middleware.shibboleth;
+package edu.internet2.middleware.shibboleth.common;
 
 import java.security.Key;
 import java.security.KeyStore;
@@ -1,8 +1,10 @@
-package edu.internet2.middleware.shibboleth;
+package edu.internet2.middleware.shibboleth.common;
 
 import org.opensaml.SAMLBinding;
 import org.opensaml.SAMLSOAPBinding;
 
+import edu.internet2.middleware.shibboleth.common.*;
+
 /**
  *  Used by Shibboleth SHAR/AA to locate a SAML binding implementation
  *
@@ -1,4 +1,4 @@
-package edu.internet2.middleware.shibboleth;
+package edu.internet2.middleware.shibboleth.common;
 import java.security.GeneralSecurityException;
 import java.security.Key;
 import java.security.KeyStore;
@@ -18,6 +18,7 @@ import org.apache.xml.security.signature.XMLSignature;
 import org.opensaml.*;
 import org.w3c.dom.*;
 
+
 /**
  *  Basic Shibboleth POST browser profile implementation with basic support for
  *  signing
@@ -1,9 +1,10 @@
-package edu.internet2.middleware.shibboleth;
+package edu.internet2.middleware.shibboleth.common;
 
 import java.security.Key;
 import org.opensaml.SAMLException;
 import org.opensaml.SAMLPOSTProfile;
 
+
 /**
  *  Used by Shibboleth HS/SHIRE to locate a Shibboleth POST profile
  *  implementation
@@ -1,4 +1,4 @@
-package edu.internet2.middleware.shibboleth;
+package edu.internet2.middleware.shibboleth.common;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
index c6eb78e..a7794c1 100755 (executable)
@@ -2,6 +2,9 @@ package edu.internet2.middleware.shibboleth.hs;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.security.KeyPairGenerator;
+import java.security.PrivateKey;
+import java.security.SecureRandom;
 import java.security.Security;
 import java.util.Date;
 
@@ -17,15 +20,15 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.opensaml.SAMLException;
 import org.xml.sax.SAXException;
 
-import edu.internet2.middleware.shibboleth.AABindingInfo;
-import edu.internet2.middleware.shibboleth.Policies;
-import edu.internet2.middleware.shibboleth.SAMLAuthenticationAssertionFactory;
-import edu.internet2.middleware.shibboleth.SAMLException;
 import edu.internet2.middleware.shibboleth.common.AttributeQueryHandle;
 import edu.internet2.middleware.shibboleth.common.Base64;
+import edu.internet2.middleware.shibboleth.common.Constants;
 import edu.internet2.middleware.shibboleth.common.HandleException;
+import edu.internet2.middleware.shibboleth.common.ShibPOSTProfile;
+import edu.internet2.middleware.shibboleth.common.ShibPOSTProfileFactory;
 
 /**
  * 
@@ -42,10 +45,11 @@ import edu.internet2.middleware.shibboleth.common.HandleException;
 public class HandleService extends HttpServlet {
 
        private static Logger log = Logger.getLogger(HandleService.class.getName());
-       private SAMLAuthenticationAssertionFactory assertionFactory;
+       private ShibPOSTProfile assertionFactory;
        private String hsConfigFileLocation;
        private String log4jConfigFileLocation;
-       private SecretKey key;
+       private SecretKey handleKey;
+       private PrivateKey responseKey;
 
        /**
         * @see GenericServlet#init()
@@ -58,30 +62,40 @@ public class HandleService extends HttpServlet {
                initLogger();
                initConfig();
                initViewConfig();
-               initSecretKey();
+               initSecretKeys();
                initAuthNFactory();
        }
 
        /**
-        * Initializes symmetric key for use in AQH creation
+        * Initializes symmetric handleKey for use in AQH creation
         */
 
-       private void initSecretKey() throws ServletException {
+       private void initSecretKeys() throws ServletException {
 
+               //Currently hardcoded to use Bouncy Castle
+               //Decide to change this or not based on overall shibboleth policy
+               Security.addProvider(new BouncyCastleProvider());
                try {
 
-                       //Currently hardcoded to use Bouncy Castle
-                       //Decide to change this or not based on overall shibboleth policy
-                       Security.addProvider(new BouncyCastleProvider());
                        SecretKeyFactory keyFactory =
                                SecretKeyFactory.getInstance("DESede");
                        DESedeKeySpec keySpec =
                                new DESedeKeySpec(
                                        Base64.decode(HandleServiceConfig.getSecretKey()));
-                       key = keyFactory.generateSecret(keySpec);
+                       handleKey = keyFactory.generateSecret(keySpec);
                } catch (Exception t) {
-                       log.fatal("Error reading Secret Key from configuration.", t);
-                       throw new ServletException("Error reading Key from configuration.");
+                       log.fatal("Error reading Handle Key from configuration.", t);
+                       throw new ServletException("Error reading Handle Key from configuration.");
+               }
+               try {
+                       
+                       KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
+                       gen.initialize(1024, new SecureRandom());
+                       responseKey = gen.generateKeyPair().getPrivate();
+
+               } catch (Exception t) {
+                       log.fatal("Error reading Response Key from configuration.", t);
+                       throw new ServletException("Error reading Response Key from configuration.");
                }
 
        }
@@ -171,20 +185,9 @@ public class HandleService extends HttpServlet {
 
        private void initAuthNFactory() throws ServletException {
                try {
-                       AABindingInfo[] binfo = new AABindingInfo[1];
-                       binfo[0] =
-                               new AABindingInfo(
-                                       AABindingInfo.SAML_SOAP_HTTPS,
-                                       HandleServiceConfig.getAaURL());
-                       String[] policies = { Policies.POLICY_URI_CLUBSHIB };
-                       assertionFactory =
-                               SAMLAuthenticationAssertionFactory.getInstance(
-                                       policies,
-                                       HandleServiceConfig.getIssuer(),
-                                       HandleServiceConfig.getDomain(),
-                                       binfo,
-                                       null,
-                                       null);
+                       
+                       String[] policies={Constants.POLICY_CLUBSHIB};
+                       assertionFactory=ShibPOSTProfileFactory.getInstance(policies, HandleServiceConfig.getIssuer());
 
                } catch (SAMLException se) {
                        log.fatal("Error initializing SAML library: ", se);
@@ -301,21 +304,20 @@ public class HandleService extends HttpServlet {
                        AttributeQueryHandle aqh =
                                new AttributeQueryHandle(
                                        remoteUser,
-                                       key,
+                                       handleKey,
                                        Long.parseLong(HandleServiceConfig.getValidityPeriod()),
                                        hsURL);
 
                        log.info("Acquired Handle: " + aqh.getHandleID());
-
-                       return assertionFactory
-                               .getAssertion(
-                                       new String(aqh.serialize(), "ASCII"),
-                                       shireURL,
-                                       clientAddress,
-                                       authType,
-                                       new Date(),
-                                       null)
-                               .toBase64();
+                                       
+                       return assertionFactory.prepare(
+                               shireURL,
+                               new String(aqh.serialize(), "ASCII"),
+                               HandleServiceConfig.getDomain(),
+                               clientAddress,
+                               authType,
+                               new Date(),
+                               null, responseKey, null, null, null).toBase64();
 
                } catch (SAMLException se) {
                        throw new HandleServiceException(
diff --git a/webApplication/WEB-INF/lib/opensaml.jar b/webApplication/WEB-INF/lib/opensaml.jar
new file mode 100644 (file)
index 0000000..a91ce6b
Binary files /dev/null and b/webApplication/WEB-INF/lib/opensaml.jar differ
diff --git a/webApplication/WEB-INF/lib/shibboleth.jar b/webApplication/WEB-INF/lib/shibboleth.jar
deleted file mode 100644 (file)
index 66f5b05..0000000
Binary files a/webApplication/WEB-INF/lib/shibboleth.jar and /dev/null differ