public class KeyStores extends Object
KeyStore
conveniently from within the source of a Configuration
. This class
cannot be instantiated.Modifier and Type | Method and Description |
---|---|
static KeyStore |
getKeyStore(String location,
String type)
Returns a
KeyStore initialized with contents read from a
location specified as a file or URL. |
static X500Principal |
getX500Principal(String alias,
KeyStore keystore)
Returns the
X500Principal for the alias in a
KeyStore ; or null if the alias is not found,
if the alias is not associated with a certificate, or if the certificate
is not an X509Certificate . |
public static KeyStore getKeyStore(String location, String type) throws GeneralSecurityException, IOException
Returns a KeyStore
initialized with contents read from a
location specified as a file or URL. This method provides a convenient
way to refer to keystores from within the source for a configuration,
which may then be used with getX500Principal
to refer to principals.
For example, a deployer that was using SslServerEndpoint
might
use the following in the source for a ConfigurationFile
to
supply principals for use in security constraints:
Client { private static users = KeyStores.getKeyStore("users.ks", null); private static client = KeyStores.getX500Principal("client", users); //... }
location
- the file name or URL containing the
KeyStore
contentstype
- the type of KeyStore
to create, or
null
for the default typeKeyStore
, with contents read from
location
GeneralSecurityException
- if there are problems with the contentsIOException
- if an I/O error occurs when reading from
location
NullPointerException
- if location
is
null
getX500Principal
public static X500Principal getX500Principal(String alias, KeyStore keystore) throws KeyStoreException
Returns the X500Principal
for the alias in a
KeyStore
; or null
if the alias is not found,
if the alias is not associated with a certificate, or if the certificate
is not an X509Certificate
. This method provides a convenient way
to refer to principals from within the source for a configuration by
specifying aliases when used with getKeystore
.
For example, a deployer that was using SslServerEndpoint
might
use the following in the source for a ConfigurationFile
to
supply principals for use in security constraints:
Client { private static users = KeyStores.getKeyStore("users.ks", null); private static client = KeyStores.getX500Principal("client", users); //... }
alias
- the aliaskeystore
- the KeyStore
X500Principal
or null
KeyStoreException
- if the keystore has not been initialized
(loaded)NullPointerException
- if either argument is null
getKeyStore
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.