private void loadHandlers(Binding binding, EndpointConfiguration config) { List<Handler> handlers = config.getHandlers(); if (handlers == null) { return; } binding.setHandlerChain(handlers); }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { SpecialMethod specialMethod = _specialMethods.get(method); if (specialMethod != null) { switch (specialMethod) { case TO_STRING: return "PortProxyHandler[]"; case EQUALS: return false; case HASH_CODE: return System.identityHashCode(this); case GET_BINDING: return _binding; case GET_REQUEST_CONTEXT: return _requestContext; case GET_RESPONSE_CONTEXT: return _responseContext; } } Object url = _requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); if (url == null) throw new ProtocolException("No service endpoint address specified"); if (!(url instanceof String)) throw new IllegalArgumentException("Invalid service endpoint address specified"); // XXX cache this and the HandlerChainInvoker List<Handler> chain = _binding.getHandlerChain(); if (chain == null || chain.size() == 0) return _skeleton.invoke(method, (String) url, args); else return _skeleton.invoke(method, (String) url, args, new HandlerChainInvoker(chain, this)); }
@SuppressWarnings("rawtypes") public JBWSTokenClient(STSClientConfig config, Map<String, ? super Object> options) { super(config); try { this.dataTypefactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException dce) { throw logger.wsTrustUnableToGetDataTypeFactory(dce); } requestType = (String) options.get(STSClientConfig.REQUEST_TYPE); if (requestType == null) { requestType = config.getRequestType(); } String soapBinding = (String) options.get(STSClientConfig.SOAP_BINDING); if (soapBinding != null) { setSoapBinding(soapBinding); } // Get pre-constructed Dispatch from super Dispatch<Source> dispatch = super.getDispatch(); String overrideDispatchStr = (String) options.get("overrideDispatch"); if (StringUtil.isNotNull(overrideDispatchStr)) { boolean bool = Boolean.valueOf(overrideDispatchStr); if (bool) { dispatch = new PicketLinkDispatch(dispatch, (String) options.get("endpointAddress")); String useWSSE = (String) options.get("useWSSE"); if (StringUtil.isNotNull(useWSSE) && useWSSE.equalsIgnoreCase("true")) { ((PicketLinkDispatch) dispatch).setUseWSSE(true); } } } Binding binding = dispatch.getBinding(); List<Handler> handlers = binding.getHandlerChain(); String handlerStr = (String) options.get("handlerChain"); if (StringUtil.isNotNull(handlerStr)) { List<String> tokens = StringUtil.tokenize(handlerStr); for (String token : tokens) { if (token.equalsIgnoreCase("binary")) { BinaryTokenHandler binaryTokenHandler = new BinaryTokenHandler(); handlers.add(binaryTokenHandler); } else if (token.equalsIgnoreCase("saml2")) { SAML2Handler samlHandler = new SAML2Handler(); handlers.add(samlHandler); } else if (token.equalsIgnoreCase("map")) { MapBasedTokenHandler mapBasedHandler = new MapBasedTokenHandler(options); handlers.add(mapBasedHandler); } else { ClassLoader cl = SecurityActions.getClassLoader(getClass()); try { handlers.add((Handler) cl.loadClass(token).newInstance()); } catch (Exception e) { throw logger.authUnableToInstantiateHandler(token, e); } } } } binding.setHandlerChain(handlers); setDispatch(dispatch); String securityDomainForFactory = (String) options.get("securityDomainForFactory"); if (StringUtil.isNotNull(securityDomainForFactory)) { logger.trace("We got security domain for domain ssl factory = " + securityDomainForFactory); logger.trace("Setting it on the system property org.jboss.security.ssl.domain.name"); String sslFactoryName = "org.jboss.security.ssl.JaasSecurityDomainSocketFactory"; SecurityActions.setSystemProperty( "org.jboss.security.ssl.domain.name", securityDomainForFactory); // StubExt.PROPERTY_SOCKET_FACTORY dispatch.getRequestContext().put("org.jboss.ws.socketFactory", sslFactoryName); // If we are using PL Dispatch. Then we need to set the SSL Socket Factory if (dispatch instanceof PicketLinkDispatch) { ClassLoader cl = SecurityActions.getClassLoader(getClass()); SSLSocketFactory socketFactory = null; if (cl != null) { try { Class<?> clazz = cl.loadClass(sslFactoryName); socketFactory = (SSLSocketFactory) clazz.newInstance(); } catch (Exception e) { cl = SecurityActions.getContextClassLoader(); try { Class<?> clazz = cl.loadClass(sslFactoryName); socketFactory = (SSLSocketFactory) clazz.newInstance(); } catch (Exception e1) { throw logger.jbossWSUnableToCreateSSLSocketFactory(e1); } } finally { if (socketFactory != null) { ((PicketLinkDispatch) dispatch).setSSLSocketFactory(socketFactory); } else throw logger.jbossWSUnableToFindSSLSocketFactory(); } } else { logger.trace( "Classloader is null. Unable to set the SSLSocketFactory on PicketLinkDispatch"); } } } }