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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:58:32+00:00 2026-06-11T04:58:32+00:00

I know it’s not the way it’s meant to be and it’s totally wrong,

  • 0

I know it’s not the way it’s meant to be and it’s totally wrong, but orders are orders, I need to do the following:
The user access the servlet with the accesskey on the parameters, like this:

http://myhost/my_app/servlet?accesskey=XXXXX

The servlet then gets the key and authenticate the user on seam with it, is it possible? I couldn’t manage to do it so far

  • 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-11T04:58:33+00:00Added an answer on June 11, 2026 at 4:58 am

    From your question it is not clear if you are required to create a custom servlet or you just need to make login based on a request parameter. The main difference is that a custom servlet is not intercepted by Seam and you cannot use components unless you manually start a seam lifecycle (as noted by Trind, you need to use LifeCycle.beginCall() and LifeCycle.endCall() to be able to use Seam components when calling from outside SeamFilter). Other than that, the two solutions work similarly.

    Create a component that will handle authentication:

    @Name("myAuthenticator")
    public class MyAuthenticator implements Serializable {
    
        // Seam's identity component
        @In private transient Identity identity;
    
        // When logged in, the user needs to have some roles, usually
        // you assign these dynamically based on user name, type, etc., here
        // I just initialize it to a fixed list of roles
        ArrayList<String> roles = new ArrayList<String>(Arrays.toList(
                new String[] { "base", "admin" }));
    
        // Access key (getters and setters omitted but are necessary)
        private String accessKey;
    
        public String doAuth() {
            // Check accessKey validity (against an SSO service or 
            // in your DB or whatever), here we do a trivial check.
            boolean userCanAccess = "ADMINKEY".equals(accessKey);
    
            if (userCanAccess) {
                identity.acceptExternallyAuthenticatedPrincipal(
                        new SimplePrincipal("username"));
    
                // Assign user roles
                for (String role : roles) {
                    identity.addRole(role);
                }
                return "ok";
            }
            return "ko";
        }
    }
    

    Now create a login page descriptor that will handle login via the parameter (say externalLogin.page.xml, you don’t need to create an .xhtml page for this):

    <page>
        <!-- this sets the accessKey variable with the query parameter -->
        <param name="accessKey" value="#{myAuthenticator.accessKey}" />
    
        <!-- this invokes our authentication action -->
        <action execute="#{myAuthenticator.doAuth}" />
    
        <!-- navigation rules, these determine what to do if auth is ok or fails -->
        <navigation from-action="#{myAuthenticator.doAuth}">
            <rule if-outcome="ko">
                <redirect view-id="/error.xhtml">
                    <message severity="ERROR">Invalid Authentication Key</message>
                </redirect>
            </rule>
            <rule if-outcome="ok">
                <redirect view-id="/home.xhtml">
                    <message severity="INFO">Welcome!</message>
                </redirect>
            </rule>
        </navigation>
    </page>
    

    Now to perform login you can use that page, like so:

    http://localhost:8080/yourapp/externalLogin.seam?accessKey=XXXXXXXX
    

    If you need to use a custom servlet (very unlikely, but nevertheless), the above component does not change, just call it from within the servlet like this:

    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        // Start Seam lifecycle
        LifeCycle.beginCall();
        // Get an instance of the authenticator component from Seam
        MyAuthenticator auth = Component.getInstance("myAuthenticator");
        // Set access key in component and perform auth
        auth.setAccessKey(req.getParameter("accessKey"));
        String result = auth.doAuth();
        // End Seam lifecycle, no more component calls are needed.
        LifeCycle.endCall();
    
        // Do something here with the result
        if ("ok".equals(result)) {
            resp.sendRedirect(...);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know you can not set a key value dynamically, but what about the
I know of cufon and one other similar. But what is the best way
I know that this may be common knowledge, but is there a way to
I know that there has been one question about this but it is not
I know that you can use DirectoryIndex example.html in .htaccess, but what I need
I know threre a lot of libraries dotnetopenauth,oauthbase, etc. But i need sample of
I know the title is not great but I think the code will come
Know this might be rather basic, but I been trying to figure out how
Know if it's possible to access the iPhone compass in Safari using JavaScript? I
I know that Phonegap has an event for back button, but it's only available

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.