org.apache.cxf.message.MessageImpl Java Examples
The following examples show how to use
org.apache.cxf.message.MessageImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncResponseImplTest.java From cxf with Apache License 2.0 | 6 votes |
/** * Test that creatinging an AsyncResponse with a null continuation throws * an IllegalArgumentException instead of a NullPointer Exception. */ @Test public void testNullContinutaion() { HttpServletRequest req = control.createMock(HttpServletRequest.class); AsyncContext asyncCtx = control.createMock(AsyncContext.class); Message msg = new MessageImpl(); msg.setExchange(new ExchangeImpl()); req.startAsync(); EasyMock.expectLastCall().andReturn(asyncCtx); control.replay(); AsyncResponse impl; try { impl = new AsyncResponseImpl(msg); } catch (IllegalArgumentException e) { assertEquals("Continuation not supported. " + "Please ensure that all servlets and servlet filters support async operations", e.getMessage()); return; } Assert.fail("Expected IllegalArgumentException, but instead got valid AsyncResponse, " + impl); }
Example #2
Source File: JAXBElementProviderTest.java From cxf with Apache License 2.0 | 6 votes |
private Message createMessage() { ServerProviderFactory factory = ServerProviderFactory.getInstance(); Message m = new MessageImpl(); m.put(Message.ENDPOINT_ADDRESS, "http://localhost:8080/bar"); m.put("org.apache.cxf.http.case_insensitive_queries", false); Exchange e = new ExchangeImpl(); m.setExchange(e); e.setInMessage(m); Endpoint endpoint = EasyMock.mock(Endpoint.class); EasyMock.expect(endpoint.getEndpointInfo()).andReturn(null).anyTimes(); EasyMock.expect(endpoint.get(Application.class.getName())).andReturn(null); EasyMock.expect(endpoint.size()).andReturn(0).anyTimes(); EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes(); EasyMock.expect(endpoint.get(ServerProviderFactory.class.getName())).andReturn(factory).anyTimes(); EasyMock.replay(endpoint); e.put(Endpoint.class, endpoint); return m; }
Example #3
Source File: WSS4JOutInterceptorTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testSignature() throws Exception { SOAPMessage saaj = readSAAJDocument("wsse-request-clean.xml"); WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(); PhaseInterceptor<SoapMessage> handler = ohandler.createEndingInterceptor(); SoapMessage msg = new SoapMessage(new MessageImpl()); Exchange ex = new ExchangeImpl(); ex.setInMessage(msg); msg.setContent(SOAPMessage.class, saaj); msg.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE); msg.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties"); msg.put(WSHandlerConstants.USER, "myAlias"); msg.put("password", "myAliasPassword"); handler.handleMessage(msg); SOAPPart doc = saaj.getSOAPPart(); assertValid("//wsse:Security", doc); assertValid("//wsse:Security/ds:Signature", doc); }
Example #4
Source File: DocLiteralInInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
private void setUpUsingDocLit() throws Exception { String ns = "http://apache.org/hello_world_doc_lit_bare"; WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass() .getResource("/wsdl/jaxb/doc_lit_bare.wsdl").toString(), new QName(ns, "SOAPService")); service = factory.create(); endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort")); endpoint = new EndpointImpl(bus, service, endpointInfo); JAXBDataBinding db = new JAXBDataBinding(); db.setContext(JAXBContext.newInstance(new Class[] {TradePriceData.class})); service.setDataBinding(db); operation = endpointInfo.getBinding().getOperation(new QName(ns, "SayHi")); operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(TradePriceData.class); operation.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(TradePriceData.class); message = new MessageImpl(); Exchange exchange = new ExchangeImpl(); message.setExchange(exchange); exchange.put(Service.class, service); exchange.put(Endpoint.class, endpoint); exchange.put(Binding.class, endpoint.getBinding()); }
Example #5
Source File: JAASLoginInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testLoginWithTlsHandler() { JAASLoginInterceptor jaasInt = createTestJaasLoginInterceptor(); CallbackHandlerTlsCert tlsHandler = new CallbackHandlerTlsCert(); tlsHandler.setFixedPassword(TestUserPasswordLoginModule.TESTPASS); CertKeyToUserNameMapper certMapper = new CertKeyToUserNameMapper(); certMapper.setKey("CN"); tlsHandler.setCertMapper(certMapper); jaasInt.setCallbackHandlerProviders(Collections.singletonList((CallbackHandlerProvider)tlsHandler)); Message message = new MessageImpl(); TLSSessionInfo sessionInfo = new TLSSessionInfo("", null, new Certificate[] { createTestCert(TEST_SUBJECT_DN) }); message.put(TLSSessionInfo.class, sessionInfo); jaasInt.handleMessage(message); }
Example #6
Source File: PersistenceUtils.java From cxf with Apache License 2.0 | 6 votes |
public static void encodeRMContent(RMMessage rmmsg, Message msg, InputStream msgContent) throws IOException { CachedOutputStream cos = new CachedOutputStream(); if (msg.getAttachments() == null) { rmmsg.setContentType((String)msg.get(Message.CONTENT_TYPE)); IOUtils.copyAndCloseInput(msgContent, cos); cos.flush(); rmmsg.setContent(cos); } else { MessageImpl msgImpl1 = new MessageImpl(); msgImpl1.setContent(OutputStream.class, cos); msgImpl1.setAttachments(msg.getAttachments()); msgImpl1.put(Message.CONTENT_TYPE, msg.get(Message.CONTENT_TYPE)); msgImpl1.setContent(InputStream.class, msgContent); AttachmentSerializer serializer = new AttachmentSerializer(msgImpl1); serializer.setXop(false); serializer.writeProlog(); // write soap root message into cached output stream IOUtils.copyAndCloseInput(msgContent, cos); cos.flush(); serializer.writeAttachments(); rmmsg.setContentType((String) msgImpl1.get(Message.CONTENT_TYPE)); rmmsg.setContent(cos); } }
Example #7
Source File: CorbaConduitTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testBuildReturn() throws Exception { Message msg = new MessageImpl(); CorbaMessage message = new CorbaMessage(msg); QName objName = new QName("returnName"); QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA); TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short); CorbaPrimitiveHandler obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null); CorbaStreamable arg = message.createStreamableObject(obj1, objName); CorbaConduit conduit = setupCorbaConduit(false); NamedValue ret = conduit.getReturn(message); assertNotNull("Return should not be null", ret != null); assertEquals("name should be equal", ret.name(), "return"); message.setStreamableReturn(arg); NamedValue ret2 = conduit.getReturn(message); assertNotNull("Return2 should not be null", ret2 != null); assertEquals("name should be equal", ret2.name(), "returnName"); }
Example #8
Source File: TransformTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void transformInboundInterceptorInputStream() { // Arrange Message message = new MessageImpl(); ByteArrayInputStream inputStream = new ByteArrayInputStream(ORIG_LOGGING_CONTENT.getBytes(StandardCharsets.UTF_8)); message.setContent(InputStream.class, inputStream); Exchange exchange = new ExchangeImpl(); message.setExchange(exchange); LogEventSenderMock logEventSender = new LogEventSenderMock(); LoggingInInterceptor interceptor = new TransformLoggingInInterceptor(logEventSender); // Act Collection<PhaseInterceptor<? extends Message>> interceptors = interceptor.getAdditionalInterceptors(); for (PhaseInterceptor intercept : interceptors) { intercept.handleMessage(message); } interceptor.handleMessage(message); // Verify LogEvent event = logEventSender.getLogEvent(); assertNotNull(event); assertEquals(TRANSFORMED_LOGGING_CONTENT, event.getPayload()); // only the first byte is read! }
Example #9
Source File: WSS4JOutInterceptorTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testSignature() throws Exception { SOAPMessage saaj = readSAAJDocument("wsse-request-clean.xml"); WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(); PhaseInterceptor<SoapMessage> handler = ohandler.createEndingInterceptor(); SoapMessage msg = new SoapMessage(new MessageImpl()); Exchange ex = new ExchangeImpl(); ex.setInMessage(msg); msg.setContent(SOAPMessage.class, saaj); msg.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE); msg.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties"); msg.put(WSHandlerConstants.USER, "myAlias"); msg.put("password", "myAliasPassword"); handler.handleMessage(msg); SOAPPart doc = saaj.getSOAPPart(); assertValid("//wsse:Security", doc); assertValid("//wsse:Security/ds:Signature", doc); }
Example #10
Source File: XSLTJaxbProviderTest.java From cxf with Apache License 2.0 | 6 votes |
private Message createMessage() { ProviderFactory factory = ServerProviderFactory.getInstance(); Message m = new MessageImpl(); m.put(Message.ENDPOINT_ADDRESS, "http://localhost:8080/bar"); m.put("org.apache.cxf.http.case_insensitive_queries", false); Exchange e = new ExchangeImpl(); m.setExchange(e); e.setInMessage(m); Endpoint endpoint = EasyMock.mock(Endpoint.class); EasyMock.expect(endpoint.getEndpointInfo()).andReturn(null).anyTimes(); EasyMock.expect(endpoint.get(Application.class.getName())).andReturn(null); EasyMock.expect(endpoint.size()).andReturn(0).anyTimes(); EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes(); EasyMock.expect(endpoint.get(ServerProviderFactory.class.getName())).andReturn(factory).anyTimes(); EasyMock.replay(endpoint); e.put(Endpoint.class, endpoint); return m; }
Example #11
Source File: STSTokenOutInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testBasicAsymmetricBinding() throws Exception { Bus bus = BusFactory.getThreadDefaultBus(); STSAuthParams authParams = new STSAuthParams( AuthMode.X509_ASSYMETRIC, null, "org.apache.cxf.systest.sts.common.CommonCallbackHandler", "mystskey", "clientKeystore.properties"); STSTokenOutInterceptor interceptor = new STSTokenOutInterceptor( authParams, "http://localhost:" + STSPORT2 + STS_X509_WSDL_LOCATION_RELATIVE, bus); MessageImpl message = prepareMessage(bus, null, SERVICE_ENDPOINT_ASSYMETRIC); interceptor.handleMessage(message); SecurityToken token = (SecurityToken)message.getExchange().get(SecurityConstants.TOKEN); validateSecurityToken(token); }
Example #12
Source File: HttpUtilsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testUpdatePath() { Message m = new MessageImpl(); m.setExchange(new ExchangeImpl()); m.put(Message.ENDPOINT_ADDRESS, "http://localhost/"); HttpUtils.updatePath(m, "/bar"); assertEquals("/bar", m.get(Message.REQUEST_URI)); HttpUtils.updatePath(m, "bar"); assertEquals("/bar", m.get(Message.REQUEST_URI)); HttpUtils.updatePath(m, "bar/"); assertEquals("/bar/", m.get(Message.REQUEST_URI)); m.put(Message.ENDPOINT_ADDRESS, "http://localhost"); HttpUtils.updatePath(m, "bar/"); assertEquals("/bar/", m.get(Message.REQUEST_URI)); }
Example #13
Source File: MAPAggregatorTest.java From cxf with Apache License 2.0 | 6 votes |
@Test(expected = SoapFault.class) public void testTwoWayRequestWithReplyToNone() throws Exception { Message message = new MessageImpl(); Exchange exchange = new ExchangeImpl(); exchange.setOutMessage(message); message.setExchange(exchange); setUpMessageProperty(message, REQUESTOR_ROLE, Boolean.FALSE); AddressingProperties maps = new AddressingProperties(); EndpointReferenceType replyTo = new EndpointReferenceType(); replyTo.setAddress(ContextUtils.getAttributedURI(Names.WSA_NONE_ADDRESS)); maps.setReplyTo(replyTo); AttributedURIType id = ContextUtils.getAttributedURI("urn:uuid:12345"); maps.setMessageID(id); maps.setAction(ContextUtils.getAttributedURI("")); setUpMessageProperty(message, ADDRESSING_PROPERTIES_OUTBOUND, maps); setUpMessageProperty(message, "org.apache.cxf.ws.addressing.map.fault.name", "NoneAddress"); aggregator.mediate(message, false); }
Example #14
Source File: JAXRSUtilsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testHttpContextParametersFromInterface() throws Exception { ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true); Method methodToInvoke = Customer.class.getMethod("setUriInfoContext", new Class[]{UriInfo.class}); OperationResourceInfo ori = new OperationResourceInfo(methodToInvoke, AnnotationUtils.getAnnotatedMethod(Customer.class, methodToInvoke), cri); ori.setHttpMethod("GET"); Message m = new MessageImpl(); List<Object> params = JAXRSUtils.processParameters(ori, new MetadataMap<String, String>(), m); assertEquals("1 parameters expected", 1, params.size()); assertSame(UriInfoImpl.class, params.get(0).getClass()); }
Example #15
Source File: AuthPolicyValidatingInterceptorTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testValidateAuthorizationPolicy() throws Exception { AuthPolicyValidatingInterceptor in = new AuthPolicyValidatingInterceptor(); TestSTSTokenValidator validator = new TestSTSTokenValidator(); in.setValidator(validator); AuthorizationPolicy policy = new AuthorizationPolicy(); policy.setUserName("bob"); policy.setPassword("pswd"); Message message = new MessageImpl(); message.put(AuthorizationPolicy.class, policy); in.handleMessage(message); assertTrue(validator.isValidated()); }
Example #16
Source File: EHCacheTokenStoreTest.java From steady with Apache License 2.0 | 5 votes |
@BeforeClass public static void init() { TokenStoreFactory tokenStoreFactory = new EHCacheTokenStoreFactory(); Message message = new MessageImpl(); message.put( SecurityConstants.CACHE_CONFIG_FILE, ClassLoaderUtils.getResource("cxf-ehcache.xml", EHCacheTokenStoreTest.class) ); message.setExchange(new ExchangeImpl()); store = tokenStoreFactory.newTokenStore(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, message); }
Example #17
Source File: XACMLRequestBuilderTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testEnvironment() throws Exception { // Mock up a request Principal principal = new Principal() { public String getName() { return "alice"; } }; String operation = "{http://www.example.org/contract/DoubleIt}DoubleIt"; MessageImpl msg = new MessageImpl(); msg.put(Message.WSDL_OPERATION, QName.valueOf(operation)); String service = "{http://www.example.org/contract/DoubleIt}DoubleItService"; msg.put(Message.WSDL_SERVICE, QName.valueOf(service)); String resourceURL = "https://localhost:8080/doubleit"; msg.put(Message.REQUEST_URL, resourceURL); XACMLRequestBuilder builder = new DefaultXACMLRequestBuilder(); RequestType request = builder.createRequest(principal, Collections.singletonList("manager"), msg); assertNotNull(request); assertFalse(request.getEnvironment().getAttributes().isEmpty()); ((DefaultXACMLRequestBuilder)builder).setSendDateTime(false); request = builder.createRequest(principal, Collections.singletonList("manager"), msg); assertNotNull(request); assertTrue(request.getEnvironment().getAttributes().isEmpty()); }
Example #18
Source File: SearchContextImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testPlainQuery4() { Message m = new MessageImpl(); m.put("search.use.plain.queries", true); m.put(Message.QUERY_STRING, "a=b&a=b2&c=d&f=g"); String exp = new SearchContextImpl(m).getSearchExpression(); assertEquals("((a==b,a==b2);c==d;f==g)", exp); }
Example #19
Source File: SAMLTokenValidatorTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(STSConstants.STATUS); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setTokenStore(tokenStore); return parameters; }
Example #20
Source File: JWTTokenValidatorTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(STSConstants.STATUS); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setTokenStore(tokenStore); return parameters; }
Example #21
Source File: WSPolicyFeature.java From cxf with Apache License 2.0 | 5 votes |
private MessageImpl createMessage(Endpoint e, Bus b) { MessageImpl m = new MessageImpl(); Exchange ex = new ExchangeImpl(); m.setExchange(ex); ex.put(Endpoint.class, e); ex.put(Bus.class, b); ex.put(Service.class, e.getService()); return m; }
Example #22
Source File: XACMLRequestBuilderTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testRESTResource() throws Exception { // Mock up a request Principal principal = new Principal() { public String getName() { return "alice"; } }; MessageImpl msg = new MessageImpl(); String resourceURL = "https://localhost:8080/doubleit"; msg.put(Message.REQUEST_URL, resourceURL); XACMLRequestBuilder builder = new DefaultXACMLRequestBuilder(); RequestType request = builder.createRequest(principal, Collections.singletonList("manager"), msg); assertNotNull(request); List<ResourceType> resources = request.getResources(); assertNotNull(resources); assertEquals(1, resources.size()); ResourceType resource = resources.get(0); assertEquals(1, resource.getAttributes().size()); for (AttributeType attribute : resource.getAttributes()) { String attributeValue = attribute.getAttributeValues().get(0).getValue(); assertEquals(attributeValue, resourceURL); } }
Example #23
Source File: RequestResponseTest.java From cxf with Apache License 2.0 | 5 votes |
private void sendAndReceiveMessages(EndpointInfo ei, boolean synchronous) throws IOException, InterruptedException { // set up the conduit send to be true JMSConduit conduit = setupJMSConduitWithObserver(ei); final Message outMessage = createMessage(); final JMSDestination destination = setupJMSDestination(ei); MessageObserver observer = new MessageObserver() { public void onMessage(Message m) { Exchange exchange = new ExchangeImpl(); exchange.setInMessage(m); m.setExchange(exchange); verifyReceivedMessage(m); verifyHeaders(m, outMessage); // setup the message for try { Conduit backConduit = destination.getBackChannel(m); // wait for the message to be got from the conduit Message replyMessage = new MessageImpl(); sendOneWayMessage(backConduit, replyMessage); } catch (Exception e) { throw new RuntimeException(e); } } }; destination.setMessageObserver(observer); try { sendMessage(conduit, outMessage, synchronous); // wait for the message to be got from the destination, // create the thread to handler the Destination incoming message verifyReceivedMessage(waitForReceiveInMessage()); } finally { conduit.close(); destination.shutdown(); } }
Example #24
Source File: SAMLProviderKeyTypeTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenProviderParameters createProviderParameters( String tokenType, String keyType ) throws WSSecurityException { TokenProviderParameters parameters = new TokenProviderParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); tokenRequirements.setTokenType(tokenType); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); keyRequirements.setKeyType(keyType); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); parameters.setAppliesToAddress("http://dummy-service.com/dummy"); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setEncryptionProperties(new EncryptionProperties()); return parameters; }
Example #25
Source File: HTTPConduitTest.java From cxf with Apache License 2.0 | 5 votes |
/** * Generates a new message. */ private Message getNewMessage() throws Exception { Message message = new MessageImpl(); Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); List<String> contentTypes = new ArrayList<>(); contentTypes.add("text/xml"); contentTypes.add("charset=utf8"); headers.put("content-type", contentTypes); message.put(Message.PROTOCOL_HEADERS, headers); return message; }
Example #26
Source File: ClientImpl.java From cxf with Apache License 2.0 | 5 votes |
public Conduit getConduit() { Message message = new MessageImpl(); Exchange exchange = new ExchangeImpl(); message.setExchange(exchange); message.putAll(getRequestContext()); setExchangeProperties(exchange, getEndpoint(), null); return getConduitSelector().selectConduit(message); }
Example #27
Source File: SAMLTokenRenewerTest.java From cxf with Apache License 2.0 | 5 votes |
private TokenValidatorParameters createValidatorParameters() throws WSSecurityException { TokenValidatorParameters parameters = new TokenValidatorParameters(); TokenRequirements tokenRequirements = new TokenRequirements(); parameters.setTokenRequirements(tokenRequirements); KeyRequirements keyRequirements = new KeyRequirements(); parameters.setKeyRequirements(keyRequirements); parameters.setPrincipal(new CustomTokenPrincipal("alice")); // Mock up message context MessageImpl msg = new MessageImpl(); WrappedMessageContext msgCtx = new WrappedMessageContext(msg); parameters.setMessageContext(msgCtx); // Add STSProperties object StaticSTSProperties stsProperties = new StaticSTSProperties(); Crypto crypto = CryptoFactory.getInstance(getEncryptionProperties()); stsProperties.setEncryptionCrypto(crypto); stsProperties.setSignatureCrypto(crypto); stsProperties.setEncryptionUsername("myservicekey"); stsProperties.setSignatureUsername("mystskey"); stsProperties.setCallbackHandler(new PasswordCallbackHandler()); stsProperties.setIssuer("STS"); parameters.setStsProperties(stsProperties); parameters.setTokenStore(tokenStore); return parameters; }
Example #28
Source File: JaxwsClientCallbackTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testHandleCancellationCallbackWhenStarted() throws Exception { callback.start(new MessageImpl()); assertThat(callback.cancel(true), equalTo(false)); assertThat(callback.isCancelled(), equalTo(false)); assertThat(callback.isDone(), equalTo(false)); }
Example #29
Source File: MessageVerifierTest.java From cxf with Apache License 2.0 | 5 votes |
@Test(expected = InvalidDataToVerifySignatureException.class) public void requiredHeaderPresentButNotSigned() throws IOException { Map<String, List<String>> headers = createMockHeaders(); createAndAddSignature(headers); headers.put("Test", Collections.singletonList("value")); MessageVerifier headerVerifier = new MessageVerifier(keyId -> keyPair.getPublic(), Collections.singletonList("test")); headerVerifier.setAddDefaultRequiredHeaders(false); headerVerifier.setSecurityProvider(new MockSecurityProvider()); headerVerifier.setAlgorithmProvider(new MockAlgorithmProvider()); headerVerifier.verifyMessage(headers, METHOD, URI, new MessageImpl()); }
Example #30
Source File: CacheControlHeaderProviderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test(expected = InternalServerErrorException.class) public void testInvalidSeparator() { CacheControlHeaderProvider cp = new CacheControlHeaderProvider() { protected Message getCurrentMessage() { Message m = new MessageImpl(); m.put(CacheControlHeaderProvider.CACHE_CONTROL_SEPARATOR_PROPERTY, "(e+)+"); return m; } }; cp.fromString("no-store"); }