Search in sources :

Example 1 with SingleSymphonyIdentity

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;
}
Also used : SingleSymphonyIdentity(com.symphony.api.id.SingleSymphonyIdentity) KeyPair(java.security.KeyPair) RSAPrivateCrtKey(java.security.interfaces.RSAPrivateCrtKey) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) Resource(org.springframework.core.io.Resource) SymphonyIdentity(com.symphony.api.id.SymphonyIdentity) SingleSymphonyIdentity(com.symphony.api.id.SingleSymphonyIdentity) X509Certificate(java.security.cert.X509Certificate)

Aggregations

SingleSymphonyIdentity (com.symphony.api.id.SingleSymphonyIdentity)1 SymphonyIdentity (com.symphony.api.id.SymphonyIdentity)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 KeyPair (java.security.KeyPair)1 X509Certificate (java.security.cert.X509Certificate)1 RSAPrivateCrtKey (java.security.interfaces.RSAPrivateCrtKey)1 Resource (org.springframework.core.io.Resource)1