@Test public void testDoAuth_NoUserPassword() throws Exception { DynamicBasicAuthorizationHeader auth = new DynamicBasicAuthorizationHeader(); try { auth.setup("http: fail(); } catch (CoreException expected) { } }
@Override public void setup(String target, AdaptrisMessage msg, ResourceTargetMatcher auth) throws CoreException { try { String username = Args.notBlank(msg.resolve(getUsername()), "username"); String password = Args.notBlank(msg.resolve(getPassword()), "password"); String encoded = new Base64ByteTranslator().translate(String.format("%s:%s", username, Password.decode(password)).getBytes("UTF-8")); authHeader = String.format("Basic %s", encoded); } catch (UnsupportedEncodingException | IllegalArgumentException | PasswordException e) { throw ExceptionHelper.wrapCoreException(e); } }
DynamicBasicAuthorizationHeader implements HttpURLConnectionAuthenticator { @Override public void setup(String target, AdaptrisMessage msg, ResourceTargetMatcher auth) throws CoreException { try { String username = Args.notBlank(msg.resolve(getUsername()), "username"); String password = Args.notBlank(msg.resolve(getPassword()), "password"); String encoded = new Base64ByteTranslator().translate(String.format("%s:%s", username, Password.decode(password)).getBytes("UTF-8")); authHeader = String.format("Basic %s", encoded); } catch (UnsupportedEncodingException | IllegalArgumentException | PasswordException e) { throw ExceptionHelper.wrapCoreException(e); } } }
DynamicBasicAuthorizationHeader implements HttpURLConnectionAuthenticator { @Override public void setup(String target, AdaptrisMessage msg, ResourceTargetMatcher auth) throws CoreException { try { String username = Args.notBlank(msg.resolve(getUsername()), "username"); String password = Args.notBlank(msg.resolve(getPassword()), "password"); String encoded = new Base64ByteTranslator().translate(String.format("%s:%s", username, Password.decode(password)).getBytes("UTF-8")); authHeader = String.format("Basic %s", encoded); } catch (UnsupportedEncodingException | IllegalArgumentException | PasswordException e) { throw ExceptionHelper.wrapCoreException(e); } } DynamicBasicAuthorizationHeader();  DynamicBasicAuthorizationHeader(String username, String password); }
DynamicBasicAuthorizationHeader implements HttpURLConnectionAuthenticator { @Override public void setup(String target, AdaptrisMessage msg, ResourceTargetMatcher auth) throws CoreException { try { String username = Args.notBlank(msg.resolve(getUsername()), "username"); String password = Args.notBlank(msg.resolve(getPassword()), "password"); String encoded = new Base64ByteTranslator().translate(String.format("%s:%s", username, Password.decode(password)).getBytes("UTF-8")); authHeader = String.format("Basic %s", encoded); } catch (UnsupportedEncodingException | IllegalArgumentException | PasswordException e) { throw ExceptionHelper.wrapCoreException(e); } } DynamicBasicAuthorizationHeader();  DynamicBasicAuthorizationHeader(String username, String password); @Override void setup(String target, AdaptrisMessage msg, ResourceTargetMatcher auth); @Override void configureConnection(HttpURLConnection conn); @Override void close(); String getUsername(); void setUsername(String s); String getPassword(); void setPassword(String pw); }
DynamicBasicAuthorizationHeader implements HttpURLConnectionAuthenticator { @Override public void setup(String target, AdaptrisMessage msg, ResourceTargetMatcher auth) throws CoreException { try { String username = Args.notBlank(msg.resolve(getUsername()), "username"); String password = Args.notBlank(msg.resolve(getPassword()), "password"); String encoded = new Base64ByteTranslator().translate(String.format("%s:%s", username, Password.decode(password)).getBytes("UTF-8")); authHeader = String.format("Basic %s", encoded); } catch (UnsupportedEncodingException | IllegalArgumentException | PasswordException e) { throw ExceptionHelper.wrapCoreException(e); } } DynamicBasicAuthorizationHeader();  DynamicBasicAuthorizationHeader(String username, String password); @Override void setup(String target, AdaptrisMessage msg, ResourceTargetMatcher auth); @Override void configureConnection(HttpURLConnection conn); @Override void close(); String getUsername(); void setUsername(String s); String getPassword(); void setPassword(String pw);  }