public void handle(URLConnection connection) { if (connection instanceof HttpURLConnection && matches(connection) && password != null && user != null) { if (!(connection instanceof HttpsURLConnection)) trace("using basic authentication with http instead of https, this is very insecure: %s", connection.getURL()); connection.setRequestProperty(HEADER_AUTHORIZATION, authentication); } }
public BasicAuthentication(String user, String password, Reporter reporter) { this.user = user; this.password = password; this.setReporter(reporter); init(null); }
public void setProperties(Map<String,String> map) throws Exception { super.setProperties(map); this.password = map.get(PASSWORD); this.user = map.get(USER); if (this.password == null) { error("No .password property set on this plugin %s", map); } if (this.password == null) { error("No user property set on this plugin %s", map); } String authString = user + ":" + password; try { String encoded = Base64.encodeBase64(authString.getBytes("UTF-8")); this.authentication = PREFIX_BASIC_AUTH + encoded; } catch (UnsupportedEncodingException e) { // cannot happen, UTF-8 is always present } }
@Override public void handle(URLConnection connection) { if (connection instanceof HttpURLConnection && matches(connection) && password != null && user != null) { if (!(connection instanceof HttpsURLConnection)) logger.debug("using basic authentication with http instead of https, this is very insecure: {}", connection.getURL()); connection.setRequestProperty(HEADER_AUTHORIZATION, authentication); } }
@Override public void setProperties(Map<String, String> map) throws Exception { super.setProperties(map); Config config = Converter.cnv(Config.class, map); this.password = config._password(); this.user = config.user(); init(map); }
SettingsURLConnectionHandler(ServerDTO serverDTO, Processor processor) { match = new Glob(serverDTO.match != null ? serverDTO.match : serverDTO.id); if (serverDTO.password == null) { handler = null; } else if (serverDTO.username != null) { handler = new BasicAuthentication(serverDTO.username, serverDTO.password, processor); } else { handler = new BearerAuthentication(serverDTO.password, processor); } // verify=false, trust.isEmpty -> void default check // verify=false, !trust.isEmpty -> ignore // verify=true, trust.isEmpty -> use default check // verify=true, !trust.isEmpty -> verify against given certs boolean hasCerts = serverDTO.trust != null && !serverDTO.trust.isEmpty(); if (serverDTO.verify == false || hasCerts) https = new HttpsVerification(serverDTO.trust, serverDTO.verify, processor); else https = null; // verify & no certs ==> default }
public void setProperties(Map<String,String> map) throws Exception { super.setProperties(map); this.password = map.get(PASSWORD); this.user = map.get(USER); if (this.password == null) { error("No .password property set on this plugin %s", map); } if (this.password == null) { error("No user property set on this plugin %s", map); } String authString = user + ":" + password; try { String encoded = Base64.encodeBase64(authString.getBytes("UTF-8")); this.authentication = PREFIX_BASIC_AUTH + encoded; } catch (UnsupportedEncodingException e) { // cannot happen, UTF-8 is always present } }
@Override public void handle(URLConnection connection) { if (connection instanceof HttpURLConnection && matches(connection) && password != null && user != null) { if (!(connection instanceof HttpsURLConnection)) logger.debug("using basic authentication with http instead of https, this is very insecure: {}", connection.getURL()); connection.setRequestProperty(HEADER_AUTHORIZATION, authentication); } }
@Override public void setProperties(Map<String, String> map) throws Exception { super.setProperties(map); Config config = Converter.cnv(Config.class, map); this.password = config._password(); this.user = config.user(); init(map); }
SettingsURLConnectionHandler(ServerDTO serverDTO, Processor processor) { match = new Glob(serverDTO.match != null ? serverDTO.match : serverDTO.id); if (serverDTO.password == null) { handler = null; } else if (serverDTO.username != null) { handler = new BasicAuthentication(serverDTO.username, serverDTO.password, processor); } else { handler = new BearerAuthentication(serverDTO.password, processor); } // verify=false, trust.isEmpty -> void default check // verify=false, !trust.isEmpty -> ignore // verify=true, trust.isEmpty -> use default check // verify=true, !trust.isEmpty -> verify against given certs boolean hasCerts = serverDTO.trust != null && !serverDTO.trust.isEmpty(); if (serverDTO.verify == false || hasCerts) https = new HttpsVerification(serverDTO.trust, serverDTO.verify, processor); else https = null; // verify & no certs ==> default }
public void handle(URLConnection connection) { if (connection instanceof HttpURLConnection && matches(connection) && password != null && user != null) { if (!(connection instanceof HttpsURLConnection)) trace("using basic authentication with http instead of https, this is very insecure: %s", connection.getURL()); connection.setRequestProperty(HEADER_AUTHORIZATION, authentication); } }
private void init(Map<String, String> map) { if (this.password == null) { error("No .password property set on this plugin %s", map); } if (this.user == null) { error("No user property set on this plugin %s", map); } String authString = user + ":" + password; try { String encoded = Base64.encodeBase64(authString.getBytes(UTF_8)); this.authentication = PREFIX_BASIC_AUTH + encoded; sha = SHA1.digest(password.getBytes()) .asHex(); } catch (Exception e) { // cannot happen, UTF-8 is always present } }
public BasicAuthentication(String user, String password, Reporter reporter) { this.user = user; this.password = password; this.setReporter(reporter); init(null); }
private void init(Map<String, String> map) { if (this.password == null) { error("No .password property set on this plugin %s", map); } if (this.user == null) { error("No user property set on this plugin %s", map); } String authString = user + ":" + password; try { String encoded = Base64.encodeBase64(authString.getBytes(UTF_8)); this.authentication = PREFIX_BASIC_AUTH + encoded; sha = SHA1.digest(password.getBytes()) .asHex(); } catch (Exception e) { // cannot happen, UTF-8 is always present } }