String type = (String) res.get("type");
String macKey = (String) res.get("mackey");
Date expDate = (Date) res.get("expdate");
if (type == null || macKey == null || expDate == null)
throw new AssociationException("Invalid association data " +
"retrived from database; cannot create Association " +
"object for handle: " + handle);
Association assoc;
if (Association.TYPE_HMAC_SHA1.equals(type))
assoc = Association.createHmacSha1(handle,
Base64.decodeBase64(macKey.getBytes() ), expDate);
else if (Association.TYPE_HMAC_SHA256.equals(type))
assoc = Association.createHmacSha256(handle,
Base64.decodeBase64(macKey.getBytes() ), expDate);
else
throw new AssociationException("Invalid association type " +
"retrieved from database: " + type);
if (DEBUG)
_log.debug("Retrieved association from database, handle: " + handle);