public Megan5ServerConnector(String url,String userName,String password){
  String plainCreds=userName + ":" + password;
  byte[] plainCredsBytes=plainCreds.getBytes();
  byte[] base64CredsBytes=Base64.encodeBase64(plainCredsBytes);
  String base64Creds=new String(base64CredsBytes);
  HttpHeaders headers=new HttpHeaders();
  headers.add("Authorization","Basic " + base64Creds);
  request=new HttpEntity<>(headers);
  restTemplate=new RestTemplate();
  if (url.endsWith("/")) {
    this.url=url;
  }
 else {
    this.url=url + "/";
  }
}

public Megan5ServerConnector ( String url , String userName , String password ) { String plainCreds = userName + ":" + password ; byte [ ] plainCredsBytes = plainCreds . getBytes ( ) ; byte [ ] base64CredsBytes = Base64 . encodeBase64 ( plainCredsBytes ) ; String base64Creds = new String ( base64CredsBytes ) ; HttpHeaders headers = new HttpHeaders ( ) ; headers . add ( "Authorization" , "Basic " + base64Creds ) ; request = new HttpEntity < > ( headers ) ; restTemplate = new RestTemplate ( ) ; if ( url . endsWith ( "/" ) ) { this . url = url ; } else { this . url = url + "/" ; } }
create connection and apply authentication . < p / > ! this method doesn ' t test the connection . so things can still go wrong later !
