Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Enabling SAML-based SSO with Remote EJB through Picketlink

<p>&nbsp;</p> <quillbot-extension-portal></quillbot-extension-portal>

January 3, 2018
Siddhartha De
Related topics:
JavaSecurity
Related products:
Red Hat JBoss Enterprise Application Platform

    Lets suppose that you have a remote Enterprise JavaBeans (EJB) application where the EJB client is a service pack (SP) application in a Security Assertion Markup Language (SAML) architecture. You would like your remote EJB to be authenticated using same assertion which was used for SP.

    Before proceeding with this tutorial, you should have a basic understanding of EJB and Picketlink.

    I have developed a POC based on Picketlink. Below are the things I have done to achieve it.
    •  Set Picketlink to sign response and assertion in identity provider (IDP) application.
      Configure:
      `SAML2SignatureGenerationHandler` like the following in picketlink.xml of IDP application.
        <Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2SignatureGenerationHandler">
             <Option Key="SIGN_RESPONSE_AND_ASSERTION" Value="true"/>
         </Handler>
    • Set picketlink to store SAML assertion in http-session in SP application.
      Configure:
      `SAML2AuthenticationHandler`  like the following in picketlink.xml of SP application.
        <Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler">
             <Option Key="ASSERTION_SESSION_ATTRIBUTE_NAME" Value="org.picketlink.sp.assertion"/>
         </Handler>
    •  Configure the sp security-domain something like below setting flag "sufficient" for both the login module and for the IDP application. You can configure your customized login module or you can use any login module available in picketbox.
          <security-domain name="sp" cache-type="default">
             <authentication>
                <login-module code="org.picketlink.identity.federation.bindings.jboss.auth.SAML2LoginModule" flag="sufficient" />
                <login-module code="org.picketlink.identity.federation.bindings.jboss.auth.SAML2STSLoginModule" flag="sufficient">
                     <module-option name="roleKey" value="Role"/>
                     <module-option name="localValidation" value="true"/>
                     <module-option name="localValidationSecurityDomain" value="sp"/>
                </login-module>
              </authentication>
           </security-domain>
    •  In your servlet (EJB client/SP application) you need to get the signed assertion and send it along with the EJB invocation for verification like below. Here, I have used ejb-remote application which is available in quickstart [1].
    //Getting Signed SAML Assertion
    public String getSignedAssertion(HttpServletRequest httpRequest) throws Exception {
             HttpSession session = httpRequest.getSession();
             String cachedSignedAssertion = (String) session.getAttribute("org.picketlink.sp.assertion.signed");
             if (cachedSignedAssertion == null) {
                 Document assertion = (Document) session.getAttribute("org.picketlink.sp.assertion");
                 String stringSignedAssertion = DocumentUtil.asString(assertion);
                 System.out.println(stringSignedAssertion);
                 return stringSignedAssertion;
             } else {
                 System.out.println("...cached assertion...");
                 return cachedSignedAssertion;
             }
         }
     
    //EJB invocation
    public void getInitialContext(String assertion, String username) throws Exception, NamingException {
     
             Properties props = new Properties();
             props.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
             props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
             props.put("remote.connections", "default");
             props.put("remote.connection.default.port", "4447");
             props.put("remote.connection.default.host", "10.10.10.10");
             System.out.println("Connecting...");
             props.put("remote.connection.default.username", username);
             props.put("remote.connection.default.password", assertion);
             props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT","false");
             props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS","false");
             Context context = new InitialContext(props);
             RemoteCounter aa = (RemoteCounter) context.lookup("ejb:/jboss-ejb-remote-server-side//CounterBean!org.jboss.as.quickstarts.ejb.remote.stateful.RemoteCounter?stateful");
             System.out.println(aa.getCount());
             aa.increment();
             System.out.println(aa.getCount());
             System.out.println("EJB Executed... using SAML assertion");
         }
    You can get the IDP and SP sample of Picketlink at [2] below:
    1.  https://github.com/jboss-developer/jboss-eap-quickstarts/tree/6.4.x/ejb-remote
    2.  https://github.com/jboss-developer/jboss-picketlink-quickstarts

    That's it for today!


    Take advantage of your Red Hat Developers membership and download RHEL today at no cost.

    Last updated: March 23, 2023

    Recent Posts

    • Tekton joins the CNCF as an incubating project

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    • Introducing virtualization platform autopilot

    • Integrate zero trust workload identity manager with Red Hat OpenShift GitOps

    What’s up next?

     

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.