[Security & JAAS/JBoss] - EJB3: How to access @Stateless EJBs from custom LoginModule?
by baeurlem
Hi,
I have a JBoss 4.2.2.GA WebService application, where the WebServices should be secured.
So I wrote a custom LoginModule for JBoss 4.2.2.GA which extends the org.jboss.security.auth.spi.UsernamePasswordLoginModule. I defined an <application-policy> in the login-config.xml and I use the @SecurityDomain annotation for the secured @WebService beans
So far so good: My LoginModule is called correctly.
Inside the LoginModule I want to call a local @Stateless bean which provides methods to retrieve the user/roles via Hibernate from the database.
But how to access this bean?
I tried the @EJB annotation => no success
I tried a lookup via JNDI => no success (NameNotFoundException)
MyLoginModule:
| public class MyLoginModule extends UsernamePasswordLoginModule
| {
| private MyAuthenticationService myAuthenticationService;
|
| @Override
| public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)
| {
| super.initialize(subject, callbackHandler, sharedState, options);
| try {
| Context jndiContext = new InitialContext();
| this.myAuthenticationService = (MyAuthenticationService) jndiContext.lookup("java:comp/env/ejb/MyAuthenticationServiceImpl"); // does not work (ejb not bound)
| // does not work: I tried all name combinations
| // jndiContext.lookup("java:comp.ejb3/env/ejb/MyAuthenticationServiceImpl") => does not work (ejb not bound)
| // jndiContext.lookup("ejb/MyAuthenticationServiceImpl") => does not work (ejb not bound)
| // jndiContext.lookup("MyAuthenticationServiceImpl") => does not work (MyAuthenticationServiceImpl not bound)
| }
| catch (NamingException ex) {
| // TODO Auto-generated catch block
| ex.printStackTrace();
| }
| }
|
| @Override
| protected Principal createIdentity(String username) throws Exception
| {
| MyUser user = this.myAuthenticationService.retrieveUserByLoginName(username);
| return user;
| }
|
| @Override
| protected String getUsersPassword() throws LoginException
| {
| MyUser myUser = (MyUser) this.getIdentity();
| return myUser.getPassword();
| }
|
| @Override
| protected Group[] getRoleSets() throws LoginException
| {
| Group roles = new SimpleGroup("Roles"); // "Roles" is the expected GroupName for the roles
|
| for (Principal role : ((MyUser) this.getIdentity()).getRoles()) {
| roles.addMember(role);
| }
|
| return new Group[] { roles };
| }
|
| @EJB // has no effect
| public void setMyAuthenticationService(MyAuthenticationService myAuthenticationService)
| {
| this.myAuthenticationService = myAuthenticationService;
| }
|
| }
|
|
MyAuthenticationServiceImpl:
| @Stateless
| public class MyAuthenticationServiceImpl implements MyAuthenticationService
| {
|
| // ...
|
| public MyUser retrieveUserByLoginName(String loginName) throws LoginException
| {
| // here the DAO is called which uses the EntityManager
| }
|
| // ...
|
| }
|
MyAuthenticationService:
| public interface JaasService
| {
| // ...
| public MyUser retrieveUserByLoginName(String loginName) throws LoginException;
| // ...
| }
|
What is wrong?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120785#4120785
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120785
18 years, 5 months
[Security & JAAS/JBoss] - Form Based Authentication with Stylesheet
by jahratero
Hello everybody,
I've been working on securing a simple web-application of mine.
I used a container managed security, Form Based Authentication with database connection.
It works fine!
My problem is I got a login.jsp page that JBoss present when you try to access the web-app
and this login.jsp is just black and white. I made a CSS file to tune it up a little, but for some
reason (which I don't know, yet) it doesn't load the CSS file.
Here is my login.jsp:
<html>
| <head>
| <title>My WebApp</title>
| <link rel="StyleSheet" href="/styles.css" type="text/css"/>
|
| </head>
| <body>
| <p class="header">
| <h1>Please log in X</h1>
| </p>
|
| <form method="POST" action="j_security_check">
| User Name: <input type="text" name="j_username" /><br/>
| Password: <input type="password" name="j_password" /><br/>
| <input type="submit" value="Login" />
| </form>
| <TABLE>
| <TR><TH CLASS="TITLE">Loggie</TH></TR>
| </TABLE>
| <p style="color:blue">
| This is the last line!
| </p>
| <p class="header">
| This is the last line!!!
| </p>
| </body>
| </html>
|
The This is the last line! text should be blue when loaded and is not
when the page is loaded.
On the other hande the This is the last line!!! text does show blue when loaded.
Now I can go ahead and just put the style in every tag, but that's I don't want that. I have a large CSS file which I want to try out.
This is my CSS file:
| BODY { background-color: #FDF5E6 }
|
| TH.TITLE { background-color: #FFAD00;
| font-size: 50px;
| font-family: Arial Black, Arial, Helvetica, sans-serif;
| }
|
Another thing is the body doesn't load the color I gave up for it to be.
Can someone please help me, give me advice how to load the CSS file (if it is possible).
Thanks in advanced
-Yuri
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120778#4120778
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120778
18 years, 5 months
[JBoss jBPM] - exception encountered in jbpm bpel examples
by shefagarwal
hi,
I am new to jbpm bpel and was trying to execute the hello application of jbpm-bpel-1.1.GA examples. I am able to deploy the hello business process definition on jboss as 4.0.5.GA. But when I try to test the process using application client as provided in the example I get these exceptions:
compile.test.dependencies:
compile.test:
[javac] Compiling 1 source file to D:\StockMarketProject\jbpm-bpel-1.1.GA\
amples\hello\target\test\classes
[javac] D:\StockMarketProject\jbpm-bpel-1.1.GA\examples\hello\src\test\jav
org\jbpm\bpel\tutorial\hello\HelloTest.java:32: cannot find symbol
[javac] symbol : class HelloWorldService
[javac] location: class org.jbpm.bpel.tutorial.hello.HelloTest
[javac] private HelloWorldService helloService;
[javac] ^
[javac] D:\StockMarketProject\jbpm-bpel-1.1.GA\examples\hello\src\test\jav
org\jbpm\bpel\tutorial\hello\HelloTest.java:40: cannot find symbol
[javac] symbol : class HelloWorldService
[javac] location: class org.jbpm.bpel.tutorial.hello.HelloTest
[javac] helloService = (HelloWorldService) iniCtx.lookup("java:comp/en
service/Hello");
[javac] ^
[javac] D:\StockMarketProject\jbpm-bpel-1.1.GA\examples\hello\src\test\jav
org\jbpm\bpel\tutorial\hello\HelloTest.java:45: cannot find symbol
[javac] symbol : class Greeter
[javac] location: class org.jbpm.bpel.tutorial.hello.HelloTest
[javac] Greeter proxy = helloService.getGreeterPort();
[javac] ^
[javac] 3 errors
BUILD FAILED
Can somebody provide a solution to this problem?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120776#4120776
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120776
18 years, 5 months