axis2 - why pwcb.getPassword is null in this code -
i try add rampart security axis2 web service using rampart module.
so here have made:
- i have stored in database hashed value of "bobwww" password , salt
in pwcbhandler.java class
•i select stored in database password , hash
•i try hash same algorithm pwcb.getpassword() same stored salt
•check if new hashed password equal stored password
but receiving nullpointerexception decide check , wrote code
if(pwcb.getpassword()==null) { try { throw new exception ("passwordget pass null" +pwcb.getpassword()); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } }
and see pwcb.getpassword() empty. here code of pwcbhandler.java
public void handle(callback[] callbacks) throws ioexception, unsupportedcallbackexception { (int = 0; < callbacks.length; i++) { wspasswordcallback pwcb = (wspasswordcallback)callbacks[i]; try { pasandsalt = getdataforchecking(); if(pwcb.getpassword()==null) { try { throw new exception ("passwordget pass null" +pwcb.getpassword()); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } } try { passwordforchecking = hash(pwcb.getpassword(),base64.decodebase64(pasandsalt[1])); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } if((pwcb.getidentifier().equals("bob")) && (passwordforchecking.equals(pasandsalt[0])) ) { return; } }
and here soaprequest sequeiry header
var sr = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<soapenv:envelope " + "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " + "xmlns:nilo=\"http://nilo\">"+ "<soapenv:header>"+ '<wsse:security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" soapenv:mustunderstand="1">'+ '<wsse:usernametoken xmlns:wsu="http://docs.oasisopen.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:id="123">'+ '<wsse:username>bob</wsse:username>'+ '<wsse:password type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#passwordtext">bobwww</wsse:password>'+ '</wsse:usernametoken>'+ '</wsse:security>'+ "</soapenv:header>"+ "<soapenv:body>" + "<nilo:getdataforchecking>" + '<nilo:data>'+tranxml+'</nilo:data>' + ' </nilo:getdataforchecking>'+ '</soapenv:body>' + '</soapenv:envelope>';
according soap headers can see using plain text password instead of password digest. might need change rampart configuration
<wsse:password type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#passwordtext">bobwww</wsse:password>
this might helpful you. http://wso2.com/library/240/
Comments
Post a Comment