Search in sources :

Example 1 with IdentityConfigurationException

use of com.symphony.api.id.IdentityConfigurationException in project spring-bot by finos.

the class TestIdentityProvider method getSymphonyPropertiesFile.

public static File getSymphonyPropertiesFile(String name) {
    // ok, hunt for a default
    File currentDir = new File("").getAbsoluteFile();
    while (currentDir != null) {
        File x;
        if ((x = new File(currentDir, name + ".json")).exists()) {
            return x;
        }
        currentDir = currentDir.getParentFile();
    }
    // no default found. Throw exception.
    throw new IdentityConfigurationException("Was expecting to find a " + name + ".json file in the current directory or a parent, or " + name + " system property", null);
}
Also used : IdentityConfigurationException(com.symphony.api.id.IdentityConfigurationException) File(java.io.File)

Example 2 with IdentityConfigurationException

use of com.symphony.api.id.IdentityConfigurationException in project spring-bot by finos.

the class TestIdentityProvider method getIdentity.

public static SymphonyIdentity getIdentity(String name) {
    try {
        ObjectMapper om = new ObjectMapper();
        String property = System.getProperties().getProperty(name);
        if (property != null) {
            return om.readValue(property, SymphonyIdentity.class);
        } else {
            File f = getSymphonyPropertiesFile(name);
            return om.readValue(new FileInputStream(f), SymphonyIdentity.class);
        }
    } catch (Exception e) {
        throw new IdentityConfigurationException("Couldn't load test identity " + name, e);
    }
}
Also used : IdentityConfigurationException(com.symphony.api.id.IdentityConfigurationException) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FileInputStream(java.io.FileInputStream) IdentityConfigurationException(com.symphony.api.id.IdentityConfigurationException)

Example 3 with IdentityConfigurationException

use of com.symphony.api.id.IdentityConfigurationException 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;
}
Also used : SymphonyIdentity(com.symphony.api.id.SymphonyIdentity) IdentityConfigurationException(com.symphony.api.id.IdentityConfigurationException) IdentityProperties(org.finos.symphony.toolkit.spring.api.properties.IdentityProperties)

Example 4 with IdentityConfigurationException

use of com.symphony.api.id.IdentityConfigurationException 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;
}
Also used : SymphonyIdentity(com.symphony.api.id.SymphonyIdentity) IdentityConfigurationException(com.symphony.api.id.IdentityConfigurationException) ConditionalOnExpression(org.springframework.boot.autoconfigure.condition.ConditionalOnExpression) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with IdentityConfigurationException

use of com.symphony.api.id.IdentityConfigurationException in project spring-bot by finos.

the class StreamHelp method getProperties.

public static <T> T getProperties(String name, Class<T> c) {
    try {
        ObjectMapper om = new ObjectMapper();
        om.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
        String property = System.getProperties().getProperty(name);
        property = property.replace('\u00A0', ' ');
        return om.readValue(property, c);
    } catch (Exception e) {
        throw new IdentityConfigurationException("Couldn't load test identity " + name, e);
    }
}
Also used : IdentityConfigurationException(com.symphony.api.id.IdentityConfigurationException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IdentityConfigurationException(com.symphony.api.id.IdentityConfigurationException)

Aggregations

IdentityConfigurationException (com.symphony.api.id.IdentityConfigurationException)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 SymphonyIdentity (com.symphony.api.id.SymphonyIdentity)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)1 IdentityProperties (org.finos.symphony.toolkit.spring.api.properties.IdentityProperties)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnExpression (org.springframework.boot.autoconfigure.condition.ConditionalOnExpression)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1