From b0fc58713dc5c60f3a0bbe792124c37eb97d5d5a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 17 Nov 2002 00:10:24 +0000 Subject: Integrate work by Raif S. Integrate work by Raif S. Naffah (raif@fl.net.au) * java/security/DummyKeyPairGenerator.java (clone): New method. * java/security/DummyMessageDigest.java (clone): New method. (engineUpdate): Now public. (engineReset): Likewise. (engineDigest): Likewise. (engineGetDigestLength): New method. * java/security/DummySignature.java (clone): New method. * java/security/KeyPairGenerator.java (provider): Now package private. (getInstance(String)): Use getInstance(String,Provider). (getInstance(String,String): Use getInstance(String,Provider) (getInstance(String,Provider): New method. (getInstance(String,String,Provider): Don't cast DummyKeyPairGenerator. * java/security/KeyPairGeneratorSpi.java (clone): New method. * java/security/MessageDigest.java (provider): Now package private. (getInstance(String): Use getInstance(String,Provider). (getInstance(String,String): Use getInstance(String,Provider) (getInstance(String,Provider): New method. * java/security/Provider.java (toCanonicalKey): New method. (get): New method that uses toCanonicalKey(). (put): Use toCanonicalKey(). (remove): Likewise. * java/security/Security.java (insertProviderAt): Provider index is one based, not zero based. (addProvider): Likewise. (removeProvider): Likewise. * java/security/Signature.java (provider): Now package private. (getInstance(String)): Use getInstance(String,Provider). (getInstance(String,String): Use getInstance(String,Provider) (getInstance(String,Provider): New method. (getInstance(String,String,Provider): Don't cast DummySignature. From-SVN: r59179 --- libjava/java/security/Security.java | 97 ++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 38 deletions(-) (limited to 'libjava/java/security/Security.java') diff --git a/libjava/java/security/Security.java b/libjava/java/security/Security.java index 9ae90ba365c..8c84c3f7978 100644 --- a/libjava/java/security/Security.java +++ b/libjava/java/security/Security.java @@ -1,5 +1,5 @@ /* Security.java --- Java base security class implmentation - Copyright (C) 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -127,8 +127,8 @@ public final class Security extends Object } /** - Gets a specific property for an algorithm. This is used to produce specialized - algorithm parsers. + Gets a specific property for an algorithm. This is used to produce + specialized algorithm parsers. @deprecated it used to a return the value of a propietary property for the "SUN" Cryptographic Service Provider to obtain @@ -147,21 +147,37 @@ public final class Security extends Object } /** - Adds a new provider at the specified position. This allows dynamic loading - of providers. It will check for duplication of providers. - - This class checks the security manager with the call checkSecurityAccess - with "insertProvider."+provider.getName() to see if the user can add this - provider. - - @param provider the provider to add - @param position position to add the provider at - - @return the position the provider was added at, or -1 if a duplicate provider - was found - - @throws SecurityException - if the security manager denies access to add a - new provider + Adds a new provider, at a specified position. The position is the + preference order in which providers are searched for requested algorithms. + Note that it is not guaranteed that this preference will be respected. The + position is 1-based, that is, 1 is most preferred, followed by 2, and so + on. +

+ If the given provider is installed at the requested position, the + provider that used to be at that position, and all providers with a + position greater than position, are shifted up one position (towards the + end of the list of installed providers). +

+ A provider cannot be added if it is already installed. +

+ NOT IMPLEMENTED YET:[ + First, if there is a security manager, its checkSecurityAccess + method is called with the string + "insertProvider."+provider.getName() + to see if it's ok to add a new provider. If the default implementation of + checkSecurityAccess is used (i.e., that method is not + overriden), then this will result in a call to the security manager's + checkPermission method with a SecurityPermission( + "insertProvider."+provider.getName()) permission.] + + @param provider the provider to be added. + @param position the preference position that the caller would like for + this provider. + @return the actual preference position (1-based) in which the provider was + added, or -1 if the provider was not added because it is already installed. + @throws SecurityException if a security manager exists and its + SecurityManager.checkSecurityAccess(java.lang.String) method denies + access to add a new provider. */ public static int insertProviderAt(Provider provider, int position) { @@ -169,6 +185,7 @@ public final class Security extends Object if (sm != null) sm.checkSecurityAccess("insertProvider." + provider.getName()); + position--; int max = providers.size (); for (int i = 0; i < max; i++) { @@ -184,29 +201,33 @@ public final class Security extends Object providers.insertElementAt(provider, position); - return position; + return position + 1; } /** - Adds a new provider. This allows dynamic loading - of providers. It will check for duplication of providers. - - This method checks the security manager with the call checkSecurityAccess - with "insertProvider."+provider.getName() to see if the user can add this - provider. - - @param provider the provider to add - - @return the position the provider was added at, or -1 if a duplicate provider - was found - - @throws SecurityException - if the security manager denies access to add a - new provider + Adds a provider to the next position available. +

+ NOT IMPLEMENTED YET: [ + First, if there is a security manager, its checkSecurityAccess + method is called with the string + "insertProvider."+provider.getName() + to see if it's ok to add a new provider. If the default implementation of + checkSecurityAccess is used (i.e., that method is not + overriden), then this will result in a call to the security manager's + checkPermission method with a SecurityPermission( + "insertProvider."+provider.getName()) permission.] + + @param provider the provider to be added. + @return the preference position in which the provider was added, or + -1 if the provider was not added because it is already installed. + @throws SecurityException if a security manager exists and its + SecurityManager.checkSecurityAccess(java.lang.String) method denies + access to add a new provider. */ public static int addProvider(Provider provider) { - return insertProviderAt (provider, providers.size ()); + return insertProviderAt (provider, providers.size () + 1); } /** @@ -215,13 +236,13 @@ public final class Security extends Object ranking. If the provider is not installed, it fails silently. This method checks the security manager with the call checkSecurityAccess - with "removeProvider."+provider.getName() to see if the user can remove this - provider. + with "removeProvider."+provider.getName() to see if the user can remove + this provider. @param name name of the provider to add - @throws SecurityException - if the security manager denies access to remove a - new provider + @throws SecurityException - if the security manager denies access to + remove a new provider */ public static void removeProvider(String name) { -- cgit v1.2.3