Search in sources :

Example 1 with P12SymphonyIdentity

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;
}
Also used : PemSymphonyIdentity(com.symphony.api.id.PemSymphonyIdentity) P12SymphonyIdentity(com.symphony.api.id.P12SymphonyIdentity) Resource(org.springframework.core.io.Resource) SymphonyIdentity(com.symphony.api.id.SymphonyIdentity) PemSymphonyIdentity(com.symphony.api.id.PemSymphonyIdentity) P12SymphonyIdentity(com.symphony.api.id.P12SymphonyIdentity)

Aggregations

P12SymphonyIdentity (com.symphony.api.id.P12SymphonyIdentity)1 PemSymphonyIdentity (com.symphony.api.id.PemSymphonyIdentity)1 SymphonyIdentity (com.symphony.api.id.SymphonyIdentity)1 Resource (org.springframework.core.io.Resource)1