target/
.idea
*.iml
+.checkstyle
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-json</artifactId>
+ </exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<artifactId>httpclient</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+
<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
logging.config=${CONFIG_HOME}/logback-spring.xml
-spring.profiles.active=secure
-
-management.endpoints.web.base-path=/fproxy
\ No newline at end of file
+spring.profiles.active=secure
\ No newline at end of file
"test.auth.access\\|tenants\\|read",
"test.auth.access\\|vservers\\|read"
]
- },
- {
- "uri": "\/rproxy\/.*",
- "permissions": [
- "org\\.access\\|rproxy\\|get"
- ]
}
]
\ No newline at end of file
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-json</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
-
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
- <version>2.8.5</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
package org.onap.aaf.rproxy;
import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import java.io.File;
import java.io.FileInputStream;
import java.net.URISyntaxException;
import java.security.Principal;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.Filter;
private static final Logger LOGGER = LoggerFactory.getLogger(ReverseProxyAuthorizationFilter.class);
- private ReverseProxyAuthorization[] reverseProxyAuthorizations = new ReverseProxyAuthorization[] {};
+ private List<ReverseProxyAuthorization> reverseProxyAuthorizations = new ArrayList<>();
@Resource
private ReverseProxyURIAuthorizationProperties reverseProxyURIAuthorizationProperties;
try (InputStream inputStream =
new FileInputStream(new File(reverseProxyURIAuthorizationProperties.getConfigurationFile()));
JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream))) {
- reverseProxyAuthorizations = new Gson().fromJson(jsonReader, ReverseProxyAuthorization[].class);
+ List<ReverseProxyAuthorization> untrimmedList = new Gson().fromJson(jsonReader,
+ new TypeToken<ArrayList<ReverseProxyAuthorization>>() {}.getType());
+ untrimmedList.removeAll(Collections.singleton(null));
+ reverseProxyAuthorizations = untrimmedList;
} catch (IOException e) {
throw new ServletException("Authorizations config file not found.", e);
}
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.actuate.endpoint.InvalidEndpointRequestException;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
@RestController
restTemplate.postForEntity(forwardProxyURI, credentialCacheData, String.class);
if (!response.getStatusCode().is2xxSuccessful()) {
- throw new InvalidEndpointRequestException("Error posting to credential cache.",
- "Status code: " + response.getStatusCodeValue() + " Message: " + response.getBody());
+ throw new HttpClientErrorException(response.getStatusCode(),
+ "Error posting to credential cache. Message: " + response.getBody());
}
}
logging.config=${CONFIG_HOME}/logback-spring.xml
-spring.profiles.default=secure,cadi
-
-# For Spring Boot Actuator endpoints
-management.endpoints.web.base-path=/rproxy
\ No newline at end of file
+spring.profiles.default=secure,cadi
\ No newline at end of file