|
1 /* |
|
2 * Copyright (c) 2008 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 package com.nokia.mj.impl.properties.mobinfo; |
|
19 |
|
20 import java.security.Permission; |
|
21 import java.security.PermissionCollection; |
|
22 import com.nokia.mj.impl.security.common.PermissionBase; |
|
23 import com.nokia.mj.impl.security.utils.SecurityPromptMessage; |
|
24 |
|
25 public class MobileInfoPermission extends PermissionBase |
|
26 { |
|
27 // the known target names |
|
28 private static final String IMSI_TARGET_NAME = "mobinfo.imsi"; |
|
29 private static final String MSISDN_TARGET_NAME = "mobinfo.msisdn"; |
|
30 private static final String PUBLIC_INFO_TARGET_NAME = "mobinfo.publicinfo"; |
|
31 |
|
32 private String iTarget = null; |
|
33 private String iAction = null; |
|
34 |
|
35 public MobileInfoPermission(String aUri,String aAction) |
|
36 { |
|
37 super(aUri); |
|
38 // figure out the target |
|
39 if (IMSI_TARGET_NAME.equals(aUri) |
|
40 || MSISDN_TARGET_NAME.equals(aUri) |
|
41 || PUBLIC_INFO_TARGET_NAME.equals(aUri)) |
|
42 { |
|
43 // aUri contains a known target name -> save it as such |
|
44 iTarget = aUri; |
|
45 } |
|
46 else |
|
47 { |
|
48 // the aUri contains the property name |
|
49 // -> do the mapping between the property name and the known |
|
50 // target names |
|
51 if (MobileInfoProperties.IMSI.equals(aUri)) |
|
52 { |
|
53 iTarget = IMSI_TARGET_NAME; |
|
54 } |
|
55 else if (MobileInfoProperties.MSISDN.equals(aUri)) |
|
56 { |
|
57 iTarget = MSISDN_TARGET_NAME; |
|
58 } |
|
59 else |
|
60 { |
|
61 iTarget = PUBLIC_INFO_TARGET_NAME; |
|
62 } |
|
63 } |
|
64 iAction = aAction; |
|
65 } |
|
66 |
|
67 /** |
|
68 * Returns the question (as localized text) associated with the security |
|
69 * prompt |
|
70 * |
|
71 * @return the localized text associated with the security prompt |
|
72 */ |
|
73 public String getSecurityPromptQuestion(int aInteractionMode) |
|
74 { |
|
75 return null; |
|
76 } |
|
77 |
|
78 public String toString() |
|
79 { |
|
80 if (IMSI_TARGET_NAME.equals(iTarget)) |
|
81 { |
|
82 return "com.nokia.mid.Mobinfo.IMSI"; |
|
83 } |
|
84 else if (MSISDN_TARGET_NAME.equals(iTarget)) |
|
85 { |
|
86 return "com.nokia.mid.Mobinfo.MSISDN"; |
|
87 } |
|
88 return null; |
|
89 } |
|
90 |
|
91 public boolean implies(Permission permission) |
|
92 { |
|
93 if (permission instanceof MobileInfoPermission) |
|
94 { |
|
95 MobileInfoPermission perm = (MobileInfoPermission)permission; |
|
96 // the target and action must be identical |
|
97 if (((iTarget != null && iTarget.equalsIgnoreCase(perm.iTarget)) |
|
98 || (iTarget == null && perm.iTarget == null)) && |
|
99 ((iAction != null && iAction.equalsIgnoreCase(perm.iAction)) |
|
100 || (iAction == null && perm.iAction == null))) |
|
101 { |
|
102 return true; |
|
103 } |
|
104 } |
|
105 return false; |
|
106 } |
|
107 |
|
108 public int hashCode() |
|
109 { |
|
110 return 0; |
|
111 } |
|
112 |
|
113 public boolean equals(Object obj) |
|
114 { |
|
115 return true; |
|
116 } |
|
117 |
|
118 public String getActions() |
|
119 { |
|
120 return iAction; |
|
121 } |
|
122 |
|
123 public PermissionCollection newPermissionCollection() |
|
124 { |
|
125 return null; |
|
126 } |
|
127 |
|
128 } |