Search in sources :

Example 96 with MessageImpl

use of org.apache.cxf.message.MessageImpl in project cxf by apache.

the class DefaultLogEventMapperTest method testUriValue.

/**
 * Test for address concatenation in CXF-8127
 */
@Test
public void testUriValue() {
    DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    Message message = new MessageImpl();
    message.put(Message.ENDPOINT_ADDRESS, "http://localhost:9001/");
    message.put(Message.REQUEST_URI, "/api");
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    LogEvent event = mapper.map(message, Collections.emptySet());
    assertEquals("http://localhost:9001/api", event.getAddress());
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) DefaultLogEventMapper(org.apache.cxf.ext.logging.event.DefaultLogEventMapper) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 97 with MessageImpl

use of org.apache.cxf.message.MessageImpl in project cxf by apache.

the class DefaultLogEventMapperTest method testRest.

@Test
public void testRest() {
    DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    Message message = new MessageImpl();
    message.put(Message.HTTP_REQUEST_METHOD, "GET");
    message.put(Message.REQUEST_URI, "test");
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    LogEvent event = mapper.map(message, Collections.emptySet());
    assertEquals("GET[test]", event.getOperationName());
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) DefaultLogEventMapper(org.apache.cxf.ext.logging.event.DefaultLogEventMapper) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 98 with MessageImpl

use of org.apache.cxf.message.MessageImpl in project cxf by apache.

the class DefaultLogEventMapperTest method shouldMaskHeaders.

@Test
public void shouldMaskHeaders() {
    final DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    final Message message = new MessageImpl();
    message.put(Message.ENDPOINT_ADDRESS, "http://localhost:9001/");
    message.put(Message.REQUEST_URI, "/api");
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    final Map<String, Object> headers = new HashMap<>();
    headers.put(TEST_HEADER_NAME, Arrays.asList(TEST_HEADER_VALUE));
    final Set<String> sensitiveHeaders = new HashSet<>();
    sensitiveHeaders.add(TEST_HEADER_NAME);
    message.put(Message.PROTOCOL_HEADERS, headers);
    LogEvent event = mapper.map(message, sensitiveHeaders);
    assertEquals(MASKED_HEADER_VALUE, event.getHeaders().get(TEST_HEADER_NAME));
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) HashMap(java.util.HashMap) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) DefaultLogEventMapper(org.apache.cxf.ext.logging.event.DefaultLogEventMapper) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 99 with MessageImpl

use of org.apache.cxf.message.MessageImpl in project cxf by apache.

the class MaskSensitiveHelperTest method prepareInMessage.

private Message prepareInMessage() {
    Message message = new MessageImpl();
    ByteArrayInputStream inputStream = new ByteArrayInputStream(loggingContent.getBytes(StandardCharsets.UTF_8));
    message.put(Message.CONTENT_TYPE, contentType);
    message.setContent(InputStream.class, inputStream);
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    return message;
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) ByteArrayInputStream(java.io.ByteArrayInputStream) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 100 with MessageImpl

use of org.apache.cxf.message.MessageImpl in project cxf by apache.

the class MaskSensitiveHelperTest method prepareOutMessage.

private Message prepareOutMessage() {
    Message message = new MessageImpl();
    message.put(Message.CONTENT_TYPE, contentType);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    message.setContent(OutputStream.class, outputStream);
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    return message;
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Aggregations

MessageImpl (org.apache.cxf.message.MessageImpl)610 Message (org.apache.cxf.message.Message)291 Test (org.junit.Test)290 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)193 WrappedMessageContext (org.apache.cxf.jaxws.context.WrappedMessageContext)152 Exchange (org.apache.cxf.message.Exchange)148 StaticSTSProperties (org.apache.cxf.sts.StaticSTSProperties)137 PasswordCallbackHandler (org.apache.cxf.sts.common.PasswordCallbackHandler)115 Crypto (org.apache.wss4j.common.crypto.Crypto)113 CustomTokenPrincipal (org.apache.wss4j.common.principal.CustomTokenPrincipal)107 JAXBElement (javax.xml.bind.JAXBElement)100 RequestSecurityTokenType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType)93 RequestSecurityTokenResponseType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType)86 STSPropertiesMBean (org.apache.cxf.sts.STSPropertiesMBean)83 Element (org.w3c.dom.Element)74 ArrayList (java.util.ArrayList)62 ServiceMBean (org.apache.cxf.sts.service.ServiceMBean)61 StaticService (org.apache.cxf.sts.service.StaticService)61 Principal (java.security.Principal)59 Endpoint (org.apache.cxf.endpoint.Endpoint)58