Class SpnegoSOAPConnection
java.lang.Object
jakarta.xml.soap.SOAPConnection
org.silverpeas.sso.kerberos.spnego.SpnegoSOAPConnection
- All Implemented Interfaces:
AutoCloseable
public class SpnegoSOAPConnection
extends jakarta.xml.soap.SOAPConnection
This class can be used to make SOAP calls to a protected SOAP Web Service.
The idea for this class is to replace code that looks like this...
final SOAPConnectionFactory soapConnectionFactory =
SOAPConnectionFactory.newInstance();
conn = soapConnectionFactory.createConnection();
with code that looks like this...
conn = new SpnegoSOAPConnection("spnego-client", "dfelix", "myp@s5");
Example:
SOAPMessage response = null;
final SpnegoSOAPConnection conn =
new SpnegoSOAPConnection(this.module, this.kuser, this.kpass);
try {
final MessageFactory msgFactory = MessageFactory.newInstance();
final SOAPMessage message = msgFactory.createMessage();
final SOAPBody body = message.getSOAPBody();
final SOAPBodyElement bodyElement = body.addBodyElement(
new QName(this.namespace, this.methodName, this.nsprefix));
for (int i=0; i<args.length; i++) {
final SOAPElement element = bodyElement.addChildElement(
new QName("arg" + i));
element.addTextNode(args[i]);
}
response = conn.call(message, this.serviceLocation);
} finally {
conn.close();
}
To see a full working example, take a look at the ExampleSpnegoSOAPClient.java example.
Also, take a look at the how to connect to a protected SOAP Web Service example.
- Author:
- Darwin V. Felix
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSpnegoSOAPConnection(String loginModuleName) Creates an instance where the LoginContext relies on a keytab file being specified by "java.security.auth.login.config" or where LoginContext relies on tgtsessionkey.SpnegoSOAPConnection(String loginModuleName, String username, String password) Creates an instance where the LoginContext does not require a keytab file.Create an instance where the GSSCredential is specified by the parameter and where the GSSCredential is automatically disposed after use.SpnegoSOAPConnection(GSSCredential creds, boolean dispose) Create an instance where the GSSCredential is specified by the parameter and whether the GSSCredential should be disposed after use. -
Method Summary
Methods inherited from class jakarta.xml.soap.SOAPConnection
get, getConnectTimeout, getReadTimeout, setConnectTimeout, setReadTimeout
-
Constructor Details
-
SpnegoSOAPConnection
Creates an instance where the LoginContext relies on a keytab file being specified by "java.security.auth.login.config" or where LoginContext relies on tgtsessionkey.- Parameters:
loginModuleName- the name of the login module- Throws:
LoginException- if the login fails
-
SpnegoSOAPConnection
Create an instance where the GSSCredential is specified by the parameter and where the GSSCredential is automatically disposed after use.- Parameters:
creds- credentials to use
-
SpnegoSOAPConnection
Create an instance where the GSSCredential is specified by the parameter and whether the GSSCredential should be disposed after use.- Parameters:
creds- credentials to usedispose- true if GSSCredential should be diposed after use
-
SpnegoSOAPConnection
public SpnegoSOAPConnection(String loginModuleName, String username, String password) throws LoginException Creates an instance where the LoginContext does not require a keytab file. However, the "java.security.auth.login.config" property must still be set prior to instantiating this object.- Parameters:
loginModuleName- the name of the login moduleusername- the login id of the userpassword- the login password of the user- Throws:
LoginException- if the login fails
-
-
Method Details
-
call
public final jakarta.xml.soap.SOAPMessage call(jakarta.xml.soap.SOAPMessage request, Object endpoint) throws jakarta.xml.soap.SOAPException - Specified by:
callin classjakarta.xml.soap.SOAPConnection- Throws:
jakarta.xml.soap.SOAPException
-
close
public final void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classjakarta.xml.soap.SOAPConnection
-