use of com.adaptris.core.http.auth.ConfiguredUsernamePassword in project interlok by adaptris.
the class EmbeddedHttpConsumerTest method testBasicConsumeWorkflow_WithACL.
@Test
public void testBasicConsumeWorkflow_WithACL() throws Exception {
EmbeddedJettyHelper helper = new EmbeddedJettyHelper();
helper.startServer();
MockMessageProducer mockProducer = new MockMessageProducer();
EmbeddedConnection embedded = new EmbeddedConnection();
ConfigurableSecurityHandler csh = new ConfigurableSecurityHandler();
HashLoginServiceFactory hsl = new HashLoginServiceFactory("InterlokJetty", PROPERTIES.getProperty(HttpConsumerTest.JETTY_USER_REALM));
csh.setLoginService(hsl);
csh.setAuthenticator(new BasicAuthenticatorFactory());
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setMustAuthenticate(true);
securityConstraint.setRoles("user");
securityConstraint.setPaths(Arrays.asList("/"));
securityConstraint.setConstraintName(Constraint.__BASIC_AUTH);
csh.setSecurityConstraints(Arrays.asList(securityConstraint));
embedded.setSecurityHandler(csh);
Channel channel = JettyHelper.createChannel(embedded, JettyHelper.createConsumer(URL_TO_POST_TO), mockProducer);
try {
start(channel);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
msg.addMetadata(CONTENT_TYPE_METADATA_KEY, "text/xml");
httpProducer.setAuthenticator(new ConfiguredUsernamePassword("user", "password"));
httpProducer.setUrl(helper.createProduceDestination());
start(httpProducer);
AdaptrisMessage reply = httpProducer.request(msg);
assertEquals("Reply Payloads", XML_PAYLOAD, reply.getContent());
doAssertions(mockProducer);
} finally {
stop(httpProducer);
stop(channel);
helper.stopServer();
}
}
use of com.adaptris.core.http.auth.ConfiguredUsernamePassword in project interlok by adaptris.
the class HttpRequestServiceTest method buildAuthenticator.
protected static HttpAuthenticator buildAuthenticator(String username, String password) {
ConfiguredUsernamePassword auth = new ConfiguredUsernamePassword();
auth.setUsername(username);
auth.setPassword(password);
return auth;
}
Aggregations