use of com.symphony.api.id.SymphonyIdentity in project spring-bot by finos.
the class BasicAppIdentityProvider method getIdentity.
public SymphonyIdentity getIdentity() throws Exception {
SymphonyIdentity out = null;
IdentityProperties identity = p.getIdentity();
String appId = getAppId(p);
if (identity != null) {
out = performIdentityLoad(identity, appId);
}
if (out == null) {
out = performIdentityLoad(getClasspathResourceLocation(appId), appId);
}
if (out == null) {
out = performIdentityLoad(getFileResourceLocation(appId), appId);
}
if (out == null) {
throw new IdentityConfigurationException("Couldn't load app identity", null);
}
return out;
}
use of com.symphony.api.id.SymphonyIdentity 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;
}
use of com.symphony.api.id.SymphonyIdentity in project spring-bot by finos.
the class SymphonyAppConfig method appIdentity.
@Bean(name = APP_IDENTITY_BEAN)
@ConditionalOnMissingBean(name = APP_IDENTITY_BEAN)
public SymphonyIdentity appIdentity() throws Exception {
GeneratingAppIdentityProvider provider = new GeneratingAppIdentityProvider(appProperties(), loader, objectMapper);
SymphonyIdentity out = provider.getIdentity();
return out;
}
use of com.symphony.api.id.SymphonyIdentity in project spring-bot by finos.
the class JWTHelperIT method testWithSuppliedId.
@Test
public void testWithSuppliedId() throws Exception {
SymphonyIdentity id = TestIdentityProvider.getIdentity("symphony-develop-bot1-identity");
long future = 1562389592;
String jwt = JWTHelper.createSignedJwt("supercomputa", future, id.getPrivateKey());
String[] parts = jwt.split("\\.");
verifySignature(id.getPublicKey(), parts);
Assertions.assertEquals("{\"alg\":\"RS512\"}{\"sub\":\"supercomputa\",\"exp\":1562389592}", JWTHelper.decodeJwt(jwt));
}
use of com.symphony.api.id.SymphonyIdentity in project spring-bot by finos.
the class SymphonyApiConfig method botIdentity.
@Bean(name = SINGLE_BOT_IDENTITY_BEAN)
@ConditionalOnMissingBean
@ConditionalOnExpression("'${" + SINGLE_BOT_IDENTITY_PROPERTY + ".email:}${" + SINGLE_BOT_IDENTITY_PROPERTY + ".location:}' != ''")
public SymphonyIdentity botIdentity() throws IOException {
LOG.warn("Loading identity from " + SINGLE_BOT_IDENTITY_PROPERTY);
SymphonyIdentity id = IdentityProperties.instantiateIdentityFromDetails(resourceLoader, identityDetails(), mapper);
if (id == null) {
throw new IdentityConfigurationException("Couldn't create bot identity from properties", null);
}
return id;
}
Aggregations