diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-11-25 17:17:20 +0100 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-12-27 16:57:38 +0100 |
commit | c310fa0c802f40a774edb58641de3ac5bfad0e2c (patch) | |
tree | 28dc002136ce8a2c122e2cb012a317aa7d8a0efa /org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java | |
parent | 03d50dc50b584caf2826f7db8a4748435b610f63 (diff) | |
download | jgit-c310fa0c802f40a774edb58641de3ac5bfad0e2c.tar.gz jgit-c310fa0c802f40a774edb58641de3ac5bfad0e2c.zip |
Mark non-externalizable strings as such
A few classes such as Constanrs are marked with @SuppressWarnings, as are
toString() methods with many liternal, but otherwise $NLS-n$ is used for
string containing text that should not be translated. A few literals may
fall into the gray zone, but mostly I've tried to only tag the obvious
ones.
Change-Id: I22e50a77e2bf9e0b842a66bdf674e8fa1692f590
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java | 87 |
1 files changed, 43 insertions, 44 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 bcf0a8ba21..4ab7998f5c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java @@ -164,7 +164,7 @@ abstract class HttpAuthMethod { /** Performs HTTP basic authentication (plaintext username/password). */ private static class Basic extends HttpAuthMethod { - static final String NAME = "Basic"; + static final String NAME = "Basic"; //$NON-NLS-1$ private String user; @@ -178,15 +178,15 @@ abstract class HttpAuthMethod { @Override void configureRequest(final HttpURLConnection conn) throws IOException { - String ident = user + ":" + pass; - String enc = Base64.encodeBytes(ident.getBytes("UTF-8")); - conn.setRequestProperty(HDR_AUTHORIZATION, NAME + " " + enc); + String ident = user + ":" + pass; //$NON-NLS-1$ + String enc = Base64.encodeBytes(ident.getBytes("UTF-8")); //$NON-NLS-1$ + conn.setRequestProperty(HDR_AUTHORIZATION, NAME + " " + enc); //$NON-NLS-1$ } } /** Performs HTTP digest authentication. */ private static class Digest extends HttpAuthMethod { - static final String NAME = "Digest"; + static final String NAME = "Digest"; //$NON-NLS-1$ private static final Random PRNG = new Random(); @@ -201,11 +201,11 @@ abstract class HttpAuthMethod { Digest(String hdr) { params = parse(hdr); - final String qop = params.get("qop"); - if ("auth".equals(qop)) { + final String qop = params.get("qop"); //$NON-NLS-1$ + if ("auth".equals(qop)) { //$NON-NLS-1$ final byte[] bin = new byte[8]; PRNG.nextBytes(bin); - params.put("cnonce", Base64.encodeBytes(bin)); + params.put("cnonce", Base64.encodeBytes(bin)); //$NON-NLS-1$ } } @@ -220,67 +220,66 @@ abstract class HttpAuthMethod { void configureRequest(final HttpURLConnection conn) throws IOException { final Map<String, String> r = new LinkedHashMap<String, String>(); - final String realm = params.get("realm"); - final String nonce = params.get("nonce"); - final String cnonce = params.get("cnonce"); + final String realm = params.get("realm"); //$NON-NLS-1$ + final String nonce = params.get("nonce"); //$NON-NLS-1$ + final String cnonce = params.get("cnonce"); //$NON-NLS-1$ final String uri = uri(conn.getURL()); - final String qop = params.get("qop"); + final String qop = params.get("qop"); //$NON-NLS-1$ final String method = conn.getRequestMethod(); - final String A1 = user + ":" + realm + ":" + pass; - final String A2 = method + ":" + uri; + final String A1 = user + ":" + realm + ":" + pass; //$NON-NLS-1$ //$NON-NLS-2$ + final String A2 = method + ":" + uri; //$NON-NLS-1$ - r.put("username", user); - r.put("realm", realm); - r.put("nonce", nonce); - r.put("uri", uri); + r.put("username", user); //$NON-NLS-1$ + r.put("realm", realm); //$NON-NLS-1$ + r.put("nonce", nonce); //$NON-NLS-1$ + r.put("uri", uri); //$NON-NLS-1$ final String response, nc; - if ("auth".equals(qop)) { - nc = String.format("%08x", ++requestCount); - response = KD(H(A1), nonce + ":" + nc + ":" + cnonce + ":" - + qop - + ":" + if ("auth".equals(qop)) { //$NON-NLS-1$ + nc = String.format("%08x", ++requestCount); //$NON-NLS-1$ + response = KD(H(A1), nonce + ":" + nc + ":" + cnonce + ":" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + qop + ":" //$NON-NLS-1$ + H(A2)); } else { nc = null; - response = KD(H(A1), nonce + ":" + H(A2)); + response = KD(H(A1), nonce + ":" + H(A2)); //$NON-NLS-1$ } - r.put("response", response); - if (params.containsKey("algorithm")) - r.put("algorithm", "MD5"); + r.put("response", response); //$NON-NLS-1$ + if (params.containsKey("algorithm")) //$NON-NLS-1$ + r.put("algorithm", "MD5"); //$NON-NLS-1$ //$NON-NLS-2$ if (cnonce != null && qop != null) - r.put("cnonce", cnonce); - if (params.containsKey("opaque")) - r.put("opaque", params.get("opaque")); + r.put("cnonce", cnonce); //$NON-NLS-1$ + if (params.containsKey("opaque")) //$NON-NLS-1$ + r.put("opaque", params.get("opaque")); //$NON-NLS-1$ //$NON-NLS-2$ if (qop != null) - r.put("qop", qop); + r.put("qop", qop); //$NON-NLS-1$ if (nc != null) - r.put("nc", nc); + r.put("nc", nc); //$NON-NLS-1$ StringBuilder v = new StringBuilder(); for (Map.Entry<String, String> e : r.entrySet()) { if (v.length() > 0) - v.append(", "); + v.append(", "); //$NON-NLS-1$ v.append(e.getKey()); v.append('='); v.append('"'); v.append(e.getValue()); v.append('"'); } - conn.setRequestProperty(HDR_AUTHORIZATION, NAME + " " + v); + conn.setRequestProperty(HDR_AUTHORIZATION, NAME + " " + v); //$NON-NLS-1$ } private static String uri(URL u) { StringBuilder r = new StringBuilder(); r.append(u.getProtocol()); - r.append("://"); + r.append("://"); //$NON-NLS-1$ r.append(u.getHost()); if (0 < u.getPort()) { - if (u.getPort() == 80 && "http".equals(u.getProtocol())) { + if (u.getPort() == 80 && "http".equals(u.getProtocol())) { //$NON-NLS-1$ /* nothing */ } else if (u.getPort() == 443 - && "https".equals(u.getProtocol())) { + && "https".equals(u.getProtocol())) { //$NON-NLS-1$ /* nothing */ } else { r.append(':').append(u.getPort()); @@ -295,30 +294,30 @@ abstract class HttpAuthMethod { private static String H(String data) { try { MessageDigest md = newMD5(); - md.update(data.getBytes("UTF-8")); + md.update(data.getBytes("UTF-8")); //$NON-NLS-1$ return LHEX(md.digest()); } catch (UnsupportedEncodingException e) { - throw new RuntimeException("UTF-8 encoding not available", e); + throw new RuntimeException("UTF-8 encoding not available", e); //$NON-NLS-1$ } } private static String KD(String secret, String data) { try { MessageDigest md = newMD5(); - md.update(secret.getBytes("UTF-8")); + md.update(secret.getBytes("UTF-8")); //$NON-NLS-1$ md.update((byte) ':'); - md.update(data.getBytes("UTF-8")); + md.update(data.getBytes("UTF-8")); //$NON-NLS-1$ return LHEX(md.digest()); } catch (UnsupportedEncodingException e) { - throw new RuntimeException("UTF-8 encoding not available", e); + throw new RuntimeException("UTF-8 encoding not available", e); //$NON-NLS-1$ } } private static MessageDigest newMD5() { try { - return MessageDigest.getInstance("MD5"); + return MessageDigest.getInstance("MD5"); //$NON-NLS-1$ } catch (NoSuchAlgorithmException e) { - throw new RuntimeException("No MD5 available", e); + throw new RuntimeException("No MD5 available", e); //$NON-NLS-1$ } } |