aboutsummaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-02-15 14:30:39 -0500
committerDan Timoney <dtimoney@att.com>2017-02-15 14:37:01 -0500
commitd8861011dc81160df81979d2bed9721447517f45 (patch)
tree6aaf805a83ad8be93bd9772a2b2e517770c67b72 /filters
parent57b0ded28b8c6477ca0df13a05eafb392f6fa82e (diff)
Initial commit for OpenECOMP SDN-C N-C core
Change-Id: I30c52795ab821c4fdd18b55d202f10a76a01acfa Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'filters')
-rwxr-xr-xfilters/.gitignore34
-rwxr-xr-xfilters/.sonar/checkstyle.xml1
-rwxr-xr-xfilters/.sonar/pmd.xml67
-rwxr-xr-xfilters/README14
-rwxr-xr-xfilters/features/pom.xml101
-rw-r--r--filters/features/src/main/resources/features.xml32
-rwxr-xr-xfilters/installer/pom.xml136
-rw-r--r--filters/installer/src/assembly/assemble_installer_zip.xml58
-rw-r--r--filters/installer/src/assembly/assemble_mvnrepo_zip.xml48
-rw-r--r--filters/installer/src/main/resources/scripts/install-feature.sh40
-rw-r--r--filters/pom.xml93
-rwxr-xr-xfilters/provider/pom.xml90
-rw-r--r--filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java68
-rw-r--r--filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java222
-rw-r--r--filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java279
15 files changed, 1283 insertions, 0 deletions
diff --git a/filters/.gitignore b/filters/.gitignore
new file mode 100755
index 0000000..b73caf3
--- /dev/null
+++ b/filters/.gitignore
@@ -0,0 +1,34 @@
+#####standard .git ignore entries#####
+
+## IDE Specific Files ##
+org.eclipse.core.resources.prefs
+.classpath
+.project
+.settings
+.idea
+.externalToolBuilders
+maven-eclipse.xml
+workspace
+
+## Compilation Files ##
+*.class
+**/target
+target
+target-ide
+MANIFEST.MF
+
+## Misc Ignores (OS specific etc) ##
+bin/
+dist
+*~
+*.ipr
+*.iml
+*.iws
+classes
+out/
+.DS_STORE
+.metadata
+
+## Folders which contain auto generated source code ##
+yang-gen-config
+yang-gen-sal
diff --git a/filters/.sonar/checkstyle.xml b/filters/.sonar/checkstyle.xml
new file mode 100755
index 0000000..3fa2315
--- /dev/null
+++ b/filters/.sonar/checkstyle.xml
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"><!-- Generated by Sonar --><module name="Checker"><module name="SuppressionCommentFilter"/><module name="TreeWalker"><module name="FileContentsHolder"/> <module name="ClassFanOutComplexity"><property name="severity" value="warning"/></module><module name="NestedForDepth"><property name="severity" value="warning"/><property name="max" value="1"/></module><module name="ClassDataAbstractionCoupling"><property name="severity" value="warning"/></module></module></module> \ No newline at end of file
diff --git a/filters/.sonar/pmd.xml b/filters/.sonar/pmd.xml
new file mode 100755
index 0000000..80343b3
--- /dev/null
+++ b/filters/.sonar/pmd.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset>
+ <rule ref="rulesets/java/naming.xml/BooleanGetMethodName">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/j2ee.xml/StaticEJBFieldShouldBeFinal">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/coupling.xml/CouplingBetweenObjects">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/codesize.xml/TooManyMethods">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/naming.xml/AvoidFieldNameMatchingTypeName">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/DoubleCheckedLocking">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/naming.xml/AvoidFieldNameMatchingMethodName">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/coupling.xml/ExcessiveImports">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/OverrideBothEqualsAndHashcode">
+ <priority>2</priority>
+ </rule>
+ <rule ref="rulesets/java/naming.xml/ShortMethodName">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/BooleanInstantiation">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/codesize.xml/TooManyFields">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/controversial.xml/AvoidUsingNativeCode">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/optimizations.xml/UseStringBufferForStringAppends">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/coupling.xml/LooseCoupling">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/NonThreadSafeSingleton">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/j2ee.xml/DoNotUseThreads">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/sunsecure.xml/ArrayIsStoredDirectly">
+ <priority>5</priority>
+ </rule>
+ <rule ref="rulesets/java/sunsecure.xml/MethodReturnsInternalArray">
+ <priority>2</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/AssignmentToNonFinalStatic">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/AvoidCatchingGenericException">
+ <priority>3</priority>
+ </rule>
+</ruleset>
+
diff --git a/filters/README b/filters/README
new file mode 100755
index 0000000..9d69d63
--- /dev/null
+++ b/filters/README
@@ -0,0 +1,14 @@
+
+/restconf filters are enabled by specifying filter chain in
+ /opt/opendaylight/current/etc/org.opendaylight.aaa.filterchain.cfg
+and enabling bundle class loading
+ >bundle:dynamic-import org.openecomp.sdnc.filters-provider
+
+loggers:
+ org.openecomp.sdnc.filters.audit
+ org.openecomp.sdnc.filters.metric
+ org.openecomp.sdnc.filters.request.response
+
+
+
+
diff --git a/filters/features/pom.xml b/filters/features/pom.xml
new file mode 100755
index 0000000..f3dfe62
--- /dev/null
+++ b/filters/features/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>filters</artifactId>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>filters-features</artifactId>
+ <name>Filters - Features</name>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>filters-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <version>${odl.mdsal.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+
+ <scope>runtime</scope>
+ </dependency>
+-->
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- launches the feature test, which validates that your karaf feature
+ can be installed inside of a karaf container. It doesn't validate that your
+ functionality works correctly, just that you have all of the dependent bundles
+ defined correctly.
+ <plugin>
+
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.16</version>
+ <configuration>
+ <systemPropertyVariables>
+ <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId>
+ <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>
+ <karaf.distro.version>${odl.karaf.empty.distro.version}</karaf.distro.version>
+ </systemPropertyVariables>
+ <dependenciesToScan>
+ <dependency>org.opendaylight.yangtools:features-test</dependency>
+ </dependenciesToScan>
+ </configuration>
+ </plugin>
+ -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/filters/features/src/main/resources/features.xml b/filters/features/src/main/resources/features.xml
new file mode 100644
index 0000000..75b780e
--- /dev/null
+++ b/filters/features/src/main/resources/features.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<features name="sdnc-filters-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+
+ <feature name='sdnc-filters' description="servlet filters" version='${project.version}'>
+ <bundle>mvn:org.openecomp.sdnc.core/filters-provider/${project.version}</bundle>
+ </feature>
+
+</features>
diff --git a/filters/installer/pom.xml b/filters/installer/pom.xml
new file mode 100755
index 0000000..39a00b9
--- /dev/null
+++ b/filters/installer/pom.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>filters</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>filters-installer</artifactId>
+ <name>Filters - Karaf Installer</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <application.name>sdnc-filters</application.name>
+ <features.boot>sdnc-filters</features.boot>
+ <features.repositories>mvn:org.openecomp.sdnc.core/filters-features/${project.version}/xml/features</features.repositories>
+ <include.transitive.dependencies>false</include.transitive.dependencies>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>filters-features</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>filters-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>maven-repo-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <attach>false</attach>
+ <finalName>stage/${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>installer-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <attach>true</attach>
+ <finalName>${application.name}-${project.version}-installer</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <transitive>false</transitive>
+ <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>true</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <includeGroupIds>org.openecomp.sdnc</includeGroupIds>
+ <excludeArtifactIds>sli-common,sli-provider</excludeArtifactIds>
+ <scope>provided</scope>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-version</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals><!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources/scripts</directory>
+ <includes>
+ <include>install-feature.sh</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/filters/installer/src/assembly/assemble_installer_zip.xml b/filters/installer/src/assembly/assemble_installer_zip.xml
new file mode 100644
index 0000000..80b2ad1
--- /dev/null
+++ b/filters/installer/src/assembly/assemble_installer_zip.xml
@@ -0,0 +1,58 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>644</fileMode>
+ <excludes>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
diff --git a/filters/installer/src/assembly/assemble_mvnrepo_zip.xml b/filters/installer/src/assembly/assemble_mvnrepo_zip.xml
new file mode 100644
index 0000000..c87b7d3
--- /dev/null
+++ b/filters/installer/src/assembly/assemble_mvnrepo_zip.xml
@@ -0,0 +1,48 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
diff --git a/filters/installer/src/main/resources/scripts/install-feature.sh b/filters/installer/src/main/resources/scripts/install-feature.sh
new file mode 100644
index 0000000..d8d381d
--- /dev/null
+++ b/filters/installer/src/main/resources/scripts/install-feature.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
+ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
+ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"}
+INSTALLERDIR=$(dirname $0)
+
+REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
+
+if [ -f ${REPOZIP} ]
+then
+ unzip -d ${ODL_HOME} ${REPOZIP}
+else
+ echo "ERROR : repo zip ($REPOZIP) not found"
+ exit 1
+fi
+
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories}
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot}
diff --git a/filters/pom.xml b/filters/pom.xml
new file mode 100644
index 0000000..b809abc
--- /dev/null
+++ b/filters/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sdnc-core</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>pom</packaging>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>filters</artifactId>
+
+
+ <name>Filters</name>
+ <description>Servlet filter to implement ECOMP logging spec</description>
+
+ <version>1.0.0</version>
+
+
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.4</version>
+ <dependencies>
+ <dependency><!-- add support for ssh/scp -->
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven.compile.plugin.version}</version>
+ <configuration>
+ <source>${java.version.source}</source>
+ <target>${java.version.target}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10</version>
+
+ <executions>
+ <execution>
+ <id>aggregate</id>
+ <goals>
+ <goal>aggregate</goal>
+ </goals>
+ <phase>site</phase>
+
+ </execution>
+
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.1</version>
+ <executions>
+ <execution>
+ <id>bundle-sources</id>
+ <phase>package</phase>
+ <goals>
+ <!-- produce source artifact for main project sources -->
+ <goal>jar-no-fork</goal>
+
+ <!-- produce source artifact for project test sources -->
+ <goal>test-jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </pluginManagement>
+ </build>
+ <organization>
+ <name>OpenECOMP</name>
+ </organization>
+ <modules>
+ <module>provider</module>
+ <module>features</module>
+ <module>installer</module>
+ </modules>
+</project>
diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml
new file mode 100755
index 0000000..7b00001
--- /dev/null
+++ b/filters/provider/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>filters</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>filters-provider</artifactId>
+ <packaging>bundle</packaging>
+ <name>Filters - Provider</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <version>${equinox.osgi.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>${commons.codec.version}</version>
+ </dependency>
+
+<!--
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>${mysql.connector.version}</version>
+ </dependency>
+-->
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${bundle.plugin.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.openecomp.sdnc.filters</Bundle-SymbolicName>
+ <Bundle-Activator>org.openecomp.sdnc.filters.Activator</Bundle-Activator>
+ <Export-Package>org.openecomp.sdnc.filters</Export-Package>
+ <DynamicImport-Package>org.openecomp.sdnc.filters</DynamicImport-Package>
+ <Import-Package>javax.servlet.*,java.io.*,org.osgi.framework.*,org.slf4j.*,org.apache.commons.codec.binary.*</Import-Package>
+ <!--
+ <Import-Package>org.openecomp.sdnc.filters.filters.*,javax.servlet.*,java.io.*,org.osgi.framework.*,org.slf4j.*</Import-Package>
+ <Embed-Dependency>*;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|slf4j-api|jcl-over-slf4j|mysql-connector-java|xml-apis</Embed-Dependency>
+ <Import-Package>*</Import-Package>
+ -->
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+
+ </plugin>
+
+
+ </plugins>
+ </build>
+</project>
diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java
new file mode 100644
index 0000000..d246d63
--- /dev/null
+++ b/filters/provider/src/main/java/org/openecomp/sdnc/filters/Activator.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.filters;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.util.Properties;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class Activator implements BundleActivator {
+
+ private ServiceRegistration registration = null;
+
+ private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
+
+ @Override
+ public void start(BundleContext ctx) throws Exception {
+
+
+
+ Object impl = new String();
+ String regName = impl.getClass().getName();
+
+ if (registration == null)
+ {
+ LOG.debug("Registering Filters service "+regName);
+ registration = ctx.registerService(regName, impl, null);
+ }
+
+ }
+
+ @Override
+ public void stop(BundleContext ctx) throws Exception {
+
+ if (registration != null)
+ {
+ registration.unregister();
+ registration = null;
+ }
+ }
+
+}
diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java
new file mode 100644
index 0000000..aa1d530
--- /dev/null
+++ b/filters/provider/src/main/java/org/openecomp/sdnc/filters/LogFilter.java
@@ -0,0 +1,222 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.filters;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.codec.binary.Base64;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+
+
+/**
+ * Logs IN request according ECOMP Logging Guidelines
+ */
+public class LogFilter implements Filter {
+
+ //X-ECOMP is shared between audit and metric
+ public static final String BEGIN_TIMESTAMP = "AUDIT-BeginTimestamp";
+ public static final String END_TIMESTAMP = "AUDIT-EndTimestamp";
+ public static final String REQUEST_ID = "X-ECOMP-RequestID";
+ public static final String SERVICE_INSTANCE = "X-ECOMP-ServiceInstanceID";
+ public static final String THREAD_ID ="X-ECOMP-ThreadId"; //optional
+ public static final String PHYSICAL_SERVER_NAME="X-ECOMP-PhysicalServerName"; //optional
+ public static final String SERVICE_NAME="X-ECOMP-ServiceName";
+ public static final String PARTNER_NAME="X-ECOMP-PartnerName";
+ public static final String STATUS_CODE="AUDIT-StatusCode";
+ public static final String RESP_CODE="AUDIT-ResponseCode";
+ public static final String RESP_DESC="AUDIT-ResponseDescription";
+ public static final String INSTANCE_UUID="AUDIT-InstanceUUID";
+ public static final String CATEGORY="AUDIT-INFO";
+ public static final String SEVERITY ="AUDIT-Severity"; //optional
+ public static final String SERVER_IP="AUDIT-ServerIP"; //by chef node['ip']
+ public static final String ELAPSED_TIME="AUDIT-ElapsedTime";
+ public static final String SERVER_HOST="AUDIT-Server";//by chef node['fqdn']
+ public static final String CLIENT_IP="AUDIT-ClientIPaddress";
+ public static final String CLASS="AUDIT-Classname"; //optional
+ public static final String UNUSED="AUDIT-Unused"; //empty
+ public static final String PROCESS_KEY="AUDIT-ProcessKey"; //optional
+ public static final String CUST_1="AUDIT-CustomField1";//optional
+ public static final String CUST_2="AUDIT-CustomField2"; //optional
+ public static final String CUST_3="AUDIT-CustomField3"; //optional
+ public static final String CUST_4="AUDIT-CustomField4"; //optional
+ public static final String DETAIL_MESSAGE="AUDIT-DetailMessage";//optional
+
+
+ private static final Logger log = LoggerFactory.getLogger(LogFilter.class);
+ private static final Logger AUDIT = LoggerFactory.getLogger("org.openecomp.sdnc.filters.audit");
+ @Override
+ public void destroy() {
+ }
+
+ @Override
+ public void doFilter(final ServletRequest request, final ServletResponse response,
+ final FilterChain filterChain) throws IOException, ServletException {
+
+ long startTime = System.currentTimeMillis();
+ try {
+
+ if ( request != null && request instanceof HttpServletRequest ) {
+ pre((HttpServletRequest)request);
+ }
+ filterChain.doFilter(request, response);
+
+
+ } finally {
+
+ if (request != null && request instanceof HttpServletRequest ) {
+ post((HttpServletRequest)request,(HttpServletResponse)response,startTime);
+ }
+ MDC.clear();
+ }
+
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+
+
+ private void pre(HttpServletRequest request) {
+
+ UUID uuid = UUID.randomUUID();
+ // check if uuid is in header X-ECOMP-RequestID
+
+ String ecompUUID = request.getHeader(REQUEST_ID);
+
+ if (ecompUUID != null && ecompUUID.length() > 0) {
+ try {
+ uuid = UUID.fromString(ecompUUID);
+ log.info("UUID is ECOMP UUID " + uuid.toString());
+ } catch (Exception ex){
+ log.warn("Failed to convert ECOMP UUID to java.util.UUID format:" + ecompUUID,ex);
+ }
+ }
+ MDC.put(REQUEST_ID, uuid.toString());
+
+ String userName="unknown";
+
+ /* below returning org.opendaylight.aaa.shiro.realm.TokenAuthRealm$ODLPrincipal@745dfcfe
+ if ( request.getUserPrincipal() != null) {
+ userName = request.getUserPrincipal().getName();
+ }
+ */
+ // going directly after Authorization header
+ if (request.getHeader("Authorization") != null) {
+ String authzHeader = request.getHeader("Authorization");
+ String usernameAndPassword = new String(Base64.decodeBase64(authzHeader.substring(6).getBytes()));
+
+ int userNameIndex = usernameAndPassword.indexOf(":");
+ String username = usernameAndPassword.substring(0, userNameIndex);
+ userName = username;
+
+ }
+
+
+ MDC.put(PARTNER_NAME, userName);
+ //just to initilaze for metric logger (outbound calls)
+ MDC.put("X-ECOMP-TargetEntity","");
+ MDC.put("X-ECOMP-TargetServiceName","");
+
+ MDC.put(SERVICE_NAME,request.getRequestURL().toString());
+ MDC.put(SERVICE_INSTANCE,"");
+
+ }
+
+
+ private void post(HttpServletRequest request,HttpServletResponse response,long startTime) {
+
+ //AUDIT.info("{}|{}|{}{}",request.getRemoteHost(),request.getMethod(),request.getRequestURL().toString(),request.getQueryString());
+ //AUDIT.info(request.getRemoteHost() + D + request.getMethod() + D + request.getRequestURL().toString() + D + request.getQueryString());
+ //METRIC.info(request.getMethod() + D + response.getStatus() + D + request.getRequestURL().toString() + D + (System.currentTimeMillis() - startTime) + " ms");
+ MDC.put(BEGIN_TIMESTAMP,asIso8601(startTime));
+ MDC.put(END_TIMESTAMP,asIso8601(System.currentTimeMillis()));
+ //MDC.put(REQUEST_ID,"already done above");
+ MDC.put(SERVICE_NAME,request.getRequestURL().toString());
+ int idx = request.getPathInfo().toString().lastIndexOf(":");
+ String instance = "";
+ if ( idx != -1 ) {
+ instance = request.getPathInfo().substring(idx+1);
+ }
+ MDC.put(SERVICE_INSTANCE,instance);
+ MDC.put(THREAD_ID,"");
+ MDC.put(PHYSICAL_SERVER_NAME,"");
+ //MDC.put(PARTNER_NAME,"already done above");
+ if ( response.getStatus() >= 400 ) {
+ MDC.put(STATUS_CODE,"ERROR");
+ } else {
+ MDC.put(STATUS_CODE,"COMPLETE");
+ }
+
+ MDC.put(RESP_CODE,"" + response.getStatus());
+ MDC.put(RESP_DESC,"");
+ MDC.put(INSTANCE_UUID,"");
+ MDC.put(CATEGORY,"");
+ MDC.put(SEVERITY,"");
+ //MDC.put(SERVER_IP,""); //by chef
+ MDC.put(ELAPSED_TIME,"" + (System.currentTimeMillis() - startTime));
+ //MDC.put(SERVER_HOST,""); //by chef
+ MDC.put(CLIENT_IP,request.getRemoteHost());
+ MDC.put(CLASS,"");
+ MDC.put(UNUSED,"");
+ MDC.put(PROCESS_KEY,"");
+ MDC.put(CUST_1,"");
+ MDC.put(CUST_2,"");
+ MDC.put(CUST_3,"");
+ MDC.put(CUST_4,"");
+ MDC.put(DETAIL_MESSAGE,request.getMethod());
+
+ AUDIT.info("");
+ }
+
+ private String asIso8601(Date date) {
+ TimeZone tz = TimeZone.getTimeZone("UTC");
+ DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'hh:mm:ss:SS'+00:00'");
+ df.setTimeZone(tz);
+ return df.format(date);
+ }
+
+ private String asIso8601(long tsInMillis) {
+ return asIso8601(new Date(tsInMillis));
+ }
+
+
+}
diff --git a/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java
new file mode 100644
index 0000000..5fe22b2
--- /dev/null
+++ b/filters/provider/src/main/java/org/openecomp/sdnc/filters/RequestResponseLoggingFilter.java
@@ -0,0 +1,279 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.filters;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.Inflater;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+public class RequestResponseLoggingFilter implements Filter {
+
+ private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("org.openecomp.sdnc.filters.request.response");
+
+ private static class ByteArrayServletStream extends ServletOutputStream {
+
+ ByteArrayOutputStream baos;
+
+ ByteArrayServletStream(ByteArrayOutputStream baos) {
+ this.baos = baos;
+ }
+
+ public void write(int param) throws IOException {
+ baos.write(param);
+ }
+ }
+
+ private static class ByteArrayPrintWriter {
+
+ private ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ private PrintWriter pw = new PrintWriter(baos);
+
+ private ServletOutputStream sos = new ByteArrayServletStream(baos);
+
+ public PrintWriter getWriter() {
+ return pw;
+ }
+
+ public ServletOutputStream getStream() {
+ return sos;
+ }
+
+ byte[] toByteArray() {
+ return baos.toByteArray();
+ }
+ }
+
+ private class BufferedServletInputStream extends ServletInputStream {
+
+ ByteArrayInputStream bais;
+
+ public BufferedServletInputStream(ByteArrayInputStream bais) {
+ this.bais = bais;
+ }
+
+ public int available() {
+ return bais.available();
+ }
+
+ public int read() {
+ return bais.read();
+ }
+
+ public int read(byte[] buf, int off, int len) {
+ return bais.read(buf, off, len);
+ }
+
+ }
+
+ private class BufferedRequestWrapper extends HttpServletRequestWrapper {
+
+ ByteArrayInputStream bais;
+
+ ByteArrayOutputStream baos;
+
+ BufferedServletInputStream bsis;
+
+ byte[] buffer;
+
+ public BufferedRequestWrapper(HttpServletRequest req) throws IOException {
+ super(req);
+
+ InputStream is = req.getInputStream();
+ baos = new ByteArrayOutputStream();
+ byte buf[] = new byte[1024];
+ int letti;
+ while ((letti = is.read(buf)) > 0) {
+ baos.write(buf, 0, letti);
+ }
+ buffer = baos.toByteArray();
+
+ }
+
+ public ServletInputStream getInputStream() {
+ try {
+ bais = new ByteArrayInputStream(buffer);
+ bsis = new BufferedServletInputStream(bais);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ return bsis;
+ }
+
+ public byte[] getBuffer() {
+ return buffer;
+ }
+
+ }
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
+ throws IOException, ServletException {
+
+ final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
+ BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest);
+
+ StringBuilder requestHeaders = new StringBuilder("REQUEST|");
+ requestHeaders.append(httpRequest.getMethod());
+ requestHeaders.append(":");
+ requestHeaders.append(httpRequest.getRequestURL().toString());
+ requestHeaders.append("|");
+ String header;
+ for (Enumeration<String> e = httpRequest.getHeaderNames(); e.hasMoreElements();) {
+ header = e.nextElement();
+ requestHeaders.append(header);
+ requestHeaders.append(":");
+ requestHeaders.append(httpRequest.getHeader(header));
+ requestHeaders.append(";");
+
+ }
+ log.info(requestHeaders.toString());
+
+ log.info("REQUEST BODY|" + new String(bufferedRequest.getBuffer()));
+
+ final HttpServletResponse response = (HttpServletResponse) servletResponse;
+
+ final ByteArrayPrintWriter pw = new ByteArrayPrintWriter();
+ HttpServletResponse wrappedResp = new HttpServletResponseWrapper(response) {
+ public PrintWriter getWriter() {
+ return pw.getWriter();
+ }
+
+ public ServletOutputStream getOutputStream() {
+ return pw.getStream();
+ }
+
+ };
+
+ try {
+
+ filterChain.doFilter(bufferedRequest, wrappedResp);
+
+ }catch (Exception e){
+ log.error("Chain Exception",e);
+ throw e;
+ } finally {
+ byte[] bytes = pw.toByteArray();
+ response.getOutputStream().write(bytes);
+
+ StringBuilder responseHeaders = new StringBuilder("RESPONSE HEADERS|");
+
+ for (String headerName : response.getHeaderNames()) {
+ responseHeaders.append(headerName);
+ responseHeaders.append(":");
+ responseHeaders.append(response.getHeader(headerName));
+ responseHeaders.append(";");
+
+ }
+ log.info(responseHeaders.toString());
+
+ if ("gzip".equals(response.getHeader("Content-Encoding"))) {
+
+ log.info("UNGZIPED RESPONSE BODY|" + decompressGZIPByteArray(bytes));
+
+ } else {
+
+ log.info("RESPONSE BODY|" + new String(bytes));
+ }
+ }
+ }
+
+ public void destroy() {
+ }
+
+ private String decompressGZIPByteArray(byte[] bytes) {
+
+ BufferedReader in = null;
+ InputStreamReader inR = null;
+ ByteArrayInputStream byteS = null;
+ GZIPInputStream gzS = null;
+ StringBuilder str = new StringBuilder();
+ try {
+ byteS = new ByteArrayInputStream(bytes);
+ gzS = new GZIPInputStream(byteS);
+ inR = new InputStreamReader(gzS);
+ in = new BufferedReader(inR);
+
+ if (in != null) {
+
+ String content;
+
+ while ((content = in.readLine()) != null) {
+ str.append(content);
+ }
+ }
+
+ } catch (Exception e) {
+ log.error("Failed get read GZIPInputStream", e);
+ } finally {
+
+ if (byteS != null)
+ try {
+ byteS.close();
+ } catch (IOException e1) {
+ log.error("Failed to close ByteStream", e1);
+ }
+ if (gzS != null)
+ try {
+ gzS.close();
+ } catch (IOException e2) {
+ log.error("Failed to close GZStream", e2);
+ }
+ if (inR != null)
+ try {
+ inR.close();
+ } catch (IOException e3) {
+ log.error("Failed to close InputReader", e3);
+ }
+ if (in != null)
+ try {
+ in.close();
+ } catch (IOException e) {
+ log.error("Failed to close BufferedReader", e);
+ }
+ }
+ return str.toString();
+ }
+}