Java Code Examples for org.apache.cxf.message.Message
The following examples show how to use
org.apache.cxf.message.Message. These examples are extracted from open source projects.
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 Project: steady Source File: HttpsTokenInterceptorProvider.java License: Apache License 2.0 | 7 votes |
public void handleMessage(Message message) throws Fault { AssertionInfoMap aim = message.get(AssertionInfoMap.class); // extract Assertion information if (aim != null) { Collection<AssertionInfo> ais = aim.get(SP12Constants.HTTPS_TOKEN); if (ais == null) { return; } if (isRequestor(message)) { assertHttps(ais, message); } else { //server side should be checked on the way in for (AssertionInfo ai : ais) { ai.setAsserted(true); } } } }
Example 2
Source Project: steady Source File: CryptoCoverageCheckerTest.java License: Apache License 2.0 | 6 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); lst.add(new CryptoCoverageChecker()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker")); }
Example 3
Source Project: cxf Source File: ResponseTimeMessageInInterceptorTest.java License: Apache License 2.0 | 6 votes |
@Test public void testServiceMessageIn() { setupCounterRepository(true, false); setupExchangeForMessage(); EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes(); EasyMock.expect(message.getExchange()).andReturn(exchange); EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null); EasyMock.expect(exchange.getOutMessage()).andReturn(message); EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(null); exchange.put(EasyMock.eq(MessageHandlingTimeRecorder.class), EasyMock.isA(MessageHandlingTimeRecorder.class)); EasyMock.replay(exchange); EasyMock.replay(message); rtmii.handleMessage(message); EasyMock.verify(message); EasyMock.verify(exchange); }
Example 4
Source Project: cxf Source File: AhcWebSocketConduit.java License: Apache License 2.0 | 6 votes |
@Override protected void setupConnection(Message message, Address address, HTTPClientPolicy csPolicy) throws IOException { URI currentURL = address.getURI(); String s = currentURL.getScheme(); if (!"ws".equals(s) && !"wss".equals(s)) { throw new MalformedURLException("unknown protocol: " + s); } message.put("http.scheme", currentURL.getScheme()); String httpRequestMethod = (String)message.get(Message.HTTP_REQUEST_METHOD); if (httpRequestMethod == null) { httpRequestMethod = "POST"; message.put(Message.HTTP_REQUEST_METHOD, httpRequestMethod); } final AhcWebSocketConduitRequest request = new AhcWebSocketConduitRequest(currentURL, httpRequestMethod); final int rtimeout = determineReceiveTimeout(message, csPolicy); request.setReceiveTimeout(rtimeout); message.put(AhcWebSocketConduitRequest.class, request); }
Example 5
Source Project: cxf Source File: AbstractHTTPDestination.java License: Apache License 2.0 | 6 votes |
@Override public String getId(Map<String, Object> context) { String id = null; if (isMultiplexWithAddress()) { String address = (String)context.get(Message.PATH_INFO); if (null != address) { int afterLastSlashIndex = address.lastIndexOf('/') + 1; if (afterLastSlashIndex > 0 && afterLastSlashIndex < address.length()) { id = address.substring(afterLastSlashIndex); } } else { getLogger().log(Level.WARNING, new org.apache.cxf.common.i18n.Message( "MISSING_PATH_INFO", LOG).toString()); } } else { return super.getId(context); } return id; }
Example 6
Source Project: cxf Source File: JAXRSUtilsTest.java License: Apache License 2.0 | 6 votes |
@Test public void testQueryParameter() throws Exception { Message messageImpl = createMessage(); ProviderFactory.getInstance(messageImpl).registerUserProvider( new GenericObjectParameterHandler()); Class<?>[] argType = {Query.class}; Method m = Customer.class.getMethod("testGenericObjectParam", argType); messageImpl.put(Message.QUERY_STRING, "p1=thequery"); List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, new ClassResourceInfo(Customer.class)), null, messageImpl); assertEquals(1, params.size()); @SuppressWarnings("unchecked") Query<String> query = (Query<String>)params.get(0); assertEquals("thequery", query.getEntity()); }
Example 7
Source Project: steady Source File: IssuedTokenInterceptorProvider.java License: Apache License 2.0 | 6 votes |
static final TokenStore createTokenStore(Message message) { EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo(); synchronized (info) { TokenStore tokenStore = (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE); if (tokenStore == null) { tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE); } if (tokenStore == null) { TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance(); String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE; if (info.getName() != null) { cacheKey += "-" + info.getName().toString().hashCode(); } tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message); info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore); } return tokenStore; } }
Example 8
Source Project: cxf Source File: CryptoCoverageCheckerTest.java License: Apache License 2.0 | 6 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); lst.add(new CryptoCoverageChecker()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker")); }
Example 9
Source Project: cxf Source File: JAXRSUtilsTest.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testContextAnnotationOnMethod() throws Exception { ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true); Customer c = new Customer(); cri.setResourceProvider(new SingletonResourceProvider(c)); InjectionUtils.injectContextProxies(cri, cri.getResourceProvider().getInstance(null)); OperationResourceInfo ori = new OperationResourceInfo(Customer.class.getMethods()[0], cri); Message message = createMessage(); InjectionUtils.injectContextMethods(c, ori.getClassResourceInfo(), message); assertNotNull(c.getUriInfo()); assertSame(ThreadLocalUriInfo.class, c.getUriInfo().getClass()); assertSame(UriInfoImpl.class, ((ThreadLocalProxy<UriInfo>)c.getUriInfo()).get().getClass()); assertSame(ThreadLocalServletConfig.class, c.getSuperServletConfig().getClass()); assertSame(ThreadLocalHttpServletRequest.class, c.getHttpServletRequest().getClass()); }
Example 10
Source Project: cxf Source File: RMInInterceptorTest.java License: Apache License 2.0 | 6 votes |
private void testHandleSequenceAck(boolean onServer) throws SequenceFault, RMException, NoSuchMethodException { Method m = RMInInterceptor.class.getDeclaredMethod("processAcknowledgments", new Class[] {RMEndpoint.class, RMProperties.class, ProtocolVariation.class}); interceptor = EasyMock.createMockBuilder(RMInInterceptor.class) .addMockedMethod(m).createMock(control); Message message = setupInboundMessage(RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION, onServer); rme.receivedControlMessage(); EasyMock.expectLastCall(); interceptor.processAcknowledgments(rme, rmps, ProtocolVariation.RM10WSA200408); EasyMock.expectLastCall(); EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null); control.replay(); interceptor.handle(message); }
Example 11
Source Project: cxf Source File: JwkUtils.java License: Apache License 2.0 | 6 votes |
public static JsonWebKeys loadJwkSet(Message m, Properties props, PrivateKeyPasswordProvider cb) { String key = (String)props.get(JoseConstants.RSSEC_KEY_STORE_FILE); JsonWebKeys jwkSet = null; if (key != null && m != null) { Object jwkSetProp = m.getExchange().get(key); if (jwkSetProp != null && !(jwkSetProp instanceof JsonWebKeys)) { throw new JwkException("Unexpected key store class: " + jwkSetProp.getClass().getName()); } else { jwkSet = (JsonWebKeys)jwkSetProp; } } if (jwkSet == null) { jwkSet = loadJwkSet(props, m != null ? m.getExchange().getBus() : null, cb); if (key != null && m != null) { m.getExchange().put(key, jwkSet); } } return jwkSet; }
Example 12
Source Project: cxf Source File: OpenTracingTracingTest.java License: Apache License 2.0 | 6 votes |
private static BookStoreService createJaxWsService(final Map<String, List<String>> headers, final Feature feature) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.setServiceClass(BookStoreService.class); factory.setAddress("http://localhost:" + PORT + "/BookStore"); if (feature != null) { factory.getFeatures().add(feature); } final BookStoreService service = (BookStoreService) factory.create(); final Client proxy = ClientProxy.getClient(service); proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers); return service; }
Example 13
Source Project: steady Source File: KerberosTokenInterceptorProvider.java License: Apache License 2.0 | 6 votes |
static final TokenStore getTokenStore(Message message) { EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo(); synchronized (info) { TokenStore tokenStore = (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE); if (tokenStore == null) { tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE); } if (tokenStore == null) { TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance(); String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE; if (info.getName() != null) { cacheKey += "-" + info.getName().toString().hashCode(); } tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message); info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore); } return tokenStore; } }
Example 14
Source Project: cxf Source File: JAXRSUtilsTest.java License: Apache License 2.0 | 6 votes |
@Test public void testPerRequestContextFields() throws Exception { ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true); cri.setResourceProvider(new PerRequestResourceProvider(Customer.class)); OperationResourceInfo ori = new OperationResourceInfo(Customer.class.getMethod("postConstruct", new Class[]{}), cri); Customer c = new Customer(); Message m = createMessage(); m.put(Message.PROTOCOL_HEADERS, new HashMap<String, List<String>>()); HttpServletResponse response = EasyMock.createMock(HttpServletResponse.class); m.put(AbstractHTTPDestination.HTTP_RESPONSE, response); InjectionUtils.injectContextFields(c, ori.getClassResourceInfo(), m); assertSame(UriInfoImpl.class, c.getUriInfo2().getClass()); assertSame(HttpHeadersImpl.class, c.getHeaders().getClass()); assertSame(RequestImpl.class, c.getRequest().getClass()); assertSame(SecurityContextImpl.class, c.getSecurityContext().getClass()); assertSame(ProvidersImpl.class, c.getBodyWorkers().getClass()); }
Example 15
Source Project: cxf Source File: AbstractSupportingTokenPolicyValidator.java License: Apache License 2.0 | 6 votes |
/** * Validate (SignedParts|SignedElements|EncryptedParts|EncryptedElements) policies of this * SupportingToken. */ private boolean validateSignedEncryptedPolicies(List<WSSecurityEngineResult> tokenResults, List<WSSecurityEngineResult> signedResults, List<WSSecurityEngineResult> encryptedResults, Message message) { if (!validateSignedEncryptedParts(signedParts, false, signedResults, tokenResults, message)) { return false; } if (!validateSignedEncryptedParts(encryptedParts, true, encryptedResults, tokenResults, message)) { return false; } if (!validateSignedEncryptedElements(signedElements, signedResults, tokenResults, message)) { return false; } return validateSignedEncryptedElements(encryptedElements, encryptedResults, tokenResults, message); }
Example 16
Source Project: cxf Source File: FormUtils.java License: Apache License 2.0 | 6 votes |
private static void checkNumberOfParts(Message m, int numberOfParts) { if (m == null || m.getExchange() == null || m.getExchange().getInMessage() == null) { return; } String maxPartsCountProp = (String)m.getExchange() .getInMessage().getContextualProperty(MAX_FORM_PARAM_COUNT); if (maxPartsCountProp == null) { return; } try { int maxPartsCount = Integer.parseInt(maxPartsCountProp); if (maxPartsCount != -1 && numberOfParts >= maxPartsCount) { throw new WebApplicationException(413); } } catch (NumberFormatException ex) { throw ExceptionUtils.toInternalServerErrorException(ex, null); } }
Example 17
Source Project: cxf Source File: NettyHttpDestinationTest.java License: Apache License 2.0 | 6 votes |
private void verifyRequestHeaders() throws Exception { Map<String, List<String>> requestHeaders = CastUtils.cast((Map<?, ?>)inMessage.get(Message.PROTOCOL_HEADERS)); assertNotNull("expected request headers", requestHeaders); List<String> values = requestHeaders.get("content-type"); assertNotNull("expected field", values); assertEquals("unexpected values", 2, values.size()); assertTrue("expected value", values.contains("text/xml")); assertTrue("expected value", values.contains("charset=utf8")); values = requestHeaders.get(AUTH_HEADER); assertNotNull("expected field", values); assertEquals("unexpected values", 1, values.size()); assertTrue("expected value", values.contains(BASIC_AUTH)); AuthorizationPolicy authpolicy = inMessage.get(AuthorizationPolicy.class); assertNotNull("Expected some auth tokens", policy); assertEquals("expected user", USER, authpolicy.getUserName()); assertEquals("expected passwd", PASSWD, authpolicy.getPassword()); }
Example 18
Source Project: cxf Source File: CorbaServerConduitTest.java License: Apache License 2.0 | 6 votes |
protected CorbaServerConduit setupCorbaServerConduit(boolean send) { target = EasyMock.createMock(EndpointReferenceType.class); endpointInfo = EasyMock.createMock(EndpointInfo.class); CorbaServerConduit corbaServerConduit = new CorbaServerConduit(endpointInfo, target, targetObject, null, orbConfig, corbaTypeMap); if (send) { // setMessageObserver observer = new MessageObserver() { public void onMessage(Message m) { inMessage = m; } }; corbaServerConduit.setMessageObserver(observer); } return corbaServerConduit; }
Example 19
Source Project: cxf Source File: MAPAggregatorImpl.java License: Apache License 2.0 | 6 votes |
/** * Set up the decoupled Destination if necessary. */ private Destination setUpDecoupledDestination(Bus bus, String replyToAddress, Message message) { EndpointReferenceType reference = EndpointReferenceUtils.getEndpointReference(replyToAddress); if (reference != null) { String decoupledAddress = reference.getAddress().getValue(); LOG.info("creating decoupled endpoint: " + decoupledAddress); try { Destination dest = getDestination(bus, replyToAddress, message); bus.getExtension(ClientLifeCycleManager.class).registerListener(DECOUPLED_DEST_CLEANER); return dest; } catch (Exception e) { // REVISIT move message to localizable Messages.properties LOG.log(Level.WARNING, "decoupled endpoint creation failed: ", e); } } return null; }
Example 20
Source Project: cxf Source File: AbstractSecurityPolicyValidator.java License: Apache License 2.0 | 6 votes |
/** * Check to see if a token is required or not. * @param token the token * @param message The message * @return true if the token is required */ protected boolean isTokenRequired( AbstractToken token, Message message ) { IncludeTokenType inclusion = token.getIncludeTokenType(); if (inclusion == IncludeTokenType.INCLUDE_TOKEN_NEVER) { return false; } else if (inclusion == IncludeTokenType.INCLUDE_TOKEN_ALWAYS) { return true; } else { boolean initiator = MessageUtils.isRequestor(message); if (initiator && (inclusion == IncludeTokenType.INCLUDE_TOKEN_ALWAYS_TO_INITIATOR)) { return true; } else if (!initiator && (inclusion == IncludeTokenType.INCLUDE_TOKEN_ONCE || inclusion == IncludeTokenType.INCLUDE_TOKEN_ALWAYS_TO_RECIPIENT)) { return true; } return false; } }
Example 21
Source Project: cxf Source File: AbstractOutDatabindingInterceptor.java License: Apache License 2.0 | 6 votes |
protected boolean writeToOutputStream(Message m, BindingInfo info, Service s) { /** * Yes, all this code is EXTREMELY ugly. But it gives about a 60-70% performance * boost with the JAXB RI, so its worth it. */ if (s == null) { return false; } String enc = (String)m.get(Message.ENCODING); return "org.apache.cxf.binding.soap.model.SoapBindingInfo".equals(info.getClass().getName()) && "org.apache.cxf.jaxb.JAXBDataBinding".equals(s.getDataBinding().getClass().getName()) && !MessageUtils.isDOMPresent(m) && (enc == null || StandardCharsets.UTF_8.name().equals(enc)); }
Example 22
Source Project: steady Source File: SecureConversationInInterceptor.java License: Apache License 2.0 | 5 votes |
private void unmapSecurityProps(Message message) { Exchange ex = message.getExchange(); for (String s : SecurityConstants.ALL_PROPERTIES) { Object v = message.getContextualProperty(s + ".sct"); if (v != null) { ex.put(s, v); } } }
Example 23
Source Project: cxf Source File: ProviderFactoryTest.java License: Apache License 2.0 | 5 votes |
@Test public void testCreateMessageBodyReaderInterceptorWithFaultMessage() throws Exception { ServerProviderFactory spf = ServerProviderFactory.getInstance(); final Message message = prepareFaultMessage(MediaType.APPLICATION_XML, MediaType.APPLICATION_XML); List<ReaderInterceptor> interceptors = spf.createMessageBodyReaderInterceptor(Book.class, Book.class, new Annotation[0], MediaType.APPLICATION_XML_TYPE, message, true, null); assertSame(1, interceptors.size()); }
Example 24
Source Project: cxf Source File: AnnotationInterceptorTest.java License: Apache License 2.0 | 5 votes |
@Test public void testJaxwsFrontendWithNoAnnotation() throws Exception { jfb.setServiceClass(SayHi.class); jfb.setServiceBean(new SayHiNoInterceptor()); jserver = jfb.create(); List<Interceptor<? extends Message>> interceptors = jserver.getEndpoint().getInInterceptors(); assertFalse(hasTestInterceptor(interceptors)); List<Feature> features = fb.getFeatures(); assertFalse(hasAnnotationFeature(features)); }
Example 25
Source Project: dropwizard-jaxws Source File: AbstractBuilder.java License: Apache License 2.0 | 5 votes |
/** * Add CXF interceptors to the outgoing fault interceptor chain. * @param interceptors CXF interceptors. * @return EndpointBuilder instance. */ @SuppressWarnings("unchecked") public AbstractBuilder cxfOutFaultInterceptors(Interceptor<? extends Message> ... interceptors) { this.cxfOutFaultInterceptors = ImmutableList.<Interceptor<? extends Message>>builder() .add(interceptors).build(); return this; }
Example 26
Source Project: cxf Source File: JettyContinuationWrapper.java License: Apache License 2.0 | 5 votes |
protected Message getMessage() { Message m = message; if (m != null && m.getExchange().getInMessage() != null) { m = m.getExchange().getInMessage(); } return m; }
Example 27
Source Project: cxf Source File: HTTPConduit.java License: Apache License 2.0 | 5 votes |
protected void propagateConduit(Exchange exchange, Message in) { if (exchange != null) { Message out = exchange.getOutMessage(); if (out != null) { in.put(Conduit.class, out.get(Conduit.class)); } } }
Example 28
Source Project: cxf Source File: AnnotationInterceptorTest.java License: Apache License 2.0 | 5 votes |
@Test public void testJaxwsFrontendWithFeatureAnnotation() throws Exception { jfb.setServiceClass(SayHi.class); SayHi implementor = new SayHiImplementation(); jfb.setServiceBean(implementor); jserver = jfb.create(); List<Interceptor<? extends Message>> interceptors = jserver.getEndpoint().getInInterceptors(); assertTrue(hasAnnotationFeatureInterceptor(interceptors)); List<Interceptor<? extends Message>> outInterceptors = jserver.getEndpoint().getOutInterceptors(); assertTrue(hasAnnotationFeatureInterceptor(outInterceptors)); }
Example 29
Source Project: cxf Source File: AbstractClient.java License: Apache License 2.0 | 5 votes |
protected static PhaseInterceptorChain setupOutInterceptorChain(ClientConfiguration cfg) { PhaseManager pm = cfg.getBus().getExtension(PhaseManager.class); List<Interceptor<? extends Message>> i1 = cfg.getBus().getOutInterceptors(); List<Interceptor<? extends Message>> i2 = cfg.getOutInterceptors(); List<Interceptor<? extends Message>> i3 = cfg.getConduitSelector().getEndpoint().getOutInterceptors(); PhaseInterceptorChain chain = new PhaseChainCache().get(pm.getOutPhases(), i1, i2, i3); chain.add(new ClientRequestFilterInterceptor()); return chain; }
Example 30
Source Project: steady Source File: IssuedTokenInterceptorProvider.java License: Apache License 2.0 | 5 votes |
static final TokenStore getTokenStore(Message message) { TokenStore tokenStore = (TokenStore)message.getContextualProperty(TokenStore.class.getName()); if (tokenStore == null) { tokenStore = createTokenStore(message); } return tokenStore; }