The Security Class
In this section, we’ll look into how the Java VM locates the
security provider(s) we want to use. The
Security
class (java.security.Security) is responsible
for managing the set of provider classes that a Java program can use
and forms the last link in the architecture of the security provider.
This class is final, and all its methods are
static (except for its constructor, which
is private). Like the System and
Math classes, then, the
Security class can never be created or
subclassed; it exists simply to provide a placeholder for methods
that deal with the java.security package.
Earlier, we explained how to add entries to the
java.security file to add new providers to the
security architecture. The same feat can be accomplished
programmatically via these methods of the
Security class:
- public static int addProvider(Provider provider)
Add a new provider into the list of providers. The provider is added to the end of the internal array of providers.
- public static int insertProviderAt(Provider provider, int position)
Add a new provider into the internal array of providers. The provider is added at the specified position; other providers have their index changed if necessary to make room for this provider. Position counting begins at 1.
The notion that these classes are kept in an indexed array is
important; when the
Security
class is asked to provide a particular algorithm for an operation, the array is searched sequentially for a provider that can supply the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access