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 7050023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:05:34+00:00 2026-05-28T03:05:34+00:00

As I understand javax.security.auth is an API for authentication and authorization. I understand that

  • 0

As I understand javax.security.auth is an API for authentication and authorization.

I understand that security should be implemented by the container provider and the bean-provider can just use it in his bean my simple annotations (@javax.annotation.security.RolesAllowed, @PermitAll etc) as recommended by the JSR.

My Question: This simply means that security cannot be tested without deploying in the container. Is there a way to use an external 3rd implementation of javax.security which can in someway be injected into the bean from the test from which security can also be propagated and tested?

This is almost a similar approach using which we inject a JPA implementation or a external transaction manager from a unit test into a bean for testing it.

P.S: I just want to check if this is possible and if it is possible, it might open ways to some other development. I understand that this testing can be done easily by deploying the bean in an Embedded container like OpenEJB or Arquillian.

  • 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-28T03:05:35+00:00Added an answer on May 28, 2026 at 3:05 am

    There’s quite a lot of plumbing involved in all of this. Trickier parts are:

    • Processing the annotations and respecting the non-inheritance and overriding rules (not referring to xml overriding)
    • Ensuring annotations are not getting misused or applied incorrectly
    • Respecting xml and overriding the annotation data
    • Mapping “roles allowed” with declared “roles” (there’s a level of indirection)
    • Adding all metadata as properly formatted permission strings to the JACC provider
    • Handling login via properly configured JAAS LoginModule
    • Some creative code to integrate the JAAS with JACC (there’s no standard way to do that)
    • Tracking your Subject via doAs calls or ThreadLocal
    • Proxying all your objects so you can do the auth checks before methods are actually invoked
    • Changing the security context for method annotated with @RunAs and ensuring the RunAs role is a declared role
    • Dealing with EJBContext.getCallerPrincipal() (a Subject has many Principal objects, so you have to pick one to return and ensure you can pick the same one consistently)
    • Wiring EJBContext.isCallerInRole(String) to the JACC provider
    • Making sure you use the right exception classes when you handle login failure, authorization failure, and various other conditions

    So that’s what a container does. The work that JAAS and JACC do are really quite small. Certainly not as detail oriented at least.

    None of this can really be “injected” as you might have hoped. Security is effectively an around advice.

    On the surface things like annotation-based security look very simple. However, when you explore all the combinations, caveats and conditions it really adds up. I remember all those details above because I got them all wrong when I first had to implement them. 🙂 Thank goodness for TCKs.

    I wouldn’t advise attempting to make your own security testing framework.

    If you do have a particular way that you’d like to see your testing happen, the smartest thing would be to just get involved with OpenEJB or Arquillian.

    All of the coolest features in OpenEJB came from users aches and pains and people describing to us “it hurts when I do this.” We love it. It’s a great source of features, a great way to get new contributors, and a fantastic way to prove ideas that might be good for bringing into the spec (like the Embedded EJBContainer API in EJB 3.1).

    I can’t stress enough how important it is to participate in the innovation rather than attempting to bypass it. If something doesn’t meet your needs, demand better.

    That last statement is more directed at the world in general 🙂

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

Sidebar

Related Questions

We have a custom javax.security.auth.spi.LoginModule used for web services as well as some web
I don't understand the rationale of this code, taken from javax.swing.event.EventListenerList docs: protected void
Please understand firstly that I fully understand that Java will return a String when
I understand that BigDecimal is recommended best practice for representing monetary values in Java.
I don't understand why there is no inheritance in Java annotations, just as Java
I'm a newbie on Java EE and got a problem that I don't understand
I want to understand form based security and JDBC realms with glassfishV3, so i
Eclipse crashed and won't restart. Can someone help me understand what the problem is?
I'm trying to create a JAR that I can put on a non development
Grails have cofig for spring bean called resources.groovy . And as i understand from

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.