KeyProvider implements Closeable { public static Options options(Configuration conf) { return new Options(conf); } KeyProvider(Configuration conf); Configuration getConf(); static Options options(Configuration conf); boolean isTransient(); abstract KeyVersion getKeyVersion(String versionName
                                            ); abstract List<String> getKeys(); Metadata[] getKeysMetadata(String... names); abstract List<KeyVersion> getKeyVersions(String name); KeyVersion getCurrentKey(String name); abstract Metadata getMetadata(String name); abstract KeyVersion createKey(String name, byte[] material,
                                       Options options); KeyVersion createKey(String name, Options options); abstract void deleteKey(String name); abstract KeyVersion rollNewVersion(String name,
                                             byte[] material
                                            ); void close(); KeyVersion rollNewVersion(String name); void invalidateCache(String name); abstract void flush(); static String getBaseName(String versionName); static KeyProvider findProvider(List<KeyProvider> providerList,
                                         String keyName); boolean needsPassword(); String noPasswordWarning(); String noPasswordError(); static final String DEFAULT_CIPHER_NAME; static final String DEFAULT_CIPHER; static final String DEFAULT_BITLENGTH_NAME; static final int DEFAULT_BITLENGTH; static final String JCEKS_KEY_SERIALFILTER_DEFAULT; static final String JCEKS_KEY_SERIAL_FILTER; }
@Test public void testOptions() throws Exception { Configuration conf = new Configuration(); conf.set(KeyProvider.DEFAULT_CIPHER_NAME, "myCipher"); conf.setInt(KeyProvider.DEFAULT_BITLENGTH_NAME, 512); Map<String, String> attributes = new HashMap<String, String>(); attributes.put("a", "A"); KeyProvider.Options options = KeyProvider.options(conf); assertEquals("myCipher", options.getCipher()); assertEquals(512, options.getBitLength()); options.setCipher("yourCipher"); options.setDescription("description"); options.setAttributes(attributes); options.setBitLength(128); assertEquals("yourCipher", options.getCipher()); assertEquals(128, options.getBitLength()); assertEquals("description", options.getDescription()); assertEquals(attributes, options.getAttributes()); options = KeyProvider.options(new Configuration()); assertEquals(KeyProvider.DEFAULT_CIPHER, options.getCipher()); assertEquals(KeyProvider.DEFAULT_BITLENGTH, options.getBitLength()); }