Re: Set WSS basic authentication on org.apache.axis.client.Stub

2018-02-18 Thread Martin Gainty
  AlgorithmSuiteValidator(algorithmSuite);

algorithmSuiteValidator.checkDerivedKeyAlgorithm(

((WSDerivedKeyTokenPrincipal)principal).getAlgorithm()
);
algorithmSuiteValidator.checkSignatureDerivedKeyLength(
((WSDerivedKeyTokenPrincipal)principal).getLength()
);
}

return samlKeyInfo;
}
}
node = node.getNextSibling();
}

//
// Next marshal the KeyInfo DOM element into a javax KeyInfo object and 
get the
// (public key) credential
//
X509Certificate[] certs = null;
KeyInfoFactory keyInfoFactory = null;
try {
keyInfoFactory = KeyInfoFactory.getInstance("DOM", "ApacheXMLDSig");
} catch (NoSuchProviderException ex) {
keyInfoFactory = KeyInfoFactory.getInstance("DOM");
}
XMLStructure keyInfoStructure = new DOMStructure(keyInfoElement);

try {
javax.xml.crypto.dsig.keyinfo.KeyInfo keyInfo =
keyInfoFactory.unmarshalKeyInfo(keyInfoStructure);
List list = keyInfo.getContent();

for (int i = 0; i < list.size(); i++) {
XMLStructure xmlStructure = (XMLStructure) list.get(i);
if (xmlStructure instanceof KeyValue) {
PublicKey publicKey = 
((KeyValue)xmlStructure).getPublicKey();
return new SAMLKeyInfo(publicKey);
} else if (xmlStructure instanceof X509Data) {
List x509Data = ((X509Data)xmlStructure).getContent();
for (int j = 0; j < x509Data.size(); j++) {
Object x509obj = x509Data.get(j);
if (x509obj instanceof X509Certificate) {
certs = new X509Certificate[1];
certs[0] = (X509Certificate)x509obj;
return new SAMLKeyInfo(certs);  //certs are null 
which causes the error you are seeing

since you are new to wss4j why not use the predefined tests here are 2 you can 
use right away

grep -S -l "certs =" *cert*.*

wss4j/src/test/java/org/apache/ws/security/components/crypto/CertificateStoreTest.java
wss4j/src/test/java/org/apache/ws/security/message/SignatureCertTest.java

HTH
Martin
__

 _ _  _ _  _ ___ _  
  _   _ _   _  |_   _| |_ ___   |  _  |___ ___ 
___| |_ ___   |   __|___|  _| |_ _ _ _ ___ ___ ___   |   __|___ _ _ ___ _| 
|___| |_|_|___ ___| | |   | -_|  | | . | .'|  _|   | -_|  |__   | . |  
_|  _| | | | .'|  _| -_|  |   __| . | | |   | . | .'|  _| | . |   |   |_| 
|_|_|___|  |__|__|  _|__,|___|_|_|___|  |_|___|_| |_| |_|__,|_| |___|  
|__|  |___|___|_|_|___|__,|_| |_|___|_|_||_|




From: Lapin Blanc <fabien.to...@lapin-blanc.com>
Sent: Sunday, February 18, 2018 9:18 AM
To: users@ws.apache.org
Subject: Set WSS basic authentication on org.apache.axis.client.Stub

Hi,

I've created a SOAP client stub using Eclipse WST on a wsdl file from a service 
provider I have to use.
To access this service I need to authenticate, with a really basic clear text 
username/password.

The stub I'm trying to use inherit from org.apache.axis.client.Stub.

I first tried the "regular" way, by setting username and password properties on 
the stub before my action is invoked. Nevertheless, the system refused my 
credential, complaining about the absence of any token :

{}description:L'authentification a échoué : aucune information de sécurité 
reçue (WSS X509 ou WSS UsernameToken)
{}description:Authentication failed : no proven X509 certificate or username 
token found

Then I analyzed what SoapUI generated like XML request and saw that it actually 
adds WSS headers to the request :



etnic
mailto:mac...@truc.be>">

false
false
PasswordText





This way, no problem, I got the correct answer.

But I can't really figure out how to do this programmatically into my project 
without having to dig deep into the XML headers etc.

I tried to understand the doc at several places (especially 
https://ws.apache.org/wss4 ), but it's overwhelming, I'm wondering if there is 
a simple approach...

Any help is very, very welcome... :-)


Set WSS basic authentication on org.apache.axis.client.Stub

2018-02-18 Thread Lapin Blanc
Hi,

I've created a SOAP client stub using Eclipse WST on a wsdl file from a
service provider I have to use.
To access this service I need to authenticate, with a really basic clear
text username/password.

The stub I'm trying to use inherit from org.apache.axis.client.Stub.

I first tried the "regular" way, by setting username and password
properties on the stub before my action is invoked. Nevertheless, the
system refused my credential, complaining about the absence of any token :

{}description:L'authentification a échoué : aucune information de sécurité
reçue (WSS X509 ou WSS UsernameToken)
{}description:Authentication failed : no proven X509 certificate or
username token found

Then I analyzed what SoapUI generated like XML request and saw that it
actually adds WSS headers to the request :



etnic


false
false
PasswordText





This way, no problem, I got the correct answer.

But I can't really figure out how to do this programmatically into my
project without having to dig deep into the XML headers etc.

I tried to understand the doc at several places (especially
https://ws.apache.org/wss4 ), but it's overwhelming, I'm wondering if there
is a simple approach...

Any help is very, very welcome... :-)