javacommons/security/src.s60/ocspuserpreferences.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <centralrepository.h>
       
    20 #include <SWInstallerInternalCRKeys.h>
       
    21 #include "s60commonutils.h"
       
    22 #include "com_nokia_mj_impl_security_midp_authentication_OcspUserPreferences.h"
       
    23 
       
    24 const int OCSP_MODE_ON = 1;
       
    25 const int OCSP_MODE_MUST = 2;
       
    26 const int OCSP_MODE_OFF = 3;
       
    27 
       
    28 using namespace java::util;
       
    29 
       
    30 jint JNICALL Java_com_nokia_mj_impl_security_midp_authentication_OcspUserPreferences__1getOcspMode
       
    31 (JNIEnv *, jobject)
       
    32 {
       
    33     int ocspMode = OCSP_MODE_OFF;
       
    34     CRepository* repository = NULL;
       
    35     TRAP_IGNORE(
       
    36         repository = CRepository::NewL(KCRUidSWInstallerSettings);
       
    37         CleanupStack::PushL(repository);
       
    38         TInt value(0);
       
    39         repository->Get(KSWInstallerOcspProcedure, value);
       
    40         TSWInstallerOcspProcedure ocspProc = TSWInstallerOcspProcedure(value);
       
    41         switch (ocspProc)
       
    42 {
       
    43 case ESWInstallerOcspProcedureOn:
       
    44     ocspMode = OCSP_MODE_ON;
       
    45     break;
       
    46 case ESWInstallerOcspProcedureMust:
       
    47     ocspMode = OCSP_MODE_MUST;
       
    48     break;
       
    49 case ESWInstallerOcspProcedureOff:
       
    50 default:
       
    51     ocspMode = OCSP_MODE_OFF;
       
    52 }
       
    53 CleanupStack::PopAndDestroy(repository);
       
    54 );
       
    55     return ocspMode;
       
    56 }
       
    57 
       
    58 jstring JNICALL Java_com_nokia_mj_impl_security_midp_authentication_OcspUserPreferences__1getOcspUrl
       
    59 (JNIEnv * aEnv, jobject)
       
    60 {
       
    61     jstring ret = NULL;
       
    62     CRepository* repository = NULL;
       
    63     HBufC* ocspUrl = NULL;
       
    64     TRAP_IGNORE(
       
    65         repository = CRepository::NewL(KCRUidSWInstallerSettings);
       
    66         CleanupStack::PushL(repository);
       
    67         ocspUrl = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength);
       
    68         TPtr ptr(ocspUrl->Des());
       
    69         repository->Get(KSWInstallerOcspDefaultURL, ptr);
       
    70         ret = S60CommonUtils::NativeToJavaString(*aEnv, ptr);
       
    71         CleanupStack::PopAndDestroy(ocspUrl);
       
    72         CleanupStack::PopAndDestroy(repository);
       
    73     );
       
    74     return ret;
       
    75 }