private boolean logSensitiveHeaders() { // Not allowed by default return PropertyUtils.isTrue(message.getContextualProperty(ALLOW_LOGGING_SENSITIVE_HEADERS)); }
private void writeUnformattedRESTfulEndpoints(PrintWriter writer, String baseAddress, AbstractDestination[] destinations) throws IOException { for (AbstractDestination sd : destinations) { String address = getAbsoluteAddress(baseAddress, sd); boolean wadlAvailable = bus != null && PropertyUtils.isTrue(bus.getProperty("wadl.service.descrition.available")); boolean swaggerAvailable = bus != null && PropertyUtils.isTrue(bus.getProperty("swagger.service.descrition.available")); if (!wadlAvailable && !swaggerAvailable) { writer.write(address + "\n"); return; } if (wadlAvailable) { writer.write(address + "?_wadl\n"); } if (swaggerAvailable) { writer.write(address + "/swagger.json\n"); } } }
if (sb != null && PropertyUtils.isTrue(sb.getProperty("wadl.service.description.available"))) { writer.write("<br/><span class=\"field\">WADL :</span> " + "<a href=\"" + absoluteURL + "?_wadl\">" + absoluteURL + "?_wadl" + "</a>"); if (sb != null && PropertyUtils.isTrue(sb.getProperty("swagger.service.description.available"))) { String swaggerPath = "swagger.json"; if (PropertyUtils.isTrue(sb.getProperty("swagger.service.ui.available"))) { URI uri = URI.create(absoluteURL); String schemePath = uri.getScheme() + "://" + uri.getHost()
protected void redirect(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException { boolean customServletPath = dispatcherServletPath != null; String theServletPath = customServletPath ? dispatcherServletPath : "/"; ServletContext sc = super.getServletContext(); RequestDispatcher rd = dispatcherServletName != null ? sc.getNamedDispatcher(dispatcherServletName) : sc.getRequestDispatcher((theServletPath + pathInfo).replace("//", "/")); if (rd == null) { String errorMessage = "No RequestDispatcher can be created for path " + pathInfo; if (dispatcherServletName != null) { errorMessage += ", dispatcher name: " + dispatcherServletName; } throw new ServletException(errorMessage); } try { for (Map.Entry<String, String> entry : redirectAttributes.entrySet()) { request.setAttribute(entry.getKey(), entry.getValue()); } HttpServletRequest servletRequest = new HttpServletRequestRedirectFilter(request, pathInfo, theServletPath, customServletPath); if (PropertyUtils.isTrue(getServletConfig().getInitParameter(REDIRECT_WITH_INCLUDE_PARAMETER))) { rd.include(servletRequest, response); } else { rd.forward(servletRequest, response); } } catch (Throwable ex) { throw new ServletException("RequestDispatcher for path " + pathInfo + " has failed", ex); } }
public void start(final BundleContext context) throws Exception { ConfigAdminHttpConduitConfigurer conduitConfigurer = new ConfigAdminHttpConduitConfigurer(); registerService(context, ManagedServiceFactory.class, conduitConfigurer, ConfigAdminHttpConduitConfigurer.FACTORY_PID); registerService(context, HTTPConduitConfigurer.class, conduitConfigurer, "org.apache.cxf.http.conduit-configurer"); if (PropertyUtils.isTrue(context.getProperty(DISABLE_DEFAULT_HTTP_TRANSPORT))) { //TODO: Review if it also makes sense to support "http.transport.disable" // directly in the CXF_CONFIG_SCOPE properties file return; } DestinationRegistry destinationRegistry = new DestinationRegistryImpl(); HTTPTransportFactory transportFactory = new HTTPTransportFactory(destinationRegistry); HttpServiceTrackerCust customizer = new HttpServiceTrackerCust(destinationRegistry, context); httpServiceTracker = new ServiceTracker<>(context, HttpService.class, customizer); httpServiceTracker.open(); context.registerService(DestinationRegistry.class.getName(), destinationRegistry, null); context.registerService(HTTPTransportFactory.class.getName(), transportFactory, null); BlueprintNameSpaceHandlerFactory factory = new BlueprintNameSpaceHandlerFactory() { @Override public Object createNamespaceHandler() { return new HttpBPHandler(); } }; NamespaceHandlerRegisterer.register(context, factory, "http://cxf.apache.org/transports/http/configuration"); }
/** * Constructor * * @param b the associated Bus * @param registry the destination registry * @param ei the endpoint info of the destination * @param path the path * @param dp true for adding the default port if it is missing * @throws IOException */ public AbstractHTTPDestination(Bus b, DestinationRegistry registry, EndpointInfo ei, String path, boolean dp) throws IOException { super(b, getTargetReference(getAddressValue(ei, dp), b), ei); this.bus = b; this.registry = registry; this.path = path; try { ServletRequest.class.getMethod("isAsyncSupported"); isServlet3 = true; } catch (Throwable t) { //servlet 2.5 or earlier, no async support } decodeBasicAuthWithIso8859 = PropertyUtils.isTrue(bus.getProperty(DECODE_BASIC_AUTH_WITH_ISO8859)); initConfig(); }
public Servlet3Continuation() { req.setAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE, inMessage.getExchange().getInMessage()); callback = inMessage.getExchange().get(ContinuationCallback.class); blockRestart = PropertyUtils.isTrue(inMessage.getContextualProperty(BLOCK_RESTART)); context = req.startAsync(); context.addListener(this); }
protected void handleHeadersTrustCaching() throws IOException { // Need to set the headers before the trust decision // because they are set before the connect(). setProtocolHeaders(); // // This point is where the trust decision is made because the // Sun implementation of URLConnection will not let us // set/addRequestProperty after a connect() call, and // makeTrustDecision needs to make a connect() call to // make sure the proper information is available. // makeTrustDecision(); // Trust is okay, set up for writing the request. String method = getMethod(); if (KNOWN_HTTP_VERBS_WITH_NO_CONTENT.contains(method) || PropertyUtils.isTrue(outMessage.get(Headers.EMPTY_REQUEST_PROPERTY))) { handleNoOutput(); return; } setupWrappedStream(); }
public String getAuthorization(AuthorizationPolicy authPolicy, URI currentURI, Message message, String fullHeader) { if (authPolicy.getUserName() != null && authPolicy.getPassword() != null) { boolean encodeBasicAuthWithIso8859 = PropertyUtils.isTrue( message.getContextualProperty(ENCODE_BASIC_AUTH_WITH_ISO8859)); return getBasicAuthHeader(authPolicy.getUserName(), authPolicy.getPassword(), encodeBasicAuthWithIso8859); } return null; }
boolean emptyRequest = getRequest || PropertyUtils.isTrue(message.get(EMPTY_REQUEST_PROPERTY));
public static boolean isTrue(Map<String, Object> props, String key) { if (props == null || key == null) { return false; } return isTrue(props.get(key)); }
private Boolean getOrFallback(Boolean value, Properties properties, String property) { Boolean fallback = value; if (value == null && properties != null) { fallback = PropertyUtils.isTrue(properties.get(PRETTY_PRINT_PROPERTY)); } if (fallback == null) { return false; } return fallback; }
public static boolean isTrue(Map<String, Object> props, String key) { if (props == null || key == null) { return false; } else { return isTrue(props.get(key)); } }
Object xmlDec = soapMessage.getProperty(SOAPMessage.WRITE_XML_DECLARATION); if (xmlDec != null) { boolean b = PropertyUtils.isTrue(xmlDec); message.put(StaxOutInterceptor.FORCE_START_DOCUMENT, b);
protected boolean isCorsRequest(Message m) { //Redirection-based flows (Implicit Grant Flow specifically) may have //the browser issuing CORS preflight OPTIONS request. //org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter can be //used to handle preflights but local preflights (to be handled by the service code) // will be blocked by this filter unless CORS filter has done the initial validation // and set a message "local_preflight" property to true return PropertyUtils.isTrue(m.get("local_preflight")); }
if (PropertyUtils.isTrue(o)) { Collection<Attachment> atts = inMessage.getAttachments(); if (atts != null) {
private boolean shouldCheckUrl(Bus bus) { Object prop = null; if (bus != null) { prop = bus.getProperty(DO_NOT_CHECK_URL_PROP); } if (prop == null) { prop = SystemPropertyAction.getPropertyOrNull(DO_NOT_CHECK_URL_PROP); } return !PropertyUtils.isTrue(prop); }
private void setWebClientOperationProperty(Message m, String httpMethod) { Object prop = m.getContextualProperty(WEB_CLIENT_OPERATION_REPORTING); // Enable the operation reporting by default if (prop == null || PropertyUtils.isTrue(prop)) { UriBuilder absPathUri = super.getCurrentBuilder().clone(); absPathUri.replaceQuery(null); setPlainOperationNameProperty(m, httpMethod + ":" + absPathUri.build().toString()); } }
private void setWebClientOperationProperty(Message m, String httpMethod) { Object prop = m.getContextualProperty(WEB_CLIENT_OPERATION_REPORTING); // Enable the operation reporting by default if (prop == null || PropertyUtils.isTrue(prop)) { UriBuilder absPathUri = super.getCurrentBuilder().clone(); absPathUri.replaceQuery(null); setPlainOperationNameProperty(m, httpMethod + ":" + absPathUri.build().toString()); } }
@Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { if (PropertyUtils.isTrue(requestContext.getProperty("blocked"))) { throw new BlockedException(); } }