Merge r1025934 TUSCANY-3735: Don't use HTTP authorization or authentication by default
git-svn-id: https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk@1027705 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java b/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
index 92ccf2c..5982d77 100644
--- a/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
+++ b/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
@@ -96,7 +96,9 @@
// Send an HTTP GET
GetMethod getMethod = new GetMethod(uri + "/" + id);
- getMethod.setRequestHeader("Authorization", authorizationHeader);
+ if (authorizationHeader != null) {
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+ }
boolean parsing = false;
try {
httpClient.executeMethod(getMethod);
@@ -173,7 +175,9 @@
// Send an HTTP POST
PostMethod postMethod = new PostMethod(uri);
- postMethod.setRequestHeader("Authorization", authorizationHeader);
+ if (authorizationHeader != null) {
+ postMethod.setRequestHeader("Authorization", authorizationHeader);
+ }
boolean parsing = false;
try {
@@ -259,7 +263,9 @@
// Send an HTTP PUT
PutMethod putMethod = new PutMethod(uri + "/" + id);
- putMethod.setRequestHeader("Authorization", authorizationHeader);
+ if (authorizationHeader != null) {
+ putMethod.setRequestHeader("Authorization", authorizationHeader);
+ }
try {
@@ -310,7 +316,9 @@
// Send an HTTP DELETE
DeleteMethod deleteMethod = new DeleteMethod(uri + "/" + id);
- deleteMethod.setRequestHeader("Authorization", authorizationHeader);
+ if (authorizationHeader != null) {
+ deleteMethod.setRequestHeader("Authorization", authorizationHeader);
+ }
try {
httpClient.executeMethod(deleteMethod);
int status = deleteMethod.getStatusCode();
@@ -351,7 +359,9 @@
// Send an HTTP GET
GetMethod getMethod = new GetMethod(uri);
- getMethod.setRequestHeader("Authorization", authorizationHeader);
+ if (authorizationHeader != null) {
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+ }
boolean parsing = false;
try {
httpClient.executeMethod(getMethod);
@@ -427,7 +437,9 @@
// Send an HTTP GET
GetMethod getMethod = new GetMethod(uri);
- getMethod.setRequestHeader("Authorization", authorizationHeader);
+ if (authorizationHeader != null) {
+ getMethod.setRequestHeader("Authorization", authorizationHeader);
+ }
getMethod.setQueryString(queryString);
boolean parsing = false;
try {
diff --git a/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java b/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
index 65331af..1961146 100644
--- a/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
+++ b/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java
@@ -49,7 +49,7 @@
private RuntimeComponentReference reference;
private AtomBinding binding;
- private String authorizationHeader;
+ private String authorizationHeader = null;
private HttpClient httpClient;
private Mediator mediator;
private DataType<?> itemClassType;
@@ -72,8 +72,10 @@
this.mediator = mediator;
// Prepare authorization header
- String authorization = "admin" + ":" + "admin";
- authorizationHeader = "Basic " + new String(Base64.encodeBase64(authorization.getBytes()));
+ // TUSCANY-3735: Don't send authorization header by default as this can cause problems.
+ // Commented out the following two lines until we have a better way to control this.
+ //String authorization = "admin" + ":" + "admin";
+ //authorizationHeader = "Basic " + new String(Base64.encodeBase64(authorization.getBytes()));
// Create an HTTP client
HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
@@ -124,10 +126,12 @@
public void start() {
// Configure the HTTP client credentials
- Credentials credentials = new UsernamePasswordCredentials("admin", "admin");
- httpClient.getParams().setAuthenticationPreemptive(true);
- URI uri = URI.create(binding.getURI());
- httpClient.getState().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), credentials);
+ // TUSCANY-3735: Don't use authentication by default as this can cause problems.
+ // Commented out the following four lines until we have a better way to control this.
+ //Credentials credentials = new UsernamePasswordCredentials("admin", "admin");
+ //httpClient.getParams().setAuthenticationPreemptive(true);
+ //URI uri = URI.create(binding.getURI());
+ //httpClient.getState().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), credentials);
// Find the get operation on the reference interface
if (true) {