use of java.security.KeyStore.LoadStoreParameter in project coprhd-controller by CoprHD.
the class KeystoreTest method setup.
@Before
public void setup() throws URISyntaxException, IOException {
ApplicationContextUtil.initContext(System.getProperty("buildType"), ApplicationContextUtil.SECURITY_CONTEXTS);
List<URI> uri = new ArrayList<URI>();
uri.add(URI.create(coordinatorServer));
ZkConnection connection = new ZkConnection();
connection.setServer(uri);
connection.build();
coordinatorClient.setZkConnection(connection);
CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
map.setNodeId("standalone");
DualInetAddress localAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
map.setDualInetAddress(localAddress);
Map<String, DualInetAddress> controllerNodeIPLookupMap = new HashMap<String, DualInetAddress>();
controllerNodeIPLookupMap.put("localhost", localAddress);
map.setControllerNodeIPLookupMap(controllerNodeIPLookupMap);
coordinatorClient.setInetAddessLookupMap(map);
coordinatorClient.start();
FileInputStream is = new FileInputStream(defaultOvfPropsLocation);
Properties defaultProp = new Properties();
defaultProp.load(is);
is.close();
is = new FileInputStream(ovfPropsLocation);
Properties ovfProps = new Properties();
ovfProps.load(is);
is.close();
CoordinatorClientImpl.setDefaultProperties(defaultProp);
CoordinatorClientImpl.setOvfProperties(ovfProps);
loadStoreParam = new DistributedLoadKeyStoreParam();
loadStoreParam.setCoordinator(coordinatorClient);
invalidLoadStoreParam = new LoadStoreParameter() {
@Override
public ProtectionParameter getProtectionParameter() {
return null;
}
};
gen = new KeyCertificatePairGenerator();
KeyCertificateAlgorithmValuesHolder values = new KeyCertificateAlgorithmValuesHolder(coordinatorClient);
gen.setKeyCertificateAlgorithmValuesHolder(values);
}
use of java.security.KeyStore.LoadStoreParameter in project jmulticard by ctt-gob-es.
the class TestJseProvider method testProviderWithCustomConnection.
static void testProviderWithCustomConnection() throws Exception {
final Provider p = new DnieProvider(new SmartcardIoConnection());
Security.addProvider(p);
// $NON-NLS-1$
final KeyStore ks = KeyStore.getInstance("DNI");
final CallbackHandler callbackHandler;
// $NON-NLS-1$
callbackHandler = (CallbackHandler) Class.forName("es.gob.jmulticard.ui.passwordcallback.gui.DnieCallbackHandler").getConstructor().newInstance();
final LoadStoreParameter lsp = new LoadStoreParameter() {
@Override
public ProtectionParameter getProtectionParameter() {
return new KeyStore.CallbackHandlerProtection(callbackHandler);
}
};
ks.load(lsp);
final Enumeration<String> aliases = ks.aliases();
while (aliases.hasMoreElements()) {
System.out.println(aliases.nextElement());
}
// $NON-NLS-1$
final Signature signature = Signature.getInstance("SHA1withRSA");
// $NON-NLS-1$
signature.initSign((PrivateKey) ks.getKey("CertFirmaDigital", PASSWORD));
// $NON-NLS-1$
signature.update("Hola Mundo!!".getBytes());
signature.sign();
// $NON-NLS-1$
System.out.println("Firma generada correctamente");
}
use of java.security.KeyStore.LoadStoreParameter in project robovm by robovm.
the class KeyStoreTest method test_KeyStore_load_LoadStoreParameter.
public void test_KeyStore_load_LoadStoreParameter() throws Exception {
for (KeyStore keyStore : keyStores()) {
keyStore.load(null);
if (isPersistentStorage(keyStore)) {
assertTrue("Should be able to query size: " + keyStore.getType(), keyStore.size() >= 0);
} else if (hasDefaultContents(keyStore)) {
assertTrue("Should have non-empty store: " + keyStore.getType(), keyStore.size() > 0);
} else {
assertEquals("Should have empty store: " + keyStore.getType(), 0, keyStore.size());
}
}
for (KeyStore keyStore : keyStores()) {
try {
keyStore.load(new LoadStoreParameter() {
public ProtectionParameter getProtectionParameter() {
return null;
}
});
fail(keyStore.getType());
} catch (UnsupportedOperationException expected) {
}
}
}
Aggregations