UNSIBSCRIBE
by Glib
---------------------------------
Want to be your own boss? Learn how on Yahoo! Small Business.
19 years, 9 months
[JBossWS] - can not get user and password from header
by pkroman
Hallo. I have written a simple WebService called TrivialService
on JBoss 4.0.4:
package org.jboss.test.ws.samples.rpcstyle;
| import java.rmi.Remote;
| import java.rmi.RemoteException;
| public interface TrivialService extends Remote
| {
| String request(String string1, String string2) throws RemoteException;
| }
package org.jboss.test.ws.samples.rpcstyle;
| import javax.xml.namespace.QName;
| public class TrivialEndpoint implements TrivialService
| {
| public String request(String string1, String string2)
| {
| return "ok " + string1 + " " + string2;
| }
| }
Then I have written a handler to have access to the user and password within the header:
package org.jboss.test.ws.samples.rpcstyle;
| import java.io.File;
| import java.io.FileInputStream;
| import java.io.IOException;
| import java.io.InputStream;
| import java.util.Iterator;
| import javax.xml.namespace.QName;
| import javax.xml.rpc.JAXRPCException;
| import javax.xml.rpc.handler.*;
| import javax.xml.rpc.handler.soap.SOAPMessageContext;
| import javax.xml.soap.*;
| public class ServerSideHandler extends GenericHandler
| {
| protected QName[] headers = new QName[]
| {
| };
|
| public QName[] getHeaders()
| {
| String NAMESPACE = "http://org.jboss.ws/samples/rpcstyle";
| QName SERVICE_NAME = new QName NAMESPACE,"TrivialService");
| QName[] qNames = {SERVICE_NAME};
| return qNames;
| }
|
| public boolean handleRequest(MessageContext msgContext)
| {
| System.out.print("handleRequeste");
| String user = (String) msgContext.getProperty("USERNAME_PROPERTY");
| String password = (String) msgContext.getProperty("PASSWORD_PROPERTY");
| System.out.print("user: " + user);
| System.out.print("password: " + password);
|
| return super.handleRequest(msgContext);
| }
|
| public boolean handleResponse(MessageContext msgContext)
| {
| System.out.print("handleResponse");
| return true;
| }
| }
And I put this to webservices.xml (in port-component tag):
<handler>
| <handler-name>ServerSideHandler</handler-name>
| <handler-class>org.jboss.test.ws.samples.rpcstyle.ServerSideHandler</handler-class>
| </handler>
This is my service client for invoking the service.
package org.jboss.test.ws.samples.client;
| import java.io.IOException;
| import java.net.URL;
| import javax.xml.namespace.QName;
| import javax.xml.rpc.Call;
| import javax.xml.rpc.ParameterMode;
| import javax.xml.rpc.Service;
| import javax.xml.rpc.ServiceFactory;
| import javax.xml.rpc.Stub;
| import com.sun.org.apache.bcel.internal.Constants;
|
| public class Client
| {
| public static void main(String[] args) throws Exception
| {
| String urlstr = "http://pc0104-129:8080/TrivialService?wsdl";
| URL url = new URL(urlstr);
|
| String ns = "http://org.jboss.ws/samples/rpcstyle";
| QName qname = new QName(ns, "TrivialService");
| QName port = new QName(ns, "TrivialServicePort");
| QName operation = new QName(ns, "request");
|
| ServiceFactory factory = ServiceFactory.newInstance();
| Service service = factory.createService(url, qname);
| Call call = service.createCall(port, operation);
| try
| {
| call.setProperty(Call.USERNAME_PROPERTY,"user");
| call.setProperty(Call.PASSWORD_PROPERTY,"password");
| String result = (String) call.invoke(new Object[] {"String1","String2"});
| System.out.println("output:" + result);
| }
| catch( IOException ioe )
| {
| ioe.printStackTrace();
| System.out.println(ioe.getMessage());
| System.out.println(ioe.getCause().getMessage());
| System.out.println(ioe.getCause().getLocalizedMessage());
| }
| }
| }
After I have invoked the service the handler printed null for the user and password. Could somebody tell me what is wrong?
Greetings,
patrick
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957353#3957353
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957353
19 years, 9 months
[Security & JAAS/JBoss] - JAAS / JBoss 3.2.5 / JBoss 3.2.8
by Timperator
Hello,
My application runs an Quartz job at start up, this works perfectly on 3.2.5, on 3.2.8 i'am getting following error:
| javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required
| at at.anite.tb.quartz.PropertyMgmtAdapter.getSysAdminManagerRemote(PropertyMgmtAdapter.java:59)
| at at.anite.tb.quartz.PropertyMgmtAdapter.getStringProperty(PropertyMgmtAdapter.java:65)
|
my method
| public static SysAdminManagerRemote getSysAdminManagerRemote() {
| try {
| SysAdminManagerRemote sysAdminManagerRemote = getSysAdminManagerHome().create();
| return sysAdminManagerRemote;
| } catch (Exception e) {
| throw new TbTechException(e);
| }
| }
|
my ejb-jar.xml
| <method-permission>
| <unchecked/>
| <method>
| <ejb-name>SysAdminManager</ejb-name>
| <method-intf>Home</method-intf>
| <method-name>*</method-name>
| </method>
| <method>
| <ejb-name>SysAdminManager</ejb-name>
| <method-name>*</method-name>
| </method>
| </method-permission>
|
I tried to edit the standardjboss.xml with
| <missing-method-permissions-excluded-mode>true</missing-method-permissions-excluded-mode>
|
but same result.
It seems he try to authentificate getSysAdminManagerHome().create() call, but didn't i disabled with my ejb-jar.xml?
Thanks,
Timothy
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957351#3957351
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957351
19 years, 9 months