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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:54:23+00:00 2026-05-25T00:54:23+00:00

In Restlet you have a class called SecretVerifier with an abstract method verify(String identifier,

  • 0

In Restlet you have a class called SecretVerifier with an abstract method verify(String identifier, char[] secret) that you are to override in your subclass. The base class will also create a User object initialized with the identifier. So far so good.

Now the Enroler interface needs to be implemented to “add” roles to the aforementioned User object (that is passed to the subclass via the ClientInfo object). Here is where you “add” roles to the User object.

Let’s assume that ChallengeAuthenticator is being used for authentication.

Question: Both these classes are quite distinct and you don’t have access to the corresponding Request/Response objects. The very design sort of forces you to perform 2 round trips to the DB – one to verify the password and one to fetch the roles of the user. Is this an efficient design?

You can fetch everything in a single query, so to speak. And since both classes will invoke the corresponding DAOs separately, there will be 2 calls to the DB.

Of course you can have slightly convoluted code by overriding SecretVerifier.getIdentifier(Request req, Response resp) and then use that to fetch everything and add the roles – but the verify method seems to be a part of the template patter and you can’t really control what’s happening in the base class, unless you directly implement Verifier and reinvent the wheel and ‘tweak’ the code ever so slightly…but the question is about the design decision. I don’t want to start a debate. I just want to know is something like this (2 trips) one for authentication, the other for roles quite common and is efficient under moderate-high loads?

  • 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-25T00:54:23+00:00Added an answer on May 25, 2026 at 12:54 am

    I understand well your question. In fact, authentication and authorization are two distinct issues. In your case, you handle both in your applications but it’s not always the case specially when you use external authentication providers through OpenID. In this case, the chosen provider does the authentication and you then manage roles for the current user.

    Regarding your question, you can do authentication and authorization processing in one call to the database. You need to get user / role hints within the verifier entity and then pass them to the enroler entity using the current request instance.

    Here is an example:

    • Verifier:

      public class MySecretVerifier extends SecretVerifier {
          private SecurityDao securityDao = (...);
      
          public int verify(String identifier, char[] secret)
                               throws IllegalArgumentException {
              ApplicationUser user = securityDao.loadUser(identifier);
              //user contains both user hints and roles
              if (user!=null
                    && compare(user.getPassword().toCharArray(), secret)) {
                  Request request = Request.getCurrent();
                  request.getAttributes().put("currentUser", user);
                  return SecretVerifier.RESULT_VALID;
              } else {
                  return SecretVerifier.RESULT_INVALID;
              }
          }
      }
      
    • Enroler:

      public class MyEnroler implements Enroler {
          public void enrole(ClientInfo clientInfo) {
              Request request = Request.getCurrent();
              User user = request.getAttributes().put("currentUser");
              if (user!=null) {
                  List<UserRole> roles = user.getRoles();
                  if (roles!=null) {
                      for (UserRole userRole : roles) {
                          // example of role creation
                          Role role = new Role(userRole.getName(), "");
                          clientInfo.getRoles().add(role);
                      }
                  }
              }
          }
      }
      

    Hope it helps you.
    Thierry

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

Sidebar

Related Questions

I have a Restlet Service that looks like this: @POST @Produces(application/json) public String processImmediately(String
I have figured out that to integrate calls between Apache HTTP server and Restlet,
I have a restlet resource mapped as follows: router.attach(/activities/{userid}/{criteria}/{value}, ActivitiesResource.class); I am testing the
We have developed a RESTful webservice using the restlet framework. The service is called
Using Restlet I have created a router for my Java application. From using curl,
I have my Apache http server running on localhost:80 and restlet server on localhost:8182,
i've started to introduce myself into REST. I use as REST-framework Restlet. I have
I cannot find the org.restlet.ext.crypto package in the Restlet maven repo http://maven.restlet.org/ Strange that
I am needing to get the application root within a Restlet resource class (it
Looking for the guice support in restlet I have come across this article -

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.