summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2014-05-26 00:45:49 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2014-05-27 10:20:42 +0200
commitf80b41fbc1830316800d25c8e4c283dd96464956 (patch)
treee1f28b62b71db0bad752bee11d4b48d4ef271bf1
parentc1f11fafce265a1bf1156e54324d9bae7b3c4faa (diff)
downloadjgit-f80b41fbc1830316800d25c8e4c283dd96464956.tar.gz
jgit-f80b41fbc1830316800d25c8e4c283dd96464956.zip
Fix authentication type names broken by 0b5441a8
0b5441a8 introduced an enum for authentication types and changed the case of digest and basic authentication type names to all uppercase. This broke digest authentication at least when using Gerrit as the git server. According to RFC2617 [1] "Basic" and "Digest" is the literal to be used in authentication headers and not "BASIC" [1] and "DIGEST" [2]. According to RFC4559 "Negotiate" [3] is used for SPNEGO based authentication. [1] http://tools.ietf.org/html/rfc2617#page-5 [2] http://tools.ietf.org/html/rfc2617#page-8 [3] http://tools.ietf.org/html/rfc4559#page-3 Bug: 435866 Change-Id: I6173aff9352d7def225cafe2d73e5176ad40dff0 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
index 47cbf691f4..3594ea91b4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
@@ -85,24 +85,44 @@ abstract class HttpAuthMethod {
public HttpAuthMethod method(String hdr) {
return None.INSTANCE;
}
+
+ @Override
+ public String getSchemeName() {
+ return "None"; //$NON-NLS-1$
+ }
},
BASIC {
@Override
public HttpAuthMethod method(String hdr) {
return new Basic();
}
+
+ @Override
+ public String getSchemeName() {
+ return "Basic"; //$NON-NLS-1$
+ }
},
DIGEST {
@Override
public HttpAuthMethod method(String hdr) {
return new Digest(hdr);
}
+
+ @Override
+ public String getSchemeName() {
+ return "Digest"; //$NON-NLS-1$
+ }
},
NEGOTIATE {
@Override
public HttpAuthMethod method(String hdr) {
return new Negotiate(hdr);
}
+
+ @Override
+ public String getSchemeName() {
+ return "Negotiate"; //$NON-NLS-1$
+ }
};
/**
* Creates a HttpAuthMethod instance configured with the provided HTTP
@@ -112,6 +132,13 @@ abstract class HttpAuthMethod {
* @return a configured HttpAuthMethod instance
*/
public abstract HttpAuthMethod method(String hdr);
+
+ /**
+ * @return the name of the authentication scheme in the form to be used
+ * in HTTP authentication headers as specified in RFC2617 and
+ * RFC4559
+ */
+ public abstract String getSchemeName();
}
static final String EMPTY_STRING = ""; //$NON-NLS-1$
@@ -270,7 +297,7 @@ abstract class HttpAuthMethod {
void configureRequest(final HttpConnection conn) throws IOException {
String ident = user + ":" + pass; //$NON-NLS-1$
String enc = Base64.encodeBytes(ident.getBytes("UTF-8")); //$NON-NLS-1$
- conn.setRequestProperty(HDR_AUTHORIZATION, type.name()
+ conn.setRequestProperty(HDR_AUTHORIZATION, type.getSchemeName()
+ " " + enc); //$NON-NLS-1$
}
}
@@ -357,7 +384,7 @@ abstract class HttpAuthMethod {
v.append(e.getValue());
v.append('"');
}
- conn.setRequestProperty(HDR_AUTHORIZATION, type.name()
+ conn.setRequestProperty(HDR_AUTHORIZATION, type.getSchemeName()
+ " " + v); //$NON-NLS-1$
}
@@ -514,7 +541,7 @@ abstract class HttpAuthMethod {
byte[] token = context.initSecContext(prevToken, 0,
prevToken.length);
- conn.setRequestProperty(HDR_AUTHORIZATION, getType().name()
+ conn.setRequestProperty(HDR_AUTHORIZATION, getType().getSchemeName()
+ " " + Base64.encodeBytes(token)); //$NON-NLS-1$
} catch (GSSException e) {
IOException ioe = new IOException();