<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Konfiguratio of security domains in JBoss AS 6 with EJB 3.1
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/suikast42">Süleyman Vurucu</a> in <i>EJB3</i> - <a href="http://community.jboss.org/message/569827#569827">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><div class="jive-rendered-content"><p>Hi @ all,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My Environment at first:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Aplication Sevrer :&#160;&#160;&#160;&#160;&#160; jboss-6.0.0.20100911-M5 (default configuration without any changes)</p><p>IDE:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Eclipse 3.6</p><p>Jboss Tools&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; V 3.2</p><p>Java Version:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; JDK 1.6 U 20</p><p>OS:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Windows Vista 32 Bit</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My Problem:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I Create a test Application. It Contains only one Stateless Bean with local and remote interfaces:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><span style="color: navy;"><strong>package</strong></span> beans.stateless;<br/> <br/><span style="color: navy;"><strong>import</strong></span> interfaces.stateless.FirstStatelessBeanLocal;<br/><span style="color: navy;"><strong>import</strong></span> interfaces.stateless.FirstStatelessBeanRemote;<br/> <br/><span style="color: navy;"><strong>import</strong></span> javax.annotation.*;<br/><span style="color: navy;"><strong>import</strong></span> javax.annotation.security.*;<br/><span style="color: navy;"><strong>import</strong></span> javax.ejb.*;<br/> <br/><span style="color: navy;"><strong>import</strong></span> org.apache.commons.logging.*;<br/><span style="color: navy;"><strong>import</strong></span> org.jboss.aop.*;<br/><span style="color: navy;"><strong>import</strong></span> org.jboss.beans.metadata.api.annotations.*;<br/><span style="color: navy;"><strong>import</strong></span> org.jboss.security.annotation.*;<br/> <br/><span style="color: darkgreen;">/**<br/> * Session Bean implementation class FirstStatelessBean<br/> */</span><br/>@Stateless<br/>@SecurityDomain(<span style="color: red;">"JBossWS"</span>)<br/>@RolesAllowed(<span style="color: red;">"{friend}"</span>)<br/><span style="color: navy;"><strong>public</strong></span> <span style="color: navy;"><strong>class</strong></span> FirstStatelessBean <span style="color: navy;"><strong>implements</strong></span> FirstStatelessBeanRemote, FirstStatelessBeanLocal <span style="color: navy;">{</span><br/> <br/>&#160;&#160;&#160; <span style="color: darkgreen;">/**<br/>&#160;&#160;&#160;&#160; * Default constructor.<br/>&#160;&#160;&#160;&#160; */</span><br/>&#160;&#160;&#160; <span style="color: navy;"><strong>private</strong></span> int&#160;&#160;&#160; pCounterLocal&#160;&#160;&#160; = 0;<br/>&#160;&#160;&#160; <span style="color: navy;"><strong>private</strong></span> int&#160;&#160;&#160; pCounterRemote&#160;&#160;&#160; = 0;<br/> <br/>&#160;&#160;&#160; @Resource<br/>&#160;&#160;&#160; <span style="color: navy;"><strong>private</strong></span> SessionContext myCtx ; <br/>&#160;&#160;&#160; <br/>&#160;&#160;&#160; <span style="color: navy;"><strong>public</strong></span> FirstStatelessBean() <span style="color: navy;">{</span><br/>&#160;&#160;&#160; <span style="color: navy;">}</span><br/> <br/>&#160;&#160;&#160; @PreDestroy<br/>&#160;&#160;&#160; <span style="color: navy;"><strong>public</strong></span> <span style="color: navy;"><strong>void</strong></span> destroy() <span style="color: navy;">{</span><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; LogFactory.getLog( getClass() ).warn( <span style="color: red;">"Destroy"</span> );<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; pCounterLocal=0;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; pCounterRemote=0;<br/>&#160;&#160;&#160; <span style="color: navy;">}</span><br/>&#160;&#160;&#160; <br/>&#160;&#160;&#160; @PostConstruct<br/>&#160;&#160;&#160; <span style="color: navy;"><strong>public</strong></span> <span style="color: navy;"><strong>void</strong></span> create()<span style="color: navy;">{</span><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; LogFactory.getLog( getClass() ).warn( <span style="color: red;">"Create"</span> );<br/>&#160;&#160;&#160; <span style="color: navy;">}</span><br/> <br/>&#160;&#160;&#160; <br/>&#160;&#160;&#160; @Override<br/>&#160;&#160;&#160; <span style="color: navy;"><strong>public</strong></span> String sayHelloLocal( String pMesssage ) <span style="color: navy;">{</span><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; String lMessage = <span style="color: red;">"Hello Local to "</span> + pMesssage + <span style="color: red;">" "</span> + ( ++pCounterLocal ) + <span style="color: red;">" Times"</span>;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; LogFactory.getLog( getClass() ).info( lMessage );<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: navy;"><strong>return</strong></span> lMessage;<br/>&#160;&#160;&#160; <span style="color: navy;">}</span><br/> <br/>&#160;&#160;&#160; @Override<br/>&#160;&#160;&#160; <span style="color: navy;"><strong>public</strong></span> String sayHelloRemote( String pMesssage ) <span style="color: navy;">{</span><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; String lMessage = <span style="color: red;">"Hello Remote to "</span> + pMesssage + <span style="color: red;">" "</span> + ( ++pCounterRemote ) + <span style="color: red;">" Times"</span>;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; LogFactory.getLog( getClass() ).info( lMessage );<br/><span style="color: darkgreen;">//&#160;&#160;&#160;&#160;&#160; LogFactory.getLog( getClass() ).info( myCtx.getCallerPrincipal() );</span><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: navy;"><strong>return</strong></span> lMessage;<br/>&#160;&#160;&#160; <span style="color: navy;">}</span><br/> <br/>&#160;&#160;&#160; @Override<br/>&#160;&#160;&#160; @PrePassivate<br/>&#160;&#160;&#160; <span style="color: navy;"><strong>public</strong></span> <span style="color: navy;"><strong>void</strong></span> passviate() <span style="color: navy;">{</span><br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; LogFactory.getLog( getClass() ).warn( <span style="color: red;">"Passivate"</span> );&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; <span style="color: navy;">}</span><br/> <br/> <br/><span style="color: navy;">}</span><br/></code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>On The Client side I get the JNDI Refrence on the following way:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">Properties p = <span style="color: navy;"><strong>new</strong></span> Properties();<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; p.put( Context.INITIAL_CONTEXT_FACTORY, <span style="color: red;">"org.jnp.interfaces.NamingContextFactory"</span> );<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; p.put( Context.PROVIDER_URL, <span style="color: red;">"jnp://"</span> + pServerAddr + <span style="color: red;">":"</span> + pServerPort );<br/>InitialContext jndiContext = <span style="color: navy;"><strong>new</strong></span> InitialContext( p );<br/> <br/></code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So&#160; my excpected behavior (when I call sayHelloRemote) is an Exception. But&#160; this request still works with worong user information.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So what I'm doing wrong ?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I try the example from</p><span><a class="jive-link-external-small" href="http://community.jboss.org/docs/DOC-15571" target="_blank">http://community.jboss.org/wiki/Chapter15-SecurityandSchoolEJBAccess</a></span><p> as well. But the result i the same. I can call every method withaout an exception. And when I call getCallerPrincipal from SessionContext I get an Exception. This occurs while the bean don't in a security domain am I rigth ?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></div></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/569827#569827">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB3 at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>