Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6782107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:42:08+00:00 2026-05-26T16:42:08+00:00

I am using EJBs (on JBoss) and Wicket as the UI layer. I added

  • 0

I am using EJBs (on JBoss) and Wicket as the UI layer. I added security to my EJB, my security.conf looks like this:

<application-policy name="my-security-domain">
    <authentication>
        <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
            <module-option name="usersProperties">META-INF/users.properties</module-option>
            <module-option name="rolesProperties">META-INF/roles.properties</module-option>
        </login-module>
    </authentication>
</application-policy>

In the UI layer, I use PicketBox to authenticate as instructed in the PicketBox Authentication page: http://community.jboss.org/wiki/PicketBoxAuthentication#PicketBox_Authentication_in_a_JBoss_Application_Server_5_environment

My Wicket AuthenticatedWebSession sub-class looks like this:

private Subject subject;
private SecurityContext securityContext;

@Override
public boolean authenticate(String username,
                            String password)
{
    boolean authenticated = false;
    securityContext = null;
    SecurityFactory.prepare();

    try
    {
        String                 securityDomainName = "my-security-domain";
        String                 configFile         = "META-INF/security.conf";
        PicketBoxConfiguration idtrustConfig      = new PicketBoxConfiguration();
        idtrustConfig.load(configFile);

        //Note: This is the most important line where you establish a security context
        securityContext = SecurityFactory.establishSecurityContext(securityDomainName);
        AuthenticationManager am = securityContext.getAuthenticationManager();
        subject = new Subject();

        Principal principal  = new SimplePrincipal(username);
        Object    credential = new String(password);
        authenticated = am.isValid(principal, credential, subject);

        securityContext.getUtil().createSubjectInfo(principal, credential, subject);
        //You may make call outs to other components here*/

        //DEBUG
        for(Principal p : subject.getPrincipals())
        {
            LOGGER.debug("Principal: " + p.getName());
            if(p instanceof Group)
            {
                Group                            g       = (Group) p;
                Enumeration<? extends Principal> members = g.members();
                while(members.hasMoreElements())
                {
                    Principal member = members.nextElement();
                    LOGGER.debug("Group name: " + member.getName());
                }
            }
        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }

    return authenticated;
}

So far so good, I can authenticated with the server from the UI. However, any subsequent calls to the secure EJBs from else where in the UI layer will fail with “Invalid User” although I have already authenticated.

I have tested the authentication in a standalone client and it works fine, I can invoke a secure EJB afterwards.

I have also tried the authentication outlined by this post, and the UI still cannot invoke secure EJBs: http://iocanel.blogspot.com/2010/09/karafs-jaas-modules-in-action.html

Any help would be greatly appreciated.

Kind regards,

Linh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:42:09+00:00Added an answer on May 26, 2026 at 4:42 pm

    A colleague of mnie suggested me to look at the security configuration at the web tier. I solved it with the following configuration:

    jboss-web.xml:

    <jboss-web>
        <security-domain>java:/jaas/my-security-domain</security-domain>
    </jboss-web>
    

    web.xml:

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>My Resource</web-resource-name>
            <url-pattern>/app/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
            <role-name>*</role-name>
        </auth-constraint>
    </security-constraint>
    <login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/login.html</form-login-page>
            <form-error-page>/login-error.html</form-error-page>
        </form-login-config>
    </login-config>
    

    Thank you all.

    Linh

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an application using Seam 2.2.x which will be deployed on JBoss 5.1.
I'm using Hibernate Validator in an application with EJB and Spring MVC. I'm using
I am using JBoss 6.0.1M5. Starting on EJBs. The tutorial I am reviewing is
I'm writing a Java EE application using JBoss AS 6 and I have a
I'm using Wicket + EJB3 in an application and I face a problem but
I'm writing my first Java EE application, using EJBs, Servlet, JSPs and the likes.
We're about to deploy a Java web application built using JBoss Seam as the
I am creating a web application using EJBs and servlets. I have a page
Is it possible to inject resources (like message queues, EJBs) using the @Resource annotation
I'm using JBoss 4.2.3, EJB2, XDoclet and have deployed one EAR with the EJBs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.