use of com.symphony.api.id.P12SymphonyIdentity 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;
}
Aggregations