use of org.apache.wss4j.dom.message.token.UsernameToken in project tesb-rt-se by Talend.
the class PropertyFileCallbackHandlerTest method testPropertyFileCallbackHandlerHashedPassword.
@Test
public void testPropertyFileCallbackHandlerHashedPassword() throws Exception {
PropertyFileCallbackHandler handler = new PropertyFileCallbackHandler();
Document doc = getDocument();
UsernameToken ut = new UsernameToken(true, doc, WSS4JConstants.PASSWORD_DIGEST);
ut.setName("tadmin");
ut.setPassword("tadmin");
Credential credential = new Credential();
credential.setUsernametoken(ut);
RequestData data = new RequestData();
try {
handler.validate(credential, data);
} catch (WSSecurityException ex) {
return;
}
Assert.fail("Expected WSSecurityException is not thrown ");
}
use of org.apache.wss4j.dom.message.token.UsernameToken in project tesb-rt-se by Talend.
the class PropertyFileCallbackHandlerTest method testPropertyFileCallbackHandlerIncorrectPasswordType.
@Test
public void testPropertyFileCallbackHandlerIncorrectPasswordType() throws Exception {
PropertyFileCallbackHandler handler = new PropertyFileCallbackHandler();
Document doc = getDocument();
UsernameToken ut = new UsernameToken(true, doc, "incorrectPasswordType");
ut.setName("tadmin");
ut.setPassword("tadmin");
Credential credential = new Credential();
credential.setUsernametoken(ut);
RequestData data = new RequestData();
try {
handler.validate(credential, data);
} catch (WSSecurityException ex) {
return;
}
Assert.fail("Expected WSSecurityException is not thrown ");
}
use of org.apache.wss4j.dom.message.token.UsernameToken in project jbossws-cxf by jbossws.
the class UsernameTokenCallbackHandler method getUsernameTokenString.
/**
* @param username
* @param password
* @return
*/
public String getUsernameTokenString(String username, String password) {
Document doc = DOMUtils.createDocument();
String result = null;
if (username != null) {
UsernameToken usernameToken = createWSSEUsernameToken(username, password, doc);
result = toString(usernameToken.getElement().getFirstChild().getParentNode());
}
return result;
}
use of org.apache.wss4j.dom.message.token.UsernameToken in project jbossws-cxf by jbossws.
the class UsernameTokenCallbackHandler method getUsernameTokenString.
/**
* Provide UsernameToken as a string.
* @param ctx
* @return
*/
public String getUsernameTokenString(Map<String, Object> ctx) {
Document doc = DOMUtils.createDocument();
String result = null;
String username = (String) ctx.get(SecurityConstants.USERNAME);
String password = (String) ctx.get(SecurityConstants.PASSWORD);
if (username != null) {
UsernameToken usernameToken = createWSSEUsernameToken(username, password, doc);
result = toString(usernameToken.getElement().getFirstChild().getParentNode());
}
return result;
}
use of org.apache.wss4j.dom.message.token.UsernameToken in project jbossws-cxf by jbossws.
the class UsernameTokenCallbackHandler method getUsernameTokenElement.
/**
* @param username
* @param password
* @return
*/
public Element getUsernameTokenElement(String username, String password) {
Document doc = DOMUtils.createDocument();
Element result = null;
UsernameToken usernameToken = null;
if (username != null) {
usernameToken = createWSSEUsernameToken(username, password, doc);
result = usernameToken.getElement();
}
return result;
}
Aggregations