You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Talkov, Roger" <Ro...@automic.com> on 2015/06/24 04:43:13 UTC
Basic Authentication with the dynamic client
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.
RE: Basic Authentication with the dynamic client
Posted by "Talkov, Roger" <Ro...@automic.com>.
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:sberyozkin@gmail.com]
Sent: Wednesday, June 24, 2015 3:28 AM
To: users@cxf.apache.org
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.
Re: Basic Authentication with the dynamic client
Posted by Sergey Beryozkin <sb...@gmail.com>.
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.
>