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

  • Home
  • SEARCH
  • 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 7920807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:21:09+00:00 2026-06-03T16:21:09+00:00

I am in a Jboss AS 7 environment. My application’s /admIn/* path is protected

  • 0

I am in a Jboss AS 7 environment. My application’s /admIn/* path is protected by a security-constraint which requires form based authentication. Security domain is database backed.

It’s ok but now I want to display a “good morning ” in each page’s header.
I’m looking for some sort of getLoggedUsername() or getPrincipal() function but I can’t find it.

Please post a reference to the official docs if any.
Thank you.

  • 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-06-03T16:21:11+00:00Added an answer on June 3, 2026 at 4:21 pm

    You should be able to use JAAS. Which is what JBoss 7 ought to be using.

    The calling principal will be stored in a SessionContext which you can obtain by telling JBoss it’s a resource.

    @Resource 
    private SessionContext context;
    
    public void myAwesomeMethod() {
        String currentUser = context.getCallerPrincipal().getName();
    }
    

    If for some reason the Injection doesn’t work on a Stateless bean, you can look up the EJBContext direct.

    @Stateless
    public class HelloBean implements com.foo.ejb.HelloRemote {
        public void hello() {
            try {
                InitialContext ic = new InitialContext();
                SessionContext sctxLookup =
                  (SessionContext) ic.lookup("java:comp/EJBContext");
                System.out.println("look up EJBContext by standard name: " + sctxLookup);
            } catch (NamingException ex) {
                throw new IllegalStateException(ex);
            }
        }
    }
    

    This snippet was obtained from 4 ways to obtain EJBContext.

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

Sidebar

Related Questions

I have several components which are application scoped. Depending on which environment I am
Are there any differences implementing Flex application security in a clustered Java environment (such
for my EE application, i have to consider clustered timertasks in JBoss 6 Environment.
We have a Java web application running on JBoss and Linux. Production environment database
Environment Jboss 6 flyway 1.5 spring core 2.5.6 structure of the war ei-web-1.0.1-SNAPSHOT.war |WEB-INF
In our Production environment we have JBoss running in a clustered mode with 4+
I am having problems getting JBoss to inject an environment variable value into a
We use jBoss in our development environment to deploy to. There are many applications
I plan to deploy an EAR packaged application into JBoss v4.2 as a folder
I have setup a very simple test application to try RESTeasy on Jboss AS

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.