[JBossWS] - Re: Accessing USERNAME_PROPERTY from Web Service class
by mjhammel
Okay, I discovered how to do this. Part of the problem was that my BASIC authentication via DatabaseServerLoginModule was not working properly.
Ignoring the authentication problem, once you have authentication working then the following code should work:
| import javax.xml.ws.WebServiceContext;
| import javax.xml.ws.handler.MessageContext;
| import javax.servlet.http.HttpServletRequest;
| import java.security.Principal;
| ...
|
| @Stateless
| @Remote(SubscriberServices.class)
| @WebService(
| name = "SubscriberWS",
| endpointInterface = "com.cei.crunch.server.ws.SubscriberServices.SubscriberServicesEndpoint"
| )
| @SOAPBinding(style = SOAPBinding.Style.RPC)
|
| public class SubscriberServices implements SubscriberServicesEndpoint {
|
| @Resource
| WebServiceContext wsContext;
|
| private Subscriber getUserInfo() throws CrunchWSException {
|
| MessageContext msgContext = wsContext.getMessageContext();
| HttpServletRequest servletRequest = (HttpServletRequest) msgContext.get(MessageContext.SERVLET_REQUEST);
| Principal p = servletRequest.getUserPrincipal();
| String username = p.getName();
| ....
|
Alternatively:
| ...
| MessageContext msgContext = wsContext.getMessageContext();
| HttpServletRequest servletRequest = (HttpServletRequest) msgContext.get(MessageContext.SERVLET_REQUEST);
| String username = servletRequest.getRemoteUser();
| ...
Either method appears to work.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123148#4123148
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123148
18 years, 4 months
[JBoss AOP] - Re: JBoss 4.2.2.GA + JDK 1.6.0_03
by apinto
Hi Kabir, thanks for your response! We already met a long time ago, but you probably don't remember. It was when you gave a few days of classes in Aveiro, Portugal, for PT Inovacao: I was one of the trainees! :-D Nice to see that you're still ahead of JBoss AOP!
Anyway, here goes the requested information:
=========================================================================
|
| JBoss Bootstrap Environment
|
| JBOSS_HOME: /opt/[ommited]/jboss-4.2.2.GA
|
| JAVA: /opt/jdk1.5.0_14/bin/java
|
| JAVA_OPTS: -Dprogram.name=run.sh -server -javaagent:pluggable-instrumentor.jar -Xms128m -Xmx512m -Djboss.partition.name=MatryoshkaPartition -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true
|
| CLASSPATH: /opt/[ommited]/jboss-4.2.2.GA/bin/run.jar:/opt/jdk1.5.0_14/lib/tools.jar
|
| =========================================================================
Also, the jboss-service.xml file was modified according to the FAQ and the JAR for the agent came from the 1.5.6 distribution. Thanks a lot for your support,
AP
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123144#4123144
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123144
18 years, 4 months
[JNDI/Naming/Network] - NameNotFoundException for SLSB Visible in JNDIView
by serac
We have deployed a service MBean in a SAR within an EAR that needs to perform a JNDI lookup to get resources in both a "Manager" JAR and a "Query" JAR. Simplified package structure:
| EAR
| +- Service SAR
| +- MBean
| +- Manager JAR (JNDI lookup for these resources succeeds)
| +- Query JAR (JNDI lookup fails)
|
The following code generates a NameNotFoundException when called from our service MBean:
| final InitialContext jndiContext = this.getJndiContext();
| obj = (T) jndiContext.lookup(jndiName);
|
where jndiName = vt-ejb/PersonQuery/local. This resource is clearly registered in JNDI as shown by the following output from JNDIView:
| Global JNDI Namespace
|
| +- vt-ejb (class: org.jnp.interfaces.NamingContext)
| | +- PersonQuery (class: org.jnp.interfaces.NamingContext)
| | | +- local (proxy: $Proxy215 implements interface edu.vt.middleware.registry.query.person.PersonQueryLocal,interface org.jboss.ejb3.JBossProxy)
| | | +- remote (proxy: $Proxy214 implements interface edu.vt.middleware.registry.query.person.PersonQueryRemote,interface org.jboss.ejb3.JBossProxy)
| | +- EmailManager (class: org.jnp.interfaces.NamingContext)
| | | +- local (proxy: $Proxy134 implements interface edu.vt.middleware.registry.manage.email.EmailManagerLocal,interface org.jboss.ejb3.JBossProxy)
| | | +- remote (proxy: $Proxy133 implements interface edu.vt.middleware.registry.manage.email.EmailManagerRemote,interface org.jboss.ejb3.JBossProxy)
|
Stack trace:
| javax.naming.NameNotFoundException: vt-ejb/PersonQuery/local
| at org.jboss.ha.jndi.TreeHead.lookup(TreeHead.java:242)
| at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:155)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:312)
| ...
|
What's interesting is that the error message for a NameNotFoundException typically reads "x not bound" for query on a non-existent name; the "not bound" text is conspicuously missing, which suggests that it's not a name resolution problem.
We are puzzled that a similar JNDI lookup as above, from the same calling context (an MBean), succeeds if we do a lookup on the EmailManager bean using the name vt-ejb/EmailManager/local.
We are using EJB3 annotations to mark up the beans and register them in JNDI, and the two beans above have exactly the same annotations except EmailManager has a @RunAs(...) annotation. They also occur in different JARs within the same EAR.
For reference, the annotations on PersonQueryBean follow:
| @Stateless
| @SecurityDomain("EDClient")
| @WebService(name = "PersonQuery",
| endpointInterface =
| "edu.vt.middleware.ed.query.PersonQueryEndpoint")
| @WebContext(contextRoot = "/registryquery",
| transportGuarantee = "CONFIDENTIAL",
| authMethod = "CLIENT-CERT")
| @LocalBinding(jndiBinding = PersonQuery.LOCAL_JNDI_NAME)
| @RemoteBinding(jndiBinding = PersonQuery.REMOTE_JNDI_NAME)
| public class PersonQueryBean extends AbstractQuery
| implements PersonQueryLocal, PersonQueryRemote
| ...
|
| public interface PersonQuery extends PersonQueryEndpoint
| {
| /** local jndi name */
| String LOCAL_JNDI_NAME = "vt-ejb/PersonQuery/local";
|
| /** remote jndi name */
| String REMOTE_JNDI_NAME = "vt-ejb/PersonQuery/remote";
| ...
|
We would appreciate any suggestions for resolving this issue or investigating it further.
Thanks,
Marvin
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123140#4123140
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123140
18 years, 4 months
[JBossWS] - Re: Question on Basic WS Authentication
by mjhammel
Alessio:
In JBOSS 4.0.5GA I dropped crunch-login-config-service.xml and crunch-login-config.xml into server/default/conf in order to enable a DB based authentication. This worked fine. In 4.2.2GA it doesn't appear that crunch-login-config-service.xml is being seen. The only way to get crunch-login-config.xml to be read is to manually put it into login-config.xml. Am I missing something or is this a change to 4.2.2GA that I'll just have to live with?
Here are the contents of the two files:
crunch-login-config-service.xml
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE server>
|
| <server>
|
| <mbean code="org.jboss.security.auth.login.DynamicLoginConfig" name="jboss:service=DynamicLoginConfig">
| <attribute name="AuthConfig">crunch-login-config.xml</attribute>
| <depends optional-attribute-name="LoginConfigService">jboss.security:service=XMLLoginConfig</depends>
| <depends optional-attribute-name="SecurityManagerService">jboss.security:service=JaasSecurityManager</depends>
| </mbean>
|
| </server>
crunch-login-config.xml
<?xml version='1.0'?>
| <!DOCTYPE policy PUBLIC
| "-//JBoss//DTD JBOSS Security Config 3.0//EN"
| "http://www.jboss.org/j2ee/dtd/security_config.dtd">
|
| <!--
| Crunch Security Realm Configuration.
| This file defines how authentication is determined for access to pages.
| This file gets copied to $JBOSS_HOME/server/default/conf by the Ant build.
| -->
|
| <policy>
|
| <application-policy name = "CrunchDBRealm">
| <authentication>
| <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required">
| <module-option name = "unauthenticatedIdentity">guest</module-option>
| <module-option name = "dsJndiName">java:/CrunchDS</module-option>
| <module-option name = "principalsQuery">SELECT password FROM subscriber WHERE username=?</module-option>
| <module-option name = "rolesQuery">SELECT CRUNCHROLES.ROLENAME, 'Roles' FROM CRUNCHROLES, SUBSCRIBER WHERE SUBSCRIBER.USERNAME=? AND CRUNCHROLES.USERGUID=SUBSCRIBER.GUID</module-option>
| </login-module>
| </authentication>
| </application-policy>
|
| </policy>
|
Again, in 4.2.2GA if I copy everything between and in the crunch-login-config.xml into login-config.xml then authentication works as it's supposed to. But I'd rather just drop in my own config without mucking with the JBOSS default config, if that's still possible.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123136#4123136
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4123136
18 years, 4 months