Topic
1 reply Latest Post - ‏2012-11-06T16:51:35Z by Barbara_Jensen
VenkataBandlamudi
VenkataBandlamudi
1 Post
ACCEPTED ANSWER

Pinned topic JAX RPC CALL how set wsse:Username and wsse:Password dynamically

‏2011-11-16T16:22:07Z |
Hi All,

Is there any that we can dynamically set values the wsse:Username and wsse:Password with out using the javax.security.auth.callback.CallbackHandler in JAX RPC or else is there any way to generate the below soap header with out using the com.ibm.wsspi.wssecurity.token.UsernameTokenGenerator which is in ibm-webservicesclient-bnd.xmi file in the JAX RPC call and pass it on to the message in the service call.

We have requirement to get the username and password values from the request and pass those values to the service call. I tried this inside the callbackhandler by getting the request from FacesContext but I have the issue when I have more than one facesportlet on same page in this case FacesContext object get the current instance from current loaded thread on current loaded portlet.

<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>test-portal3</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">loadtest</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {

String serviceusername;
String servicepassword;

RenderRequest renderRequest = (RenderRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();

PortletPreferences prefs = renderRequest.getPreferences();
serviceusername = prefs.getValue("serviceusername", "");
servicepassword = prefs.getValue("servicepassword", "");
username = serviceusername;
password = servicepassword.toCharArray();

int i = 0;
if(callbacks == null || (i = callbacks.length) == 0){
System.out.println("no callbacks found::"+callbacks);
return;
}

for(int j = 0; j < i; j++)
{
Callback callback = callbacks[j];
if(callback instanceof NameCallback){
((NameCallback)callback).setName(username);
continue;
}
if(callback instanceof PasswordCallback)
{
((PasswordCallback)callback).setPassword(password);
continue;
}

}
System.out.println("username::"+username);
}
Updated on 2012-11-06T16:51:35Z at 2012-11-06T16:51:35Z by Barbara_Jensen
  • Barbara_Jensen
    Barbara_Jensen
    3 Posts
    ACCEPTED ANSWER

    Re: JAX RPC CALL how set wsse:Username and wsse:Password dynamically

    ‏2012-11-06T16:51:35Z  in response to VenkataBandlamudi
    Unfortunately, the only way that you can do this using JAX-RPC WS-Security, is to either replace the callback handler (which sets the username and password for the built-in token generator) or the entire token generator. Obviously the callback handler is the better option.