java.security
Class Security
This class centralizes all security properties and common security methods.
One of its primary uses is to manage security providers.
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
addProvider
public static int addProvider(Provider provider)
- the position (starting from 1) of
provider
in the
current list of Provider
s, or -1
if
provider
was already there.
getAlgorithmProperty
public static String getAlgorithmProperty(String algName,
String propName)
Use the provider-based and algorithm-independent
AlgorithmParameters
and KeyFactory
engine
classes instead.
Returns the value associated to a designated property name for a given
algorithm.
algName
- the algorithm name.propName
- the name of the property to return.
- the value of the specified property or
null
if none
found.
getAlgorithms
public static Set getAlgorithms(String serviceName)
For a given
service (e.g. Signature, MessageDigest, etc...) this
method returns the
Set
of all available algorithm names (instances
of
String
, from all currently installed
Provider
s.
serviceName
- the case-insensitive name of a service (e.g. Signature,
MessageDigest, etc).
- a
Set
of String
s containing the names of all
algorithm names provided by all of the currently installed
Provider
s.
getProperty
public static String getProperty(String key)
Returns the value associated with a Security propery.
key
- the key of the property to fetch.
- the value of the Security property associated with
key
. Returns null
if no such property
was found.
getProviders
public static Provider[] getProviders()
Returns the current list of installed
Provider
s as an array
ordered according to their installation preference order.
- an array of all the installed providers.
getProviders
public static Provider[] getProviders(Map filter)
Returns an array of currently installed
Provider
s which satisfy a
set of
selection criteria.
The
selection criteria are defined in a
Map
where each
element specifies a
selection querry. The
Keys in this
Map
must be in one of the two following forms:
- <crypto_service>.<algorithm_or_type>: Where
crypto_service is a case-insensitive string, similar to what has
been described in the
getAlgorithms(String)
method, and
algorithm_or_type is a case-insensitive known name of an
Algorithm, or one of its aliases. The value of the entry in the
Map
for such a Key MUST be the empty string.
Provider
s which provide an implementation for the designated
service algorithm are included in the result. - <crypto_service>.<algorithm_or_type> <attribute_name>:
Where crypto_service is a case-insensitive string, similar to what
has been described in the
getAlgorithms(String)
method,
algorithm_or_type is a case-insensitive known name of an Algorithm
or one of its aliases, and attribute_name is a case-insensitive
property name with no whitespace characters, and no dots, in-between. The
value of the entry in this Map
for such a Key MUST
NOT be null
or an empty string. Provider
s which
declare the designated attribute_name and value for the
designated service algorithm are included in the result.
filter
- a Map
of selection querries.
- all currently installed
Provider
s which satisfy ALL the
selection criteria defined in filter
.
Returns ALL installed Provider
s if filter
is null
or empty.
getProviders
public static Provider[] getProviders(String filter)
Returns an array of currently installed
Provider
s, ordered
according to their installation preference order, which satisfy a given
selection criterion.
This implementation recognizes a
selection criterion written in
one of two following forms:
- <crypto_service>.<algorithm_or_type>: Where
crypto_service is a case-insensitive string, similar to what has
been described in the
getAlgorithms(String)
method, and
algorithm_or_type is a known case-insensitive name of an
Algorithm, or one of its aliases.
For example, "CertificateFactory.X.509" would return all the installed
Provider
s which provide a CertificateFactory
implementation of X.509. - <crypto_service>.<algorithm_or_type> <attribute_name>:<value>:
Where crypto_service is a case-insensitive string, similar to what
has been described in the
getAlgorithms(String)
method,
algorithm_or_type is a case-insensitive known name of an Algorithm
or one of its aliases, attribute_name is a case-insensitive
property name with no whitespace characters, and no dots, in-between, and
value is a String
with no whitespace characters in-between.
For example, "Signature.Sha1WithDSS KeySize:1024" would return all the
installed Provider
s which declared their ability to provide
Signature services, using the Sha1WithDSS algorithm with
key sizes of 1024.
filter
- the selection criterion for selecting among the installed
Provider
s.
- all the installed
Provider
s which satisfy the selection
criterion. Returns null
if no installed
Provider
s were found which satisfy the selection
criterion. Returns ALL installed Provider
s if
filter
is null
or is an empty string.
insertProviderAt
public static int insertProviderAt(Provider provider,
int position)
Inserts a new designated
Provider
at a designated (1-based)
position in the current list of installed
Provider
s,
provider
- the new Provider
to add.position
- the position (starting from 1) of where to install
provider
.
- the actual position, in the list of installed Providers. Returns
-1
if provider
was laready in the
list. The actual position may be different than the desired
position
.
removeProvider
public static void removeProvider(String name)
Removes an already installed
Provider
, given its name, from the
current list of installed
Provider
s.
name
- the name of an already installed Provider
to remove.
setProperty
public static void setProperty(String key,
String datum)
Sets or changes a designated Security property to a designated value.
key
- the name of the property to set.datum
- the new value of the property.
Security.java --- Java base security class implementation
Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.