< prev index next >

src/share/classes/sun/security/pkcs11/P11DSAKeyFactory.java

Print this page
rev 1387 : 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
Reviewed-by: xuelei, mullan
Contributed-by: alexandre.boulgakov@oracle.com

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -206,12 +206,12 @@
         } finally {
             token.releaseSession(session);
         }
     }
 
-    KeySpec implGetPublicKeySpec(P11Key key, Class keySpec, Session[] session)
-            throws PKCS11Exception, InvalidKeySpecException {
+    <T extends KeySpec> T implGetPublicKeySpec(P11Key key, Class<T> keySpec,
+            Session[] session) throws PKCS11Exception, InvalidKeySpecException {
         if (DSAPublicKeySpec.class.isAssignableFrom(keySpec)) {
             session[0] = token.getObjSession();
             CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
                 new CK_ATTRIBUTE(CKA_VALUE),
                 new CK_ATTRIBUTE(CKA_PRIME),

@@ -223,19 +223,19 @@
                 attributes[0].getBigInteger(),
                 attributes[1].getBigInteger(),
                 attributes[2].getBigInteger(),
                 attributes[3].getBigInteger()
             );
-            return spec;
+            return keySpec.cast(spec);
         } else { // X.509 handled in superclass
             throw new InvalidKeySpecException("Only DSAPublicKeySpec and "
                 + "X509EncodedKeySpec supported for DSA public keys");
         }
     }
 
-    KeySpec implGetPrivateKeySpec(P11Key key, Class keySpec, Session[] session)
-            throws PKCS11Exception, InvalidKeySpecException {
+    <T extends KeySpec> T implGetPrivateKeySpec(P11Key key, Class<T> keySpec,
+            Session[] session) throws PKCS11Exception, InvalidKeySpecException {
         if (DSAPrivateKeySpec.class.isAssignableFrom(keySpec)) {
             session[0] = token.getObjSession();
             CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
                 new CK_ATTRIBUTE(CKA_VALUE),
                 new CK_ATTRIBUTE(CKA_PRIME),

@@ -247,11 +247,11 @@
                 attributes[0].getBigInteger(),
                 attributes[1].getBigInteger(),
                 attributes[2].getBigInteger(),
                 attributes[3].getBigInteger()
             );
-            return spec;
+            return keySpec.cast(spec);
         } else { // PKCS#8 handled in superclass
             throw new InvalidKeySpecException("Only DSAPrivateKeySpec "
                 + "and PKCS8EncodedKeySpec supported for DSA private keys");
         }
     }
< prev index next >