javamanager/javaregistry/legacy/server/src/javaregserverpolicycheck.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 27 Apr 2010 16:30:29 +0300
branchRCL_3
changeset 14 04becd199f91
permissions -rw-r--r--
Revision: v2.1.22 Kit: 201017

/*
* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  javaregserverpolicycheck implementation
*
*/


#include "javaregserver.h"
#include "javaregserversession.h"
#include "javaregserverallowedid.h"
#include "logger.h"

// ============================ MEMBER FUNCTIONS ==============================

// ---------------------------------------------------------------------------
// CJavaRegServer::CustomSecurityCheckL
// ---------------------------------------------------------------------------
//
// using namespace Java::Utilities;
using namespace Java::Manager::Registry;

CPolicyServer::TCustomResult CJavaRegServer::CustomSecurityCheckL(
    const RMessage2&  aMsg,
    TInt&  aAction,
    TSecurityInfo&  /*aMissing*/)
{
    JELOG(EJavaStorage, "CJavaRegServer::CustomSecurityCheckL()");
    switch (aMsg.Function())
    {
    case EInitializeServerTransId:
    case ESetEntry:
    case ERemoveEntry:
    case ERemoveEntryFromAll:
    case EAllocateUids:
        // Pass if the client is Java Installer OR OSGi VM OR SDK debug agent
        if (aMsg.SecureId() == AllowedClientSecureId_Installer ||
                aMsg.SecureId() == AllowedClientSecureId_OsgiVm ||
                aMsg.SecureId() == AllowedClientSecureId_SDKDebugAgent)
        {
            return CPolicyServer::EPass;
        }
        // Pass if the client is using the legacy API AND
        // it's either JavaHelperServer OR AppInstUi.
        // Written as an 'elseif' only for better readability's sake.
        else if (((CJavaRegServerSession*)(aMsg.Session()))->IsLegacy() &&
                 (aMsg.SecureId() == AllowedClientSecureId_JavaHelperServer ||
                  aMsg.SecureId() == AllowedClientSecureId_AppInstUi))
        {
            return CPolicyServer::EPass;
        }
        else
        {
            aAction = CPolicyServer::EFailClient;
            return CPolicyServer::EFail;
        }
        // falltrough not possible here
    case ESetBackupState:
        if (aMsg.SecureId() == AllowedClientSecureId_Backup)
        {
            return CPolicyServer::EPass;
        }
        else
        {
            aAction = CPolicyServer::EFailClient;
            return CPolicyServer::EFail;
        }
        // falltrough not possible here
    default:
        aAction = CPolicyServer::EFailClient;
        return CPolicyServer::EFail;
        // falltrough not possible here
    }
}