Archived

This forum has been archived. Please start a new discussion on GitHub.

Is there a mechanism that can intercept request to servant

Hi!

I wrote a servant and a client, And for the servant there is a security mechanism that one call to the servant's any method must do a check before, the check target info is in the context map.
If the check is not ok, then the call should return( means not route to the servant anymore).

I found the Ice::DispatchInterceptor, But It seems can't do that, But do some retry code only.

Is there a opportunity to do a check before servant method call?

Thank you for your patient.



add: I don't want to add check code(even if only one line) in every method of servant.

Comments

  • benoit
    benoit Rennes, France
    You can use servant locators for this purpose. If the check based on the information from the context isn't successful, the implementation of your servant locator locate method can return 0. This will cause the client to receive an Ice::ObjectNotExistException. You could actually also use dispatch interceptors and raise Ice::ObjectNotExistException from the implementation if the check fails.

    Cheers,
    Benoit.
  • From your advise, I towards to use dispatch interceptor, and raise user-defined exception in the dispatch method, I want to know that there is no any problem for raise exception in the dispatch interceptor, is it?
  • benoit
    benoit Rennes, France
    Hi,

    If you want to raise a user exception I recommend to use servant locators instead. Raising a user exception from a dispatch interceptor won't work as you expect, the user exception will be returned as an Ice::UnknownUserException even if the operation is allowed to raise the user exception (i.e.: even if you added a throw clause in the specification of the Slice operation). The Ice runtime doesn't know if this a valid exception to raise at this point in the dispatch interceptor.

    Cheers,
    Benoit.