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);
}
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) {
}
}
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) {
}
}
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();
}
}
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) {
}
}
Aggregations