use of com.symphony.api.id.SymphonyIdentity in project spring-bot by finos.
the class RSAAuthIT method testKeyManagerAuthWithRSA.
@ParameterizedTest
@MethodSource("setupConfigurations")
public void testKeyManagerAuthWithRSA(TestClientStrategy s) throws Exception {
SymphonyIdentity id = s.getIdentity();
String jwt = JWTHelper.createSignedJwt(id.getCommonName(), id.getPrivateKey());
AuthenticationApi keyApi = s.getRSAKeyAuthApi();
AuthenticateRequest req = new AuthenticateRequest();
req.setToken(jwt);
Token done = keyApi.pubkeyAuthenticatePost(req);
System.out.println(done);
}
use of com.symphony.api.id.SymphonyIdentity in project spring-bot by finos.
the class RSAAuthIT method testSessionAuthWithRSA.
@ParameterizedTest
@MethodSource("setupConfigurations")
public void testSessionAuthWithRSA(TestClientStrategy s) throws Exception {
SymphonyIdentity id = s.getIdentity();
String jwt = JWTHelper.createSignedJwt(id.getCommonName(), id.getPrivateKey());
System.out.println(jwt);
System.out.println(JWTHelper.decodeJwt(jwt));
AuthenticationApi sessionApi = s.getRSASessionAuthApi();
AuthenticateRequest req = new AuthenticateRequest();
req.setToken(jwt);
Token done = sessionApi.pubkeyAuthenticatePost(req);
System.out.println(done);
}
use of com.symphony.api.id.SymphonyIdentity in project spring-bot by finos.
the class IdentityProperties method instantiateIdentityFromDetails.
@SuppressWarnings("deprecation")
public static SymphonyIdentity instantiateIdentityFromDetails(ResourceLoader loader, IdentityProperties details, ObjectMapper om) throws IOException {
if (!StringUtils.isEmpty(details.getLocation())) {
Resource r = loader.getResource(details.getLocation());
boolean pkcs12 = (details.getType() == Type.PKCS12) || (details.getType() == null) && (details.getLocation().endsWith("p12"));
boolean json = (details.getType() == Type.JSON) || (details.getType() == null) && (details.getLocation().endsWith("json"));
if (r.isReadable()) {
if (pkcs12) {
P12SymphonyIdentity id = new P12SymphonyIdentity(r.getInputStream(), details.getPassword(), details.getEmail());
return id;
} else if (json) {
SymphonyIdentity id = om.readValue(r.getInputStream(), SymphonyIdentity.class);
return id;
}
}
}
if (!StringUtils.isEmpty(details.getPrivateKey())) {
if ((details.getCertificates() != null) && (details.getCertificates().size() > 0)) {
String[] certs = (String[]) details.getCertificates().toArray(new String[details.getCertificates().size()]);
PemSymphonyIdentity id = new PemSymphonyIdentity(details.getPrivateKey(), certs, details.getEmail());
return id;
} else {
PemSymphonyIdentity id = new PemSymphonyIdentity(details.getPrivateKey(), details.getCommonName(), details.getEmail());
return id;
}
}
return null;
}
use of com.symphony.api.id.SymphonyIdentity in project spring-bot by finos.
the class SymphonyAdminController method getAPI.
protected <X> X getAPI(Class<X> x) throws IOException, Exception {
Config config = getConfig();
SymphonyIdentity identity = IdentityProperties.instantiateIdentityFromDetails(rl, config.getIdentityProperties(), getObjectMapper());
ApiBuilderFactory abf = new ApiBuilderFactory() {
@Override
public boolean isSingleton() {
return false;
}
@Override
public Class<?> getObjectType() {
return ApiBuilder.class;
}
@Override
public ConfigurableApiBuilder getObject() throws Exception {
return new CXFApiBuilder();
}
};
ApiInstanceFactory apiInstanceFactory = new TokenManagingApiInstanceFactory(abf);
ApiInstance instance = apiInstanceFactory.createApiInstance(identity, config.getPodProperties(), null);
X out = instance.getAgentApi(x);
return out;
}
use of com.symphony.api.id.SymphonyIdentity in project spring-bot by finos.
the class SymphonyMessageSenderIT method testSymphonyMessageSender.
@Test
public void testSymphonyMessageSender() throws IOException {
SymphonyIdentity id = TestIdentityProvider.getTestIdentity();
ProxyingWrapper pod = new ProxyingWrapper(null, Collections.singletonList(null), POD_URL, id, LOGGER);
ProxyingWrapper agent = new ProxyingWrapper(null, Collections.singletonList(null), AGENT_URL, id, LOGGER);
ProxyingWrapper relay = new ProxyingWrapper(null, Collections.singletonList(null), RELAY_URL, id, LOGGER);
ProxyingWrapper login = new ProxyingWrapper(null, Collections.singletonList(null), LOGIN_URL, id, LOGGER);
SymphonyMessageSender sms = new SymphonyMessageSender(pod, agent, null, null, relay, login, id);
Map<String, Object> data = new HashMap<String, Object>();
Developer d = new Developer();
d.setName("John Johnson");
d.setEmail("john@example.com");
data.put("projects", Collections.emptyList());
data.put("exceptions", Collections.emptyList());
data.put("developers", Collections.singletonList(d));
data.put("title", "Some Test Project");
data.put("date", new Date());
data.put("passed", true);
data.put("url", "https://github.com/finos/symphony-java-toolkit");
data.put("recipients", Collections.singletonList("y3EJYqKMwG7Jn7/YqyYdiX///pR3YrnTdA=="));
data.put("hashtags", Collections.singletonList("some-hash-tag"));
data.put("version", "1.0");
data.put("type", "org.finos.symphony.toolkit.maven-event");
sms.sendMessage(Collections.singletonMap("event", data));
}
Aggregations