|
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_common_GeneralSecuritySettings.h" |
|
23 |
|
24 using namespace java::util; |
|
25 |
|
26 // Java Security Policy Central Repository UID |
|
27 static const TUid KCRUidJavaSecurityPolicy = { 0x2001B289 }; |
|
28 // IDs for security policy and security warnings mode |
|
29 static const TUint32 KPolicyFileName = 0x01; |
|
30 static const TUint32 KPolicy = 0x03; |
|
31 static const TUint32 KWarningsMode = 0x04; |
|
32 |
|
33 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_security_midp_common_GeneralSecuritySettings__1getSecurityPolicy |
|
34 (JNIEnv * aEnv, jclass) |
|
35 { |
|
36 jstring ret = NULL; |
|
37 CRepository* repository = NULL; |
|
38 HBufC* buf = NULL; |
|
39 TRAP_IGNORE( |
|
40 repository = CRepository::NewLC(KCRUidJavaSecurityPolicy); |
|
41 buf = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength); |
|
42 TPtr policy(buf->Des()); |
|
43 TInt err = repository->Get(KPolicy, policy); |
|
44 if (err != KErrNone) |
|
45 { |
|
46 // one more try // remove this once the new key (0x03) is in place |
|
47 User::LeaveIfError(repository->Get(KPolicyFileName, policy)); |
|
48 TInt sep = policy.Find(_L("_")); |
|
49 if (sep > 0) |
|
50 { |
|
51 policy.Set(policy.LeftTPtr(sep)); |
|
52 policy.SetLength(sep); |
|
53 } |
|
54 } |
|
55 ret = S60CommonUtils::NativeToJavaString(*aEnv, policy); |
|
56 CleanupStack::PopAndDestroy(buf); |
|
57 CleanupStack::PopAndDestroy(repository); |
|
58 ); |
|
59 return ret; |
|
60 } |
|
61 |
|
62 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_security_midp_common_GeneralSecuritySettings__1getDefaultSecurityWarningsMode |
|
63 (JNIEnv *, jclass) |
|
64 { |
|
65 TInt ret = -1; |
|
66 CRepository* repository = NULL; |
|
67 TRAP_IGNORE( |
|
68 repository = CRepository::NewLC(KCRUidJavaSecurityPolicy); |
|
69 User::LeaveIfError(repository->Get(KWarningsMode, ret)); |
|
70 CleanupStack::PopAndDestroy(repository); |
|
71 ); |
|
72 return ret; |
|
73 } |
|
74 |