BasicAuthSupplier is my own custom supplier:
class BasicAuthSupplier implements HttpAuthSupplier
{
boolean preemptive
public BasicAuthSupplier(boolean preemptive)
{
this.preemptive = preemptive
}
/**
* send the encoded user & password
*/
@Override
public String getAuthorization(AuthorizationPolicy authPolicy, URI arg1,
Message arg2, String arg3)
{
String userAndPass = authPolicy.getUserName() + ":" +
authPolicy.getPassword();
// arg3 is the auth challenge header
//This is called first with no challenge then again after the challenge
if ( arg3 == null && !preemptive)
{
return null;
}
return "Basic " + Base64Utility.encode(userAndPass.getBytes());
}
@Override
public boolean requiresRequestCaching()
{
//This must be true for getAuthorization to be called
//again after the auth challenge
return true;
}
}
-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]]
Sent: Wednesday, June 24, 2015 3:28 AM
To: [email protected]
Cc: DelBusto, George
Subject: Re: Basic Authentication with the dynamic client
Hi, you might need to implement your own custom supplier, possibly extending
BasicAuthSupplier
Thanks, Sergey
On 24/06/15 03:43, Talkov, Roger wrote:
> We have Basic Authentication working for the dynamic client with user
> & password, But have not been able to figure out how to set Host, Port, and
> Realm.
>
> Our current code is similar to below:
>
> HTTPConduit httpc = (HTTPConduit) client.getConduit();
>
> AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy();
> authorizationPolicy.setUserName (user);
> authorizationPolicy.setPassword (password);
> authorizationPolicy.setAuthorizationType ("Basic");
> httpc.setAuthorization(authorizationPolicy);
>
> // does Base64 encoding of user & password BasicAuthSupplier
> authSupplier = new BasicAuthSupplier (isPreemptiveAuthentication ());
> httpc.setAuthSupplier(authSupplier);
>
> Thanks,
>
> Roger
>
>
> This email (including any attachments) may contain information which is
> privileged, confidential, or protected. If you are not the intended
> recipient, note that any disclosure, copying, distribution, or use of the
> contents of this message and attached files is prohibited. If you have
> received this email in error, please notify the sender and delete this email
> and any attached files.
>
This email (including any attachments) may contain information which is
privileged, confidential, or protected. If you are not the intended recipient,
note that any disclosure, copying, distribution, or use of the contents of this
message and attached files is prohibited. If you have received this email in
error, please notify the sender and delete this email and any attached files.