Java Code Examples for java.net.HttpURLConnection#HTTP_PROXY_AUTH
The following examples show how to use
java.net.HttpURLConnection#HTTP_PROXY_AUTH .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HTTPConduit.java From cxf with Apache License 2.0 | 6 votes |
/** * This function processes any retransmits at the direction of redirections * or "unauthorized" responses. * * @return true if there was a retransmit * @throws IOException */ protected boolean processRetransmit() throws IOException { int responseCode = getResponseCode(); if ((outMessage != null) && (outMessage.getExchange() != null)) { outMessage.getExchange().put(Message.RESPONSE_CODE, responseCode); } // Process Redirects first. switch(responseCode) { case HttpURLConnection.HTTP_MOVED_PERM: case HttpURLConnection.HTTP_MOVED_TEMP: case HttpURLConnection.HTTP_SEE_OTHER: case 307: case 308: return redirectRetransmit(); case HttpURLConnection.HTTP_UNAUTHORIZED: case HttpURLConnection.HTTP_PROXY_AUTH: return authorizationRetransmit(); default: break; } return false; }
Example 2
Source File: HttpNegotiateServer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 3
Source File: HttpNegotiateServer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 4
Source File: HttpNegotiateServer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 5
Source File: HttpNegotiateServer.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 6
Source File: HttpNegotiateServer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 7
Source File: HttpNegotiateServer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 8
Source File: HttpNegotiateServer.java From hottub with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 9
Source File: HttpNegotiateServer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 10
Source File: HttpNegotiateServer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme .equalsIgnoreCase("Negotiate") ? GSSUtil.GSS_SPNEGO_MECH_OID : GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 11
Source File: HttpNegotiateServer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 12
Source File: HttpNegotiateServer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 13
Source File: HttpNegotiateServer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 14
Source File: HttpNegotiateServer.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public MyServerAuthenticator(boolean proxy, String scheme, String principal, String ktab) throws Exception { this.scheme = scheme; if (proxy) { reqHdr = "Proxy-Authenticate"; respHdr = "Proxy-Authorization"; err = HttpURLConnection.HTTP_PROXY_AUTH; } Krb5LoginModule krb5 = new Krb5LoginModule(); Map<String, String> map = new HashMap<>(); Map<String, Object> shared = new HashMap<>(); map.put("storeKey", "true"); map.put("isInitiator", "false"); map.put("useKeyTab", "true"); map.put("keyTab", ktab); map.put("principal", principal); krb5.initialize(s, null, shared, map); krb5.login(); krb5.commit(); m = GSSManager.getInstance(); cred = Subject.doAs(s, new PrivilegedExceptionAction<GSSCredential>() { @Override public GSSCredential run() throws Exception { System.err.println("Creating GSSCredential"); return m.createCredential( null, GSSCredential.INDEFINITE_LIFETIME, MyServerAuthenticator.this.scheme.equalsIgnoreCase("Negotiate")? GSSUtil.GSS_SPNEGO_MECH_OID: GSSUtil.GSS_KRB5_MECH_OID, GSSCredential.ACCEPT_ONLY); } }); }
Example 15
Source File: NvWebSocketResponseImpl.java From Javacord with Apache License 2.0 | 4 votes |
@Override public int getCode() { return HttpURLConnection.HTTP_PROXY_AUTH; }
Example 16
Source File: HTTPTestServer.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
int getUnauthorizedCode() { return authType == HttpAuthType.PROXY ? HttpURLConnection.HTTP_PROXY_AUTH : HttpURLConnection.HTTP_UNAUTHORIZED; }
Example 17
Source File: NvWebSocketResponseImpl.java From Javacord with Apache License 2.0 | 4 votes |
@Override public int getCode() { return HttpURLConnection.HTTP_PROXY_AUTH; }
Example 18
Source File: HTTPConduit.java From cxf with Apache License 2.0 | 4 votes |
protected void handleHttpRetryException(HttpRetryException e) throws IOException { String msg = "HTTP response '" + e.responseCode() + ": " + getResponseMessage() + "' invoking " + url; switch (e.responseCode()) { case HttpURLConnection.HTTP_MOVED_PERM: // 301 case HttpURLConnection.HTTP_MOVED_TEMP: // 302 case HttpURLConnection.HTTP_SEE_OTHER: // 303 case 307: msg += " that returned location header '" + e.getLocation() + "'"; break; case HttpURLConnection.HTTP_UNAUTHORIZED: // 401 if (authorizationPolicy == null || authorizationPolicy.getUserName() == null) { msg += " with NO authorization username configured in conduit " + getConduitName(); } else { msg += " with authorization username '" + authorizationPolicy.getUserName() + "'"; } break; case HttpURLConnection.HTTP_PROXY_AUTH: // 407 if (proxyAuthorizationPolicy == null || proxyAuthorizationPolicy.getUserName() == null) { msg += " with NO proxy authorization configured in conduit " + getConduitName(); } else { msg += " with proxy authorization username '" + proxyAuthorizationPolicy.getUserName() + "'"; } if (clientSidePolicy == null || clientSidePolicy.getProxyServer() == null) { if (usingProxy()) { msg += " using a proxy even if NONE is configured in CXF conduit " + getConduitName() + " (maybe one is configured by java.net.ProxySelector)"; } else { msg += " but NO proxy was used by the connection (none configured in cxf " + "conduit and none selected by java.net.ProxySelector)"; } } else { msg += " using " + clientSidePolicy.getProxyServerType() + " proxy " + clientSidePolicy.getProxyServer() + ":" + clientSidePolicy.getProxyServerPort(); } break; default: // No other type of HttpRetryException should be thrown break; } throw new IOException(msg, e); }
Example 19
Source File: Sentry.java From Sentry-Android with MIT License | 4 votes |
/** * Map from HTTP status code to reason description. * Sentry HTTP breadcrumbs expect a text description of the HTTP status-code. * This function implements a look-up table with a default value for unknown status-codes. * @param statusCode an integer HTTP status code, expected to be in the range [200,505]. * @return a non-empty string in all cases. */ private static String httpReason(int statusCode) { switch (statusCode) { // 2xx case HttpURLConnection.HTTP_OK: return "OK"; case HttpURLConnection.HTTP_CREATED: return "Created"; case HttpURLConnection.HTTP_ACCEPTED: return "Accepted"; case HttpURLConnection.HTTP_NOT_AUTHORITATIVE: return "Non-Authoritative Information"; case HttpURLConnection.HTTP_NO_CONTENT: return "No Content"; case HttpURLConnection.HTTP_RESET: return "Reset Content"; case HttpURLConnection.HTTP_PARTIAL: return "Partial Content"; // 3xx case HttpURLConnection.HTTP_MULT_CHOICE: return "Multiple Choices"; case HttpURLConnection.HTTP_MOVED_PERM: return "Moved Permanently"; case HttpURLConnection.HTTP_MOVED_TEMP: return "Temporary Redirect"; case HttpURLConnection.HTTP_SEE_OTHER: return "See Other"; case HttpURLConnection.HTTP_NOT_MODIFIED: return "Not Modified"; case HttpURLConnection.HTTP_USE_PROXY: return "Use Proxy"; // 4xx case HttpURLConnection.HTTP_BAD_REQUEST: return "Bad Request"; case HttpURLConnection.HTTP_UNAUTHORIZED: return "Unauthorized"; case HttpURLConnection.HTTP_PAYMENT_REQUIRED: return "Payment Required"; case HttpURLConnection.HTTP_FORBIDDEN: return "Forbidden"; case HttpURLConnection.HTTP_NOT_FOUND: return "Not Found"; case HttpURLConnection.HTTP_BAD_METHOD: return "Method Not Allowed"; case HttpURLConnection.HTTP_NOT_ACCEPTABLE: return "Not Acceptable"; case HttpURLConnection.HTTP_PROXY_AUTH: return "Proxy Authentication Required"; case HttpURLConnection.HTTP_CLIENT_TIMEOUT: return "Request Time-Out"; case HttpURLConnection.HTTP_CONFLICT: return "Conflict"; case HttpURLConnection.HTTP_GONE: return "Gone"; case HttpURLConnection.HTTP_LENGTH_REQUIRED: return "Length Required"; case HttpURLConnection.HTTP_PRECON_FAILED: return "Precondition Failed"; case HttpURLConnection.HTTP_ENTITY_TOO_LARGE: return "Request Entity Too Large"; case HttpURLConnection.HTTP_REQ_TOO_LONG: return "Request-URI Too Large"; case HttpURLConnection.HTTP_UNSUPPORTED_TYPE: return "Unsupported Media Type"; // 5xx case HttpURLConnection.HTTP_INTERNAL_ERROR: return "Internal Server Error"; case HttpURLConnection.HTTP_NOT_IMPLEMENTED: return "Not Implemented"; case HttpURLConnection.HTTP_BAD_GATEWAY: return "Bad Gateway"; case HttpURLConnection.HTTP_UNAVAILABLE: return "Service Unavailable"; case HttpURLConnection.HTTP_GATEWAY_TIMEOUT: return "Gateway Timeout"; case HttpURLConnection.HTTP_VERSION: return "Version Not Supported"; default: return "unknown"; } }