Home Help Center

Per session context

xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
Is posible add per session default parameters in the context?

My use case is as follow
I want establish same default parameters when the user login to glacier2. The server append this context to all invokations made by this session, I use this parameters in my ServantLocator for authorize or denied request.


pseudo code
Ice::ObjectPtr Oz::MyServantLocator::locate(const Ice::Current& current,Ice::LocalObjectPtr& cookie){
      Ice::ObjectPtr object = 0;
     if(Auth(current,cookie)){
       if(current.id.category == "person")
             object = PersonI(current.id);
      }else{
             object = BlojectAuthDenied(current.id,current.method);
      }
    return object;
}


bool MyServantLocator::Auth(const Ice::Current& current){
     bool auth = false;
     std::string userId = current.context["userId"];  //Default param that client can't write. HOW ??
     //query ACL database
     if( query.next())
         auth = true;
     return auth;
}

bool BlojectAuthDenied::ice_invoke(ByteSeq inParams, out ByteSeq outParams){
    outParams << AuthDeniedException(current.id,current.method);
    return false;
}

All methods in servants are defined to throw AuthDeniedException, BlojectAuthDenied extends Ice::Bloject an return an instace of AuthDeniedException.

Can this work? what about the per session context params?

Thanks in advance

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    I don't see why this wouldn't work. Contexts are forwarded by Glacier2 if you set the configuration property Glacier2.Client.ForwardContext to 1. So I would suggest to set the context in the client once the session with Glacier2 is created (you can use the communicator implicit contexts to set this once and for all, see the Ice 3.2 manual for more information on implicit contexts).

    Cheers,
    Benoit.
Sign In or Register to comment.