Package com.springsource.insight.collection.http

Examples of com.springsource.insight.collection.http.HttpObfuscator


        super.setUp();

        HttpClientExecutionCollectionAspect aspectInstance = getAspect();
        originalObfuscator = aspectInstance.getHttpHeadersObfuscator();
        marker.clear();
        aspectInstance.setHttpHeadersObfuscator(new HttpObfuscator(marker));
    }
View Full Code Here


            }
            method.addRequestHeader(name, name);
        }

        HttpClientExecutionCollectionAspect aspectInstance = getAspect();
        HttpObfuscator obfuscator = aspectInstance.getHttpHeadersObfuscator();
        if (!defaultHeaders) {
            for (String name : HttpObfuscator.DEFAULT_OBFUSCATED_HEADERS_LIST) {
                if ("WWW-Authenticate".equalsIgnoreCase(name)) {
                    continue;    // this is a response header
                }
                method.addRequestHeader(name, name);
            }
            obfuscator.incrementalUpdate(HttpObfuscator.OBFUSCATED_HEADERS_SETTING, StringUtil.implode(headerSet, ","));
        }

        int response = httpClient.executeMethod(method);
        Operation op = assertExecutionResult(uri, method, response, false);
        OperationMap reqDetails = op.get("request", OperationMap.class);
        OperationList reqHeaders = reqDetails.get("headers", OperationList.class);
        Map<String, String> requestHeaders = toHeadersMap(reqHeaders);
        OperationMap rspDetails = op.get("response", OperationMap.class);
        OperationList rspHeaders = rspDetails.get("headers", OperationList.class);
        Map<String, String> responseHeaders = toHeadersMap(rspHeaders);
        Map<String, String> hdrsMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
        if (MapUtil.size(requestHeaders) > 0) {
            hdrsMap.putAll(requestHeaders);
        }
        if (MapUtil.size(responseHeaders) > 0) {
            hdrsMap.putAll(responseHeaders);
        }

        Collection<?> obscuredValues = (ObscuredValueSetMarker) obfuscator.getSensitiveValueMarker();
        for (String name : headerSet) {
            String value = hdrsMap.get(name);
            assertNotNull("Missing value for header: " + name, value);
            assertTrue("Unobscured value of " + name, obscuredValues.contains(value));
        }
View Full Code Here

        ClientHttpRequestCollectionOperationAspect aspectInstance = getAspect();
        ClientHttpRequestOperationCollector collector = (ClientHttpRequestOperationCollector) aspectInstance.getCollector();
        originalObfuscator = collector.getHttpObfuscator();
        marker.clear();
        collector.setHttpObfuscator(new HttpObfuscator(marker));
    }
View Full Code Here

    }

    private void runObfuscationTest(String testName, Collection<String> hdrs, boolean defaultHeaders) throws Exception {
        ClientHttpRequestCollectionOperationAspect aspectInstance = getAspect();
        ClientHttpRequestOperationCollector collector = (ClientHttpRequestOperationCollector) aspectInstance.getCollector();
        HttpObfuscator obfuscator = collector.getHttpObfuscator();
        if (!defaultHeaders) {
            obfuscator.incrementalUpdate(HttpObfuscator.OBFUSCATED_HEADERS_SETTING, StringUtil.implode(hdrs, ","));
        }

        HttpHeaders reqHdrs = createIdentityHttpHeaders(HttpObfuscator.DEFAULT_OBFUSCATED_HEADERS_LIST);
        assertNotNull("Failed to remove response header value", reqHdrs.remove("WWW-Authenticate"));
        if (!defaultHeaders) {
            addIdentityHttpHeaders(reqHdrs, hdrs);
        }

        HttpHeaders rspHdrs = createIdentityHttpHeaders(Collections.singletonList("WWW-Authenticate"));
        ClientHttpRequest request =
                new TestClientHttpRequest(HttpMethod.GET,
                        new URI("http://somewhere:7365/" + testName),
                        reqHdrs,
                        createMockClientHttpResponse(HttpStatus.OK, rspHdrs));
        ClientHttpResponse response = request.execute();
        assertNotNull("No response", response);

        ObscuredValueSetMarker obsMarker = (ObscuredValueSetMarker) obfuscator.getSensitiveValueMarker();
        for (String name : hdrs) {
            assertTrue("Value not obscured for " + name, obsMarker.remove(name));
        }

        // if obscured headers are not the defaults, make sure defaults are not obscured
View Full Code Here

        super.setUp();

        HttpClientExecutionCollectionAspect aspectInstance = getAspect();
        originalObfuscator = aspectInstance.getHttpHeadersObfuscator();
        marker.clear();
        aspectInstance.setHttpHeadersObfuscator(new HttpObfuscator(marker));
    }
View Full Code Here

            }
            request.setHeader(name, name);
        }

        HttpClientExecutionCollectionAspect aspectInstance = getAspect();
        HttpObfuscator obfuscator = aspectInstance.getHttpHeadersObfuscator();
        if (!defaultHeaders) {
            for (String name : HttpObfuscator.DEFAULT_OBFUSCATED_HEADERS_LIST) {
                if ("WWW-Authenticate".equalsIgnoreCase(name)) {
                    continue;    // this is a response header
                }
                request.setHeader(name, name);
            }
            obfuscator.incrementalUpdate(HttpObfuscator.OBFUSCATED_HEADERS_SETTING, StringUtil.implode(headerSet, ","));
        }

        HttpResponse response = httpClient.execute(request);
        Operation op = assertExecutionResult(uri, request, response, false);
        OperationMap reqDetails = op.get("request", OperationMap.class);
        OperationList reqHeaders = reqDetails.get("headers", OperationList.class);
        Map<String, String> requestHeaders = toHeadersMap(reqHeaders);
        OperationMap rspDetails = op.get("response", OperationMap.class);
        OperationList rspHeaders = rspDetails.get("headers", OperationList.class);
        Map<String, String> responseHeaders = toHeadersMap(rspHeaders);
        Map<String, String> hdrsMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
        if (MapUtil.size(requestHeaders) > 0) {
            hdrsMap.putAll(requestHeaders);
        }
        if (MapUtil.size(responseHeaders) > 0) {
            hdrsMap.putAll(responseHeaders);
        }

        Collection<?> obscuredValues = (ObscuredValueSetMarker) obfuscator.getSensitiveValueMarker();
        for (String name : headerSet) {
            String value = hdrsMap.get(name);
            assertNotNull("Missing header=" + name, value);
            assertTrue("Unobscured value of " + name, obscuredValues.contains(value));
        }
View Full Code Here

    OperationList fillMethodHeaders(OperationList op, HttpHeaders hdrs) {
        if (hdrs.isEmpty()) {
            return op;
        }

        HttpObfuscator obfs = getHttpObfuscator();
        for (String key : hdrs.keySet()) {
            String value = hdrs.getFirst(key);
            OperationUtils.addNameValuePair(op, key, value);
            if (obfs.processHeader(key, value)) {
                continue;    // debug breakpoint
            }
        }

        return op;
View Full Code Here

        super.setUp();

        SocketOperationCollectionAspectSupport aspectInstance = (SocketOperationCollectionAspectSupport) getAspect();
        originalContext = aspectInstance.getSocketCollectOperationContext();
        marker.clear();
        aspectInstance.setSocketCollectOperationContext(new SocketCollectOperationContext(new HttpObfuscator(marker)));
    }
View Full Code Here

TOP

Related Classes of com.springsource.insight.collection.http.HttpObfuscator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.