use of com.symphony.api.id.SingleSymphonyIdentity in project spring-bot by finos.
the class GeneratingAppIdentityProvider method performIdentityLoad.
/**
* Augments the identity process by generating a new self-signed certificate
* and storing it in the application directory.
*
* Note - terrible idea if running with multiple instances and not sharing the f/s.
*/
@Override
protected SymphonyIdentity performIdentityLoad(IdentityProperties identity, String appId) throws Exception {
SymphonyIdentity out = super.performIdentityLoad(identity, appId);
if (out == null) {
String location = identity.getLocation();
Resource r = loader.getResource(location);
if (r.isFile()) {
LOG.info("Creating a new identity in {}, since one couldn't be loaded", location);
KeyPair keyPair = certTools.createKeyPair();
X509Certificate cert = certTools.createSelfSignedCertificate(appId, keyPair);
out = new SingleSymphonyIdentity((RSAPrivateCrtKey) keyPair.getPrivate(), null, new X509Certificate[] { cert }, appId);
OutputStream os = new FileOutputStream(r.getFile());
om.writeValue(os, out);
os.close();
} else {
}
}
return out;
}
Aggregations