1 /* |
|
2 * Copyright (c) 2009 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 package com.nokia.mj.impl.rt.legacy; |
|
18 import com.nokia.mj.impl.rt.support.ApplicationUtils; |
|
19 import com.nokia.mj.impl.security.midp.common.PermissionMappingTable; |
|
20 import com.nokia.mj.impl.security.midp.common.MIDPPermission; |
|
21 import com.nokia.mj.impl.security.midp.authorization.ClassInstantiator; |
|
22 import com.nokia.mj.impl.utils.Logger; |
|
23 import java.security.Permission; |
|
24 |
|
25 public final class Security |
|
26 { |
|
27 public static void ensurePermission(String aPermission, String aOperation, String[] aArgs) |
|
28 throws |
|
29 SecurityException |
|
30 { |
|
31 if (aPermission != null) |
|
32 { |
|
33 MIDPPermission internalPermission = PermissionMappingTable.get( |
|
34 aPermission); |
|
35 if (internalPermission != null) |
|
36 { |
|
37 // make an instance of the internal permission |
|
38 try |
|
39 { |
|
40 Permission permission = (Permission)ClassInstantiator |
|
41 .newInstance(internalPermission.getName(), |
|
42 internalPermission.getTarget(), |
|
43 internalPermission.getActionList()); |
|
44 ApplicationUtils appUtils = ApplicationUtils.getInstance(); |
|
45 appUtils.checkPermission(permission); |
|
46 return; |
|
47 } |
|
48 catch (InstantiationException e) |
|
49 { |
|
50 // fall-through |
|
51 } |
|
52 } |
|
53 } |
|
54 throw new SecurityException("Permission " + aPermission + " not allowed"); |
|
55 } |
|
56 |
|
57 } |
|