RFTokenClient Class Reference

class RFTokenClient : public RSessionBase

Utility class for for giving another process permission (token) to access on demand a specific file from another process. The class permits process (provider) to grant another process (consumer) ability to open, read and close the named file on demand as the consumer so wishes, without repeated interaction between provider and consumer.

Tokens are valid as long the session used for grating the permission is connected

        // Provider should usually instantiate session as member variable as session lifetime 
    // defines the tokens lifetime also, consumer may generate session on-demand based as well

    RFTokenClient client;
    User::LeaveIfError(client.Connect());
    CleanupClosePushL(client);

   // Provider, generating token based on known uid (made up uid in this example ;)

   TInt64 token = 0;
   TPckg<TInt64> tokenbuf(token); 
    
   _LIT(KMYPRIVATEFILE, "z:\\private\\1028289F\\focus.png"); // full path with drive letter must be given
   
   TSecureId consumerSecId(0x10282845); 

   User::LeaveIfError(iClient.GenerateToken(),TSecurityPolicy(consumerSecId), tokenbuf));

   // Generating token based on existing token
   // Nb. Consumer may ensure extended lifetime for token by "cloning" it
   // (i.e. make sure that token remains valid even the session of orifial provider
   // is closed )  

   TInt64 token2 = 0;
   TPckg<TInt64> tokenbuf2(token2); 

    User::LeaveIfError(client.GenerateToken(tokenbuf, Application()->AppDllUid(), tokenbuf2));

  // Consumer, opening file based on token

   RFile file;
   User::LeaveIfError(client.OpenFileForToken(file, tokenbuf2));
       

Inherits from

Public Member Functions
IMPORT_C TInt Connect ()
IMPORT_C TInt GenerateToken (const TDesC &, const TSecurityPolicy &, TDes8 &)
IMPORT_C TInt GenerateToken (const RFile &, const TSecurityPolicy &, TDes8 &)
IMPORT_C TInt GenerateToken (const TDesC8 &, const TSecurityPolicy &, TDes8 &)
IMPORT_C TInt GenerateToken (const TDesC &, const TUid &, TDes8 &)
IMPORT_C TInt GenerateToken (const RFile &, const TUid &, TDes8 &)
IMPORT_C TInt GenerateToken (const TDesC8 &, const TUid &, TDes8 &)
IMPORT_C TInt OpenFileForToken ( RFile &, const TDesC8 &)
Inherited Functions
RHandleBase::Attributes()const
RHandleBase::BTraceId()const
RHandleBase::Close()
RHandleBase::DoExtendedClose()
RHandleBase::Duplicate(const RThread &,TOwnerType)
RHandleBase::FullName()const
RHandleBase::FullName(TDes &)const
RHandleBase::Handle()const
RHandleBase::HandleInfo(THandleInfo *)
RHandleBase::Name()const
RHandleBase::NotifyDestruction(TRequestStatus &)
RHandleBase::Open(const TFindHandleBase &,TOwnerType)
RHandleBase::OpenByName(const TDesC &,TOwnerType,TInt)
RHandleBase::RHandleBase()
RHandleBase::RHandleBase(TInt)
RHandleBase::SetHandle(TInt)
RHandleBase::SetHandleNC(TInt)
RSessionBase::CreateSession(RServer2,const TVersion &)
RSessionBase::CreateSession(RServer2,const TVersion &,TInt)
RSessionBase::CreateSession(RServer2,const TVersion &,TInt,TIpcSessionType,const TSecurityPolicy *,TRequestStatus *)
RSessionBase::CreateSession(const TDesC &,const TVersion &)
RSessionBase::CreateSession(const TDesC &,const TVersion &,TInt)
RSessionBase::CreateSession(const TDesC &,const TVersion &,TInt,TIpcSessionType,const TSecurityPolicy *,TRequestStatus *)
RSessionBase::CreateSession(const TDesC &,const TVersion &,TInt,TRequestStatus *)
RSessionBase::Open(RMessagePtr2,TInt,TOwnerType)
RSessionBase::Open(RMessagePtr2,TInt,const TSecurityPolicy &,TOwnerType)
RSessionBase::Open(TInt,TOwnerType)
RSessionBase::Open(TInt,const TSecurityPolicy &,TOwnerType)
RSessionBase::Send(TInt)const
RSessionBase::Send(TInt,const TIpcArgs &)const
RSessionBase::SendReceive(TInt)const
RSessionBase::SendReceive(TInt,TRequestStatus &)const
RSessionBase::SendReceive(TInt,const TIpcArgs &)const
RSessionBase::SendReceive(TInt,const TIpcArgs &,TRequestStatus &)const
RSessionBase::SetReturnedHandle(TInt)
RSessionBase::SetReturnedHandle(TInt,RHandleBase &)
RSessionBase::SetReturnedHandle(TInt,const TSecurityPolicy &)
RSessionBase::ShareAuto()
RSessionBase::ShareProtected()
Inherited Enumerations
RHandleBase:TAttributes
RSessionBase:TAttachMode
Private Attributes
TInt iSpare1
TInt iSpare2
Inherited Attributes
RHandleBase::iHandle

Member Functions Documentation

Connect()

IMPORT_C TInt Connect ( )

Connects to server. If the server does not exist, starts the server .

GenerateToken(const TDesC &, const TSecurityPolicy &, TDes8 &)

IMPORT_C TInt GenerateToken ( const TDesC & aFileName,
const TSecurityPolicy & aSecurityPolicy,
TDes8 & aToken
) const

Generates token based on filename. Method is synchronous.

Parameters

const TDesC & aFileName Filename of file to be shared
const TSecurityPolicy & aSecurityPolicy Security policy that a process that process must fullfill to gain access to file
TDes8 & aToken Generated token, 64-bit integer as a 8-bit descriptor

GenerateToken(const RFile &, const TSecurityPolicy &, TDes8 &)

IMPORT_C TInt GenerateToken ( const RFile & aOpenFile,
const TSecurityPolicy & aSecurityPolicy,
TDes8 & aToken
) const

Generates token based on open file handle. Method is synchronous.

Parameters

const RFile & aOpenFile Open filehandle, can reside other process gage as well
const TSecurityPolicy & aSecurityPolicy Security policy that a process that process must fullfill to gain access to file
TDes8 & aToken Generated token, 64-bit integer as a 8-bit descriptor

GenerateToken(const TDesC8 &, const TSecurityPolicy &, TDes8 &)

IMPORT_C TInt GenerateToken ( const TDesC8 & aExistingToken,
const TSecurityPolicy & aSecurityPolicy,
TDes8 & aToken
) const

Generates token based on existing token. Method is synchronous.

Parameters

const TDesC8 & aExistingToken Token that is valid inside this process (SecId matches)
const TSecurityPolicy & aSecurityPolicy Security policy that a process that process must fullfill to gain access to file
TDes8 & aToken Generated token, 64-bit integer as a 8-bit descriptor

GenerateToken(const TDesC &, const TUid &, TDes8 &)

IMPORT_C TInt GenerateToken ( const TDesC & aFileName,
const TUid & aConsumerUid,
TDes8 & aToken
) const

Generates token based on filename. Method is synchronous.

Parameters

const TDesC & aFileName Filename of file to be shared
const TUid & aConsumerUid Secure id of process that gains access to file
TDes8 & aToken Generated token, 64-bit integer as a 8-bit descriptor

GenerateToken(const RFile &, const TUid &, TDes8 &)

IMPORT_C TInt GenerateToken ( const RFile & aOpenFile,
const TUid & aConsumerUid,
TDes8 & aToken
) const

Generates token based on open file handle. Method is synchronous.

Parameters

const RFile & aOpenFile Open filehandle, can reside other process gage as well
const TUid & aConsumerUid Secure id of process that gains access to file
TDes8 & aToken Generated token, 64-bit integer as a 8-bit descriptor

GenerateToken(const TDesC8 &, const TUid &, TDes8 &)

IMPORT_C TInt GenerateToken ( const TDesC8 & aExistingToken,
const TUid & aConsumerUid,
TDes8 & aToken
) const

Generates token based on existing token. Method is synchronous.

Parameters

const TDesC8 & aExistingToken Token that is valid inside this process (SecId matches)
const TUid & aConsumerUid Secure id of process that gains access to file
TDes8 & aToken Generated token, 64-bit integer as a 8-bit descriptor

OpenFileForToken(RFile &, const TDesC8 &)

IMPORT_C TInt OpenFileForToken ( RFile & aHandle,
const TDesC8 & aToken
) const

Opens filehandle based on token. Method is synchronous.

Parameters

RFile & aHandle Unattached handle
const TDesC8 & aToken Token that is valid in for this process

Member Data Documentation

TInt iSpare1

TInt iSpare1 [private]

TInt iSpare2

TInt iSpare2 [private]