@Test void load() { PrivateKeyLoader loader = new PrivateKeyLoader(); Bundle bundle = new Bundle(); loader.load(bundle, createXml( DocumentTools.INSTANCE.getDocumentBuilder().newDocument() )); assertFalse(bundle.getPrivateKeys().isEmpty()); assertEquals(1, bundle.getPrivateKeys().size()); PrivateKey privateKey = bundle.getPrivateKeys().get("alias"); assertNotNull(privateKey); assertEquals("alias", privateKey.getName()); assertEquals("alias", privateKey.getAlias()); assertEquals(KeyStoreType.GENERIC, privateKey.getKeyStoreType()); assertEquals(KeyStoreType.GENERIC.getName(), privateKey.getKeystore()); assertEquals("EC", privateKey.getAlgorithm()); }
@Override public void load(Bundle bundle, Element element) { final Element privateKey = getSingleChildElement(getSingleChildElement(element, RESOURCE), PRIVATE_KEY); final String alias = privateKey.getAttribute(ATTRIBUTE_ALIAS); final KeyStoreType keystore = KeyStoreType.fromId(privateKey.getAttribute(ATTRIBUTE_KEYSTORE_ID)); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(privateKey, PROPERTIES), PROPERTIES); PrivateKey key = new PrivateKey(); key.setId(keystore.generateKeyId(alias)); key.setAlias(alias); key.setKeyStoreType(keystore); key.setKeystore(keystore.getName()); key.setAlgorithm((String) properties.get("keyAlgorithm")); key.setKeyPassword(""); bundle.getPrivateKeys().put(alias, key); }
PrivateKeyLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element privateKey = getSingleChildElement(getSingleChildElement(element, RESOURCE), PRIVATE_KEY); final String alias = privateKey.getAttribute(ATTRIBUTE_ALIAS); final KeyStoreType keystore = KeyStoreType.fromId(privateKey.getAttribute(ATTRIBUTE_KEYSTORE_ID)); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(privateKey, PROPERTIES), PROPERTIES); PrivateKey key = new PrivateKey(); key.setId(keystore.generateKeyId(alias)); key.setAlias(alias); key.setKeyStoreType(keystore); key.setKeystore(keystore.getName()); key.setAlgorithm((String) properties.get("keyAlgorithm")); key.setKeyPassword(""); bundle.getPrivateKeys().put(alias, key); } }
PrivateKeyLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element privateKey = getSingleChildElement(getSingleChildElement(element, RESOURCE), PRIVATE_KEY); final String alias = privateKey.getAttribute(ATTRIBUTE_ALIAS); final KeyStoreType keystore = KeyStoreType.fromId(privateKey.getAttribute(ATTRIBUTE_KEYSTORE_ID)); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(privateKey, PROPERTIES), PROPERTIES); PrivateKey key = new PrivateKey(); key.setId(keystore.generateKeyId(alias)); key.setAlias(alias); key.setKeyStoreType(keystore); key.setKeystore(keystore.getName()); key.setAlgorithm((String) properties.get("keyAlgorithm")); key.setKeyPassword(""); bundle.getPrivateKeys().put(alias, key); }  }
PrivateKeyLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element privateKey = getSingleChildElement(getSingleChildElement(element, RESOURCE), PRIVATE_KEY); final String alias = privateKey.getAttribute(ATTRIBUTE_ALIAS); final KeyStoreType keystore = KeyStoreType.fromId(privateKey.getAttribute(ATTRIBUTE_KEYSTORE_ID)); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(privateKey, PROPERTIES), PROPERTIES); PrivateKey key = new PrivateKey(); key.setId(keystore.generateKeyId(alias)); key.setAlias(alias); key.setKeyStoreType(keystore); key.setKeystore(keystore.getName()); key.setAlgorithm((String) properties.get("keyAlgorithm")); key.setKeyPassword(""); bundle.getPrivateKeys().put(alias, key); }  @Override void load(Bundle bundle, Element element); @Override String getEntityType(); }
PrivateKeyLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element privateKey = getSingleChildElement(getSingleChildElement(element, RESOURCE), PRIVATE_KEY); final String alias = privateKey.getAttribute(ATTRIBUTE_ALIAS); final KeyStoreType keystore = KeyStoreType.fromId(privateKey.getAttribute(ATTRIBUTE_KEYSTORE_ID)); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(privateKey, PROPERTIES), PROPERTIES); PrivateKey key = new PrivateKey(); key.setId(keystore.generateKeyId(alias)); key.setAlias(alias); key.setKeyStoreType(keystore); key.setKeystore(keystore.getName()); key.setAlgorithm((String) properties.get("keyAlgorithm")); key.setKeyPassword(""); bundle.getPrivateKeys().put(alias, key); }  @Override void load(Bundle bundle, Element element); @Override String getEntityType();  }