Fixed a bug that caused crypto handle expiration times to not take effect.
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / hs / provider / CryptoShibHandle.java
index b05c4a7..9d12371 100644 (file)
@@ -64,7 +64,6 @@ import edu.internet2.middleware.shibboleth.common.NameIdentifierMapping;
 import edu.internet2.middleware.shibboleth.common.NameIdentifierMappingException;
 import edu.internet2.middleware.shibboleth.common.ServiceProvider;
 import edu.internet2.middleware.shibboleth.common.ShibResource;
-import edu.internet2.middleware.shibboleth.hs.HSNameIdentifierMapping;
 import edu.internet2.middleware.shibboleth.utils.Base32;
 
 /**
@@ -74,7 +73,7 @@ import edu.internet2.middleware.shibboleth.utils.Base32;
  * @author Walter Hoehn
  * @author Derek Morr
  */
-public class CryptoShibHandle extends AQHNameIdentifierMapping implements HSNameIdentifierMapping {
+public class CryptoShibHandle extends AQHNameIdentifierMapping implements NameIdentifierMapping {
 
        private static Logger log = Logger.getLogger(CryptoShibHandle.class.getName());
        protected SecretKey secret;
@@ -205,8 +204,7 @@ public class CryptoShibHandle extends AQHNameIdentifierMapping implements HSName
                        long decodedExpirationTime = dataStream.readLong();
                        String decodedPrincipal = dataStream.readUTF();
 
-                       HMACHandleEntry macHandleEntry = new HMACHandleEntry(
-                                       createHandleEntry(new AuthNPrincipal(decodedPrincipal)));
+                       HMACHandleEntry macHandleEntry = createHMACHandleEntry(new AuthNPrincipal(decodedPrincipal));
                        macHandleEntry.setExpirationTime(decodedExpirationTime);
                        byte[] generatedMac = macHandleEntry.getMAC(mac);
 
@@ -263,8 +261,7 @@ public class CryptoShibHandle extends AQHNameIdentifierMapping implements HSName
 
                        Mac mac = Mac.getInstance(macAlgorithm);
                        mac.init(secret);
-                       HandleEntry handleEntry = createHandleEntry(principal);
-                       HMACHandleEntry macHandleEntry = new HMACHandleEntry(handleEntry);
+                       HMACHandleEntry macHandleEntry = createHMACHandleEntry(principal);
 
                        Cipher cipher = Cipher.getInstance(cipherAlgorithm);
                        byte[] iv = new byte[cipher.getBlockSize()];
@@ -397,6 +394,11 @@ public class CryptoShibHandle extends AQHNameIdentifierMapping implements HSName
                return Arrays.equals(defaultKey, encodedKey);
        }
 
+       protected HMACHandleEntry createHMACHandleEntry(AuthNPrincipal principal) {
+
+               return new HMACHandleEntry(principal, handleTTL);
+       }
+
 }
 
 /**
@@ -410,11 +412,6 @@ class HMACHandleEntry extends HandleEntry {
                super(principal, TTL);
        }
 
-       protected HMACHandleEntry(HandleEntry handleEntry) {
-
-               super(handleEntry.principal, handleEntry.expirationTime);
-       }
-
        private static byte[] getLongBytes(long longValue) {
 
                try {