if ( soap == null )
{
return null;
}
User user = null;
Set<Object> credentials = new HashSet<Object>();
try
{
final SOAPHeaderElement securityHeader = SOAPExtractorUtil.extractSecurityHeader( soap.getSOAPPart().getEnvelope() );
if ( securityHeader == null )
{
return null;
}
Iterator childElements = securityHeader.getChildElements();
while ( childElements.hasNext() )
{
final Node securityNode = (Node) childElements.next();
if ( securityNode.getNodeType() == Node.ELEMENT_NODE )
{
final String localName = securityNode.getLocalName();
if ( "BinarySecurityToken".equalsIgnoreCase( localName ) )
{
// create a BinarySecurityToken (does some filtering and checking)
final BinarySecurityToken binaryToken = createBinarySecurityToken(securityNode);
// add the key(cert) as a credential
credentials.add(binaryToken.getKey());
}
else if ( "UsernameToken".equalsIgnoreCase(localName) )
{
UsernameToken usernameToken = createUsernameToken(securityNode);
final String userName = usernameToken.getUserName();
if ( userName != null )
{
user = new User(usernameToken.getUserName());
}
char[] passwd = usernameToken.getPassword();
if ( passwd != null )
{
credentials.add(passwd);