@SuppressWarnings("unchecked") @Before public void setup() throws APPlatformException, MalformedURLException { besDAO.configService = confServ; doReturn(subServ).when(besDAO).getBESWebService( eq(SubscriptionService.class), any(ServiceInstance.class), any(Optional.class)); doReturn(idServ).when(besDAO).getBESWebService( eq(IdentityService.class), any(ServiceInstance.class), any(Optional.class)); doReturn(idServ).when(besDAO).getServicePort(eq(IdentityService.class), anyMap()); doReturn(subServ).when(besDAO).getServicePort( eq(SubscriptionService.class), anyMap()); doNothing().when(besDAO).validateVersion(anyString()); Binding mockBinding = mock(Binding.class); when(idServ.getBinding()).thenReturn(mockBinding); }
protected void setupClient(Object obj, Class<?> seiClass, WebServiceFeature... features) { Binding binding = ((BindingProvider)obj).getBinding(); Client client = obj instanceof DispatchImpl<?> ? ((DispatchImpl<?>)obj).getClient() : ClientProxy.getClient(obj); ClientConfig config = readConfig(seiClass); if (config != null) { CXFClientConfigurer helper = new CXFClientConfigurer(); helper.setupConfigHandlers(binding, config); helper.setConfigProperties(client, config.getProperties()); } client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding)); //add this *after* the config has been set (if any)! if (features != null) { for (WebServiceFeature f : features) { if (f instanceof AbstractClientFeature) { ((AbstractClientFeature)f).initialize(obj); } } } }
public CertRAClient(String location) { CertRaService certRaService = CertRaServiceFactory.newInstance(); this.port = certRaService.getCertRaPort(); BindingProvider bindingProvider = (BindingProvider) this.port; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(new LoggingHandler()); // LoggingHandler makes CXF fail on the attachments. // https://issues.apache.org/jira/browse/CXF-5496 binding.setHandlerChain(handlerChain); this.protocolObjectFactory = new be.e_contract.mycarenet.certra.jaxb.protocol.ObjectFactory(); }
/** * Main constructor. * * @param location * the URL of the eHealth STS web service. */ public EHealthSTSClient(String location) { EHealthSamlStsService service = EHealthSamlStsServiceFactory .newInstance(); QName portQName = new QName("urn:be:ehealth:saml:sts:1.0", "EHealthSamlStsPort"); this.dispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD); this.dispatch.getRequestContext().put( Dispatch.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = dispatch.getBinding(); @SuppressWarnings("rawtypes") List<Handler> handlerChain = binding.getHandlerChain(); this.wsSecuritySOAPHandler = new WSSecuritySOAPHandler(); handlerChain.add(this.wsSecuritySOAPHandler); handlerChain.add(new LoggingHandler()); binding.setHandlerChain(handlerChain); }
/** * Main constructor. * * @param location * the URL of the MyCareNet XKMS web service. */ public XKMSClient(String location) { XMLKeyManagementService service = XKMSServiceFactory.newInstance(); this.port = service.getKeyServiceSoapPort(); BindingProvider bindingProvider = (BindingProvider) this.port; bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(new LoggingHandler()); this.proofOfPossessionSignatureSOAPHandler = new ProofOfPossessionSignatureSOAPHandler(); handlerChain.add(this.proofOfPossessionSignatureSOAPHandler); handlerChain.add(new LoggingHandler()); binding.setHandlerChain(handlerChain); this.objectFactory = new ObjectFactory(); this.xmldsigObjectFactory = new be.e_contract.mycarenet.jaxb.xmldsig.ObjectFactory(); }
@SuppressWarnings("unchecked") private void configureBindingProvider(BindingProvider bindingProvider, String location) { bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List handlerChain = binding.getHandlerChain(); handlerChain.add(this.wsSecuritySOAPHandler); handlerChain.add(this.inboundAttachmentsSOAPHandler); // handlerChain.add(new LoggingHandler()); // LoggingHandler makes CXF fail on the attachments. // https://issues.apache.org/jira/browse/CXF-5496 binding.setHandlerChain(handlerChain); }
/** * Decorates a given JAX-WS port with the required security handlers. * * @param bindingProvider * the JAX-WS port to decorate. * @return the added payload logical JAX-WS handler. */ public PayloadLogicalHandler decorate(BindingProvider bindingProvider) { bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, this.location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List<Handler> handlerChain = binding.getHandlerChain(); SecuritySOAPHandler sessionKeySignatureSOAPHandler = new SecuritySOAPHandler( this.sessionKey, this.packageLicenseKey); handlerChain.add(sessionKeySignatureSOAPHandler); handlerChain.add(new LoggingHandler()); PayloadLogicalHandler payloadLogicalHandler = new PayloadLogicalHandler(); handlerChain.add(payloadLogicalHandler); binding.setHandlerChain(handlerChain); return payloadLogicalHandler; }
/** * Creates a Binding instance based on an EndpointDescription. * @param ed * @return */ public static Binding createBinding(EndpointDescription ed) { if (ed == null) { throw new NullPointerException("EndpointDescription is null"); } String bindingType = (ed.getServiceDescription().isServerSide()) ? ed.getBindingType() : ed.getClientBindingID(); if (BindingUtils.isSOAPBinding(bindingType)) { return new SOAPBinding(ed); } else if (BindingUtils.isHTTPBinding(bindingType)) { return new HTTPBinding(ed); } else { // If we can't figure it out, let's default to // a SOAPBinding return new SOAPBinding(ed); } }
/** * This code might be executed in the context of the bootstrap class loader. That's why we have to make sure we only * call code which is visible. For example, we can't use slf4j or directly reference stagemonitor classes */ @Advice.OnMethodEnter private static void addHandlers(@Advice.Argument(value = 0, readOnly = false) List<Handler> handlerChain, @Advice.This Binding binding) { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger("org.stagemonitor.tracing.soap.SoapHandlerTransformer"); final List<Handler<?>> stagemonitorHandlers = Dispatcher.get("org.stagemonitor.tracing.soap.SoapHandlerTransformer"); if (stagemonitorHandlers != null) { logger.fine("Adding SOAPHandlers " + stagemonitorHandlers + " to handlerChain for Binding " + binding); if (handlerChain == null) { handlerChain = Collections.emptyList(); } // creating a new list as we don't know if handlerChain is immutable or not handlerChain = new ArrayList<Handler>(handlerChain); for (Handler<?> stagemonitorHandler : stagemonitorHandlers) { if (!handlerChain.contains(stagemonitorHandler) && // makes sure we only add the handler to the correct application Dispatcher.isVisibleToCurrentContextClassLoader(stagemonitorHandler)) { handlerChain.add(stagemonitorHandler); } } logger.fine("Handler Chain: " + handlerChain); } else { logger.fine("No SOAPHandlers found in Dispatcher for Binding " + binding); } }
private void setBinding(BindingProvider client, String userName, String password) { final Binding binding = client.getBinding(); List<Handler> handlerList = binding.getHandlerChain(); if (handlerList == null) handlerList = new ArrayList<>(); handlerList.add(new SOAPSecurityHandler(userName, password)); binding.setHandlerChain(handlerList); }
@SuppressWarnings("unchecked") @Before public void setup() throws APPlatformException, MalformedURLException { besDAO.configService = confServ; doReturn(subServ).when(besDAO).getBESWebService( eq(SubscriptionService.class), any(ServiceInstance.class), any(Optional.class)); doReturn(idServ).when(besDAO).getBESWebService( eq(IdentityService.class), any(ServiceInstance.class), any(Optional.class)); doReturn(idServ).when(besDAO).getServicePort(eq(IdentityService.class), anyMap()); doReturn(subServ).when(besDAO).getServicePort( eq(SubscriptionService.class), anyMap()); Binding mockBinding = mock(Binding.class); when(idServ.getBinding()).thenReturn(mockBinding); }
/** * this is for Client Stub Programming * * @param t * @param s * @param args * @return */ @SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T getPort(T t, Service s, Object[] args) { Class<T> clz = null; if (Class.class.isAssignableFrom(args[0].getClass())) { clz = (Class<T>) args[0]; } else if (Class.class.isAssignableFrom(args[1].getClass())) { clz = (Class<T>) args[1]; } if (clz == null) { return t; } Binding binding = ((BindingProvider) t).getBinding(); List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(this.handler); binding.setHandlerChain(handlerChain); final String wsdlLocation = getServiceURL(s); T tProxy = JDKProxyInvokeUtil.newProxyInstance(clz.getClassLoader(), new Class[] { clz }, new JDKProxyInvokeHandler<T>(t, new ClientStubProcessor(wsdlLocation.toString(), this.handler))); return tProxy; }
@SuppressWarnings("rawtypes") public Dispatch createDispatch(Dispatch d, Service s, Object[] args) { Binding binding = ((BindingProvider) d).getBinding(); List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(this.handler); binding.setHandlerChain(handlerChain); final String wsdlLocation = getServiceURL(s); Dispatch tProxy = JDKProxyInvokeUtil.newProxyInstance(this.getClass().getClassLoader(), new Class[] { Dispatch.class }, new JDKProxyInvokeHandler<Dispatch>(d, new DispatchProcessor(wsdlLocation.toString(), this.handler))); return tProxy; }
protected InvoicePortType_InvoicePort_Server() throws java.lang.Exception { System.out.println("Starting Server"); Object implementor = new InvoicePortImpl(); String address = "http://localhost:9000/mockInvoicePortBinding"; Endpoint ep = Endpoint.publish(address, implementor); Binding binding = ep.getBinding(); ((SOAPBinding)binding).setMTOMEnabled(true); }
/** * Add a message handler to a SOAP binding * @param binding binding to which we'll add the handler * @param handler the handler to be added */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static void addMessageHandler(Object binding, SOAPHandler<SOAPMessageContext> handler) { final Binding b = ((BindingProvider) binding).getBinding(); List handlerList = b.getHandlerChain(); if (handlerList == null) handlerList = new ArrayList(); handlerList.add(handler); b.setHandlerChain(handlerList); }
/** * Add a message handler to a SOAP binding * @param binding binding to which we'll add the handler * @param handler the handler to be added */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static void addMessageHandler(Object binding, LogicalHandler handler) { final Binding b = ((BindingProvider) binding).getBinding(); List handlerList = b.getHandlerChain(); if (handlerList == null) handlerList = new ArrayList(); handlerList.add(handler); b.setHandlerChain(handlerList); }
/** * Add a message handler to a SOAP binding * @param binding binding to which we'll add the handler * @param index position in the list of handlers * @param handler the handler to be added */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static void addMessageHandler(Object binding, int index, SOAPHandler<SOAPMessageContext> handler) { final Binding b = ((BindingProvider) binding).getBinding(); List handlerList = b.getHandlerChain(); if (handlerList == null) handlerList = new ArrayList(); handlerList.add(index, handler); b.setHandlerChain(handlerList); }
/** * Add a message handler to a SOAP binding * @param binding binding to which we'll add the handler * @param index position in the list of handlers * @param handler the handler to be added */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static void addMessageHandler(Object binding, int index, LogicalHandler handler) { final Binding b = ((BindingProvider) binding).getBinding(); List handlerList = b.getHandlerChain(); if (handlerList == null) handlerList = new ArrayList(); handlerList.add(index, handler); b.setHandlerChain(handlerList); }
/** * Setups a given Binding instance using a specified CommonConfig * * @param binding the Binding instance to setup * @param config the CommonConfig with the input configuration */ @SuppressWarnings("rawtypes") public void setupConfigHandlers(Binding binding, CommonConfig config) { if (config != null) { //start with the use handlers only to remove the previously set configuration List<Handler> userHandlers = getNonConfigHandlers(binding.getHandlerChain()); List<Handler> handlers = convertToHandlers(config.getPreHandlerChains(), binding.getBindingID(), true); //PRE handlers.addAll(userHandlers); //ENDPOINT handlers.addAll(convertToHandlers(config.getPostHandlerChains(), binding.getBindingID(), false)); //POST binding.setHandlerChain(handlers); } }
public HandlerChainSortInterceptor(Binding b) { super(Phase.PRE_PROTOCOL); binding = b; //initially sort and reset the handler chain; if the chain is not modified later, the sort process //in handleMessage() deals with an already ordered list and is very efficient (~ O(n) according to //Collections.sort(..) javadoc. @SuppressWarnings("rawtypes") List<Handler> hc = binding.getHandlerChain(); if (hc.size() > 1) { //no need to sort etc if the chain is empty or has one handler only Collections.sort(hc, comparator); binding.setHandlerChain(hc); } }
private void configureBindingProvider(BindingProvider bindingProvider, String location) { bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); List handlerChain = binding.getHandlerChain(); handlerChain.add(this.wsSecuritySOAPHandler); handlerChain.add(new LoggingHandler()); binding.setHandlerChain(handlerChain); }
@SuppressWarnings("unchecked") private void configureBindingProvider(BindingProvider bindingProvider, String location) { bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List handlerChain = binding.getHandlerChain(); handlerChain.add(this.wsSecuritySOAPHandler); binding.setHandlerChain(handlerChain); }
@SuppressWarnings("unchecked") private void configureBindingProvider(BindingProvider bindingProvider, String location) { bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List handlerChain = binding.getHandlerChain(); handlerChain.add(this.wsSecuritySOAPHandler); handlerChain.add(new LoggingHandler()); handlerChain.add(this.payloadLogicalHandler); binding.setHandlerChain(handlerChain); }
@SuppressWarnings("unchecked") private void configureBindingProvider(BindingProvider bindingProvider, String location) { bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List handlerChain = binding.getHandlerChain(); handlerChain.add(new LoggingHandler()); handlerChain.add(this.payloadLogicalHandler); binding.setHandlerChain(handlerChain); }
/** * Main constructor. * * @param location * the URL of the MyCareNet XKMS 2.0 web service. */ public XKMS2Client(String location) { XMLKeyManagementService service = XKMS2ServiceFactory.newInstance(); this.keyServicePort = service.getKeyServiceSoapPort(); BindingProvider bindingProvider = (BindingProvider) this.keyServicePort; bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List<Handler> handlerChain = binding.getHandlerChain(); this.proofOfPossessionSignatureSOAPHandler = new ProofOfPossessionSignatureSOAPHandler(); handlerChain.add(new LoggingHandler()); handlerChain.add(this.proofOfPossessionSignatureSOAPHandler); this.keyBindingAuthenticationSignatureSOAPHandler = new KeyBindingAuthenticationSignatureSOAPHandler(); handlerChain.add(this.keyBindingAuthenticationSignatureSOAPHandler); handlerChain.add(new LoggingHandler()); binding.setHandlerChain(handlerChain); this.objectFactory = new ObjectFactory(); this.xmldsigObjectFactory = new be.e_contract.mycarenet.jaxb.xmldsig.ObjectFactory(); try { this.datatypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new RuntimeException("DatatypeFactory error: " + e.getMessage(), e); } }
protected void registerService(BindingProvider bindingProvider) { Binding binding = bindingProvider.getBinding(); List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(new LoggingHandler()); // set the handler chain again for the changes to take effect binding.setHandlerChain(handlerChain); }
private void registerService(BindingProvider bindingProvider) { Binding binding = bindingProvider.getBinding(); List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(new LoggingHandler()); // set the handler chain again for the changes to take effect binding.setHandlerChain(handlerChain); }
/** Creates an instance of an InvocationContext based on the Binding that was passed in. */ public static InvocationContext createInvocationContext(Binding binding) { InvocationContextImpl ic = new InvocationContextImpl(); if (binding != null) { ic.setHandlers(binding.getHandlerChain()); } return ic; }
public static EndpointInvocationContext createEndpointInvocationContext(Binding binding) { EndpointInvocationContext eic = new EndpointInvocationContextImpl(); if (binding != null) { eic.setHandlers(binding.getHandlerChain()); } return eic; }
public void testGetBinding() throws Exception { SampleEndpoint sample = new SampleEndpoint(); Endpoint ep = Endpoint.create(sample); assertTrue("The returned Endpoint instance was null", ep != null); Binding bnd = ep.getBinding(); assertTrue("The returned Binding instance was null", bnd != null); assertTrue("The returned Binding instance was of the wrong type (" + bnd.getClass().getName() + "), expected SOAPBinding", SOAPBinding.class.isAssignableFrom(bnd.getClass())); ep.stop(); }
public ListStamps(Configuration configuration) { super(); this.configuration = configuration; service = new ProdWSService(); port = service.getProdWSPort(); Binding binding = ((BindingProvider) port).getBinding(); @SuppressWarnings("rawtypes") List<Handler> chain = binding.getHandlerChain(); chain.add(new WSSUsernameTokenSecurityHandler(configuration.getProperty("org.kleini.prodws.login"), configuration.getProperty("org.kleini.prodws.password"))); // chain.add(new SOAPLoggingHandler()); binding.setHandlerChain(chain); }
@Override public ElementMatcher.Junction<TypeDescription> getTypeMatcher() { // It's important to pre-select potential matches first with the nameContains matcher // otherwise, the type hierarchy of each and every class has to be determined whether it derives from Binding return nameContains("Binding") .and(not(isInterface())) .and(isSubTypeOf(Binding.class)); }
@Advice.OnMethodExit private static void setHandlerChain(@Advice.Return Object portOrDispatch) { if (portOrDispatch instanceof BindingProvider) { final Binding binding = ((BindingProvider) portOrDispatch).getBinding(); final List<Handler> handlerChain = binding.getHandlerChain(); if (handlerChain != null) { binding.setHandlerChain(handlerChain); } else { binding.setHandlerChain(new ArrayList<Handler>()); } } }
@SuppressWarnings("rawtypes") public CampaignServiceInterfaceImpl() { binding = Mockito.mock(Binding.class); RequestInfoXPathSet requestInfoXPathSet = Mockito.mock(RequestInfoXPathSet.class); ResponseInfoXPathSet responseInfoXPathSet = Mockito.mock(ResponseInfoXPathSet.class); List<Handler> handlerList = Lists.<Handler>newArrayList( new JaxWsSoapContextHandler(requestInfoXPathSet, responseInfoXPathSet)); when(binding.getHandlerChain()).thenReturn(handlerList); }