Results 1 to 3 of 3

Thread: Ice Context propagation problem (C++, Java)

  1. #1
    joel vennin is offline Registered User
    Name: Joël Vennin
    Organization: University Lille 1
    Project: Just Testing when i have time
    Join Date
    Dec 2005
    Location
    France
    Posts
    21

    Ice Context propagation problem (C++, Java)

    Hi !

    I play with Ice, it is really nice. Currently, i'm trying to make an authentificaton system. When you have some rights you can/cannot access to a specific method of an interface.

    When the user is being authentificated to the Authentification service, it gets a user_key.

    This user_key is stored in a context. So each time the user call a method, a check is done to the Authentification service.


    The problem that I have is the propagation of the context. I use the implicit/explicit context mechanism:


    Imagine that the Authentification service has a sequence with all others generic services:

    ---------------------- ------------------
    | Authentification |--1-----0..n-| Generic Service |
    ---------------------- ------------------
    | string login(us,pswd)|
    | getServices () |
    ----------------------


    So the user connect to the authentification service. Next it calls the login method that returns the user key.
    At this point i have the user key, A User can call the getServices only if it is already identified. So to do it,

    I add the user key to the context (Client side in Java, Server side in C++ VS2005):


    String key = authManager.login(getLogin(), getPassword());

    // Here we have the connection id and we add it to the context
    java.util.Map ctx = ic.getDefaultContext();
    ctx.put("my_key", key);
    mAuthentificationManager = hdg.authentification.IManagerPrxHelper.uncheckedCa st(authManager.ice_newContext(ctx));

    So at this point, the mAuthentificationManager should have an implicit context. So every time i use a method of the mAuthentificationManager
    proxy the context should be preset.


    So for now, all are ok.

    Now i'm calling the getServices (), the user can call this method because the implicit context contains its key. However, I would like that
    all GenericService proxy returned by the getServices have the same context.

    So the getServices method looks like that (Server side in C++):


    ::hdg::service::IAbstractManagerSeq AuthentificationI::getServices(const ::Ice::Current& cur) {

    checkRightPermission (AdminRight, cur);

    hdg::service::IAbstractManagerSeq seq;

    for (hdg::service::IAbstractManagerSeq::iterator it = m_services.begin (); it != m_services.end (); ++it) {

    hdg::service::IAbstractManagerPrx service = hdg::service::IAbstractManagerPrx::uncheckedCast(( *it)->ice_newContext (cur.ctx));

    // just make the affectation to debug and see the contents of the context.
    Ice::Context ctx = service->ice_getContext ();

    seq.push_back (service);
    }
    return seq;
    }


    At this point, each generic service proxy has the context of the proxy caller of the getServices method.

    However, the problem comes from the java part, in fact, when i get the result of the getServices method, i get all generic service proxies
    without the context. The ice_context of all returned generic service proxies are empty.


    Maybe i've missed something,

    Can you help me ?

    Thank you.
    Phd Student
    - University of Lille 1 (France)
    - I work on distributed simulation (i'm ask my self if i should use Ice has a backend)

  2. #2
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Hi,

    Ice is behaving as expected; the context is a strictly local setting, therefore any context values defined for a proxy do not accompany that proxy when it is marshaled and sent to another process. However, if you replace the communicator's default context using Communicator.setDefaultContext, then any proxy subsequently received by the application will automatically use your new default context.

    Hope that helps,
    - Mark

  3. #3
    joel vennin is offline Registered User
    Name: Joël Vennin
    Organization: University Lille 1
    Project: Just Testing when i have time
    Join Date
    Dec 2005
    Location
    France
    Posts
    21
    Thank you Mes !

    Of course, it helps

    Joel
    Phd Student
    - University of Lille 1 (France)
    - I work on distributed simulation (i'm ask my self if i should use Ice has a backend)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 04-20-2009, 10:06 PM
  2. Ice.Context and AMI calls
    By aozarov in forum Help Center
    Replies: 1
    Last Post: 11-21-2008, 05:04 PM
  3. IceStorm and Ice::Context
    By Nis Baggesen in forum Help Center
    Replies: 2
    Last Post: 03-06-2006, 06:52 AM
  4. Problem passing context map with createSession()
    By bartley in forum Help Center
    Replies: 6
    Last Post: 02-02-2006, 10:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •