Search in sources :

Example 1 with ForceDisconnectException

use of com.newrelic.agent.ForceDisconnectException in project newrelic-java-agent by newrelic.

the class DataSenderImpl method connect.

@Override
public Map<String, Object> connect(Map<String, Object> startupOptions) throws Exception {
    String redirectHost = parsePreconnectAndReturnHost();
    if (redirectHost != null) {
        this.redirectHost = redirectHost;
        logger.info(MessageFormat.format("Collector redirection to {0}:{1}", this.redirectHost, Integer.toString(port)));
    } else if (configService.getDefaultAgentConfig().laspEnabled()) {
        throw new ForceDisconnectException("The agent did not receive one or more security policies that it expected and will shut down." + " Please contact support.");
    }
    return doConnect(startupOptions);
}
Also used : ForceDisconnectException(com.newrelic.agent.ForceDisconnectException)

Example 2 with ForceDisconnectException

use of com.newrelic.agent.ForceDisconnectException in project newrelic-java-agent by newrelic.

the class LaspPoliciesConfigTest method missingKnownPolicies.

@Test
public void missingKnownPolicies() throws ParseException {
    String policiesString = "{" + "\"custom_events\":            { \"enabled\": true, \"required\": false }}";
    JSONObject policiesJson = createPolicies(policiesString);
    try {
        LaspPolicies.validatePolicies(policiesJson);
        fail();
    } catch (ForceDisconnectException ex) {
    }
}
Also used : ForceDisconnectException(com.newrelic.agent.ForceDisconnectException) JSONObject(org.json.simple.JSONObject) Test(org.junit.Test)

Example 3 with ForceDisconnectException

use of com.newrelic.agent.ForceDisconnectException in project newrelic-java-agent by newrelic.

the class LaspPoliciesConfigTest method emptyList.

@Test
public void emptyList() throws ParseException, ForceDisconnectException {
    try {
        LaspPolicies.validatePolicies(new JSONObject());
        fail();
    } catch (ForceDisconnectException ex) {
    }
}
Also used : ForceDisconnectException(com.newrelic.agent.ForceDisconnectException) JSONObject(org.json.simple.JSONObject) Test(org.junit.Test)

Example 4 with ForceDisconnectException

use of com.newrelic.agent.ForceDisconnectException in project newrelic-java-agent by newrelic.

the class LaspPoliciesConfigTest method knownRequired.

@Test
public void knownRequired() throws ParseException, ForceDisconnectException {
    String policiesString = "{" + "\"record_sql\":                    { \"enabled\": false, \"required\": true },\n" + "\"attributes_include\":            { \"enabled\": false, \"required\": true },\n" + "\"allow_raw_exception_messages\":  { \"enabled\": false, \"required\": true },\n" + "\"custom_events\":                 { \"enabled\": false, \"required\": true },\n" + "\"custom_parameters\":             { \"enabled\": false, \"required\": true },\n" + "\"custom_instrumentation_editor\": { \"enabled\": false, \"required\": true },\n" + "\"message_parameters\":            { \"enabled\": false, \"required\": true },\n" + "\"attributes_include\":            { \"enabled\": false, \"required\": true }}";
    JSONObject policiesJson = createPolicies(policiesString);
    try {
        LaspPolicies.validatePolicies(policiesJson);
    } catch (ForceDisconnectException ex) {
        fail();
    }
}
Also used : ForceDisconnectException(com.newrelic.agent.ForceDisconnectException) JSONObject(org.json.simple.JSONObject) Test(org.junit.Test)

Example 5 with ForceDisconnectException

use of com.newrelic.agent.ForceDisconnectException in project newrelic-java-agent by newrelic.

the class LaspHighSecurityTest method laspAndHsmEnabled.

@Test
public void laspAndHsmEnabled() throws ConfigurationException {
    Map<String, Object> settings = createSecurityProps();
    ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(settings);
    ServiceManager serviceManager = new MockServiceManager(configService);
    ServiceFactory.setServiceManager(serviceManager);
    AgentConfig agentConfig = AgentConfigFactory.createAgentConfig(settings, null, null);
    assertTrue(agentConfig.laspEnabled());
    assertTrue(agentConfig.isHighSecurity());
    try {
        ConfigServiceFactory.validateConfig(agentConfig);
        fail();
    } catch (ForceDisconnectException ex) {
    }
}
Also used : ForceDisconnectException(com.newrelic.agent.ForceDisconnectException) ServiceManager(com.newrelic.agent.service.ServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) Test(org.junit.Test)

Aggregations

ForceDisconnectException (com.newrelic.agent.ForceDisconnectException)9 JSONObject (org.json.simple.JSONObject)7 Test (org.junit.Test)7 MockServiceManager (com.newrelic.agent.MockServiceManager)1 ServiceManager (com.newrelic.agent.service.ServiceManager)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1