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));
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 Enumerations | |
---|---|
RHandleBase:TAttributes | |
RSessionBase:TAttachMode |
Private Attributes | |
---|---|
TInt | iSpare1 |
TInt | iSpare2 |
Inherited Attributes | |
---|---|
RHandleBase::iHandle |
IMPORT_C TInt | Connect | ( | ) |
Connects to server. If the server does not exist, starts the server .
IMPORT_C TInt | GenerateToken | ( | const TDesC & | aFileName, |
const TSecurityPolicy & | aSecurityPolicy, | |||
TDes8 & | aToken | |||
) | const |
Generates token based on filename. Method is synchronous.
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 |
IMPORT_C TInt | GenerateToken | ( | const RFile & | aOpenFile, |
const TSecurityPolicy & | aSecurityPolicy, | |||
TDes8 & | aToken | |||
) | const |
Generates token based on open file handle. Method is synchronous.
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 |
IMPORT_C TInt | GenerateToken | ( | const TDesC8 & | aExistingToken, |
const TSecurityPolicy & | aSecurityPolicy, | |||
TDes8 & | aToken | |||
) | const |
Generates token based on existing token. Method is synchronous.
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 |
IMPORT_C TInt | GenerateToken | ( | const TDesC & | aFileName, |
const TUid & | aConsumerUid, | |||
TDes8 & | aToken | |||
) | const |
Generates token based on filename. Method is synchronous.
IMPORT_C TInt | GenerateToken | ( | const RFile & | aOpenFile, |
const TUid & | aConsumerUid, | |||
TDes8 & | aToken | |||
) | const |
Generates token based on open file handle. Method is synchronous.
IMPORT_C TInt | GenerateToken | ( | const TDesC8 & | aExistingToken, |
const TUid & | aConsumerUid, | |||
TDes8 & | aToken | |||
) | const |
Generates token based on existing token. Method is synchronous.
IMPORT_C TInt | OpenFileForToken | ( | RFile & | aHandle, |
const TDesC8 & | aToken | |||
) | const |
Opens filehandle based on token. Method is synchronous.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.