23 |
23 |
24 import com.nokia.mj.impl.rt.ui.ConfirmData; |
24 import com.nokia.mj.impl.rt.ui.ConfirmData; |
25 import com.nokia.mj.impl.rt.ui.RuntimeUi; |
25 import com.nokia.mj.impl.rt.ui.RuntimeUi; |
26 import com.nokia.mj.impl.rt.ui.RuntimeUiFactory; |
26 import com.nokia.mj.impl.rt.ui.RuntimeUiFactory; |
27 |
27 |
28 import com.nokia.mj.impl.rt.midp.SchemeHandlerBase; |
28 import com.nokia.mj.impl.rt.midp.SchemeHandler; |
29 |
29 |
30 import com.nokia.mj.impl.rt.support.ApplicationInfo; |
30 import com.nokia.mj.impl.rt.support.ApplicationInfo; |
31 |
31 |
32 import com.nokia.mj.impl.security.midp.authorization.AccessControllerFactoryImpl; |
32 import com.nokia.mj.impl.security.midp.authorization.AccessControllerFactoryImpl; |
33 import com.nokia.mj.impl.security.midp.authorization.AccessControllerImpl; |
33 import com.nokia.mj.impl.security.midp.authorization.AccessControllerImpl; |
59 */ |
59 */ |
60 private static boolean mConstructionAllowed = true; |
60 private static boolean mConstructionAllowed = true; |
61 |
61 |
62 private static final int DOMAIN_MANUFACTURER_OR_OPERATOR = 1; |
62 private static final int DOMAIN_MANUFACTURER_OR_OPERATOR = 1; |
63 |
63 |
|
64 private static final String JRT_SCHEME = "jrt:"; |
|
65 |
64 /*** ----------------------------- PUBLIC ------------------------------ */ |
66 /*** ----------------------------- PUBLIC ------------------------------ */ |
65 |
67 |
66 /** |
68 /** |
67 * For checking if MIDlet is allowed to do some protected action. |
69 * For checking if MIDlet is allowed to do some protected action. |
68 * @see MIDP spec for further details. |
70 * @see MIDP spec for further details. |
161 |
163 |
162 ApplicationInfo appInfo = ApplicationInfo.getInstance(); |
164 ApplicationInfo appInfo = ApplicationInfo.getInstance(); |
163 String domain = appInfo.getProtectionDomain(); |
165 String domain = appInfo.getProtectionDomain(); |
164 |
166 |
165 // Handling for java scheme. |
167 // Handling for java scheme. |
166 /*if (url.startsWith("java://")) |
168 if (url.startsWith(JRT_SCHEME)) |
167 { |
169 { |
168 String handlerName = parseHandlerName(url); |
170 String handlerName = parseHandlerName(url); |
169 |
171 |
170 if (handlerName.equals("taskmanager")) |
172 if (handlerName.equals("taskmanager")) |
171 { |
173 { |
172 // Check application is bound either Manufacturer or Operator domain. |
174 // Check application is bound either Manufacturer or Operator domain. |
173 enforceSecurityDomain(DOMAIN_MANUFACTURER_OR_OPERATOR, domain); |
175 enforceSecurityDomain(DOMAIN_MANUFACTURER_OR_OPERATOR, domain); |
174 } |
176 } |
175 |
177 |
176 return invokeSchemeHandler(handlerName, url); |
178 return invokeSchemeHandler(handlerName, url); |
177 }*/ |
179 } |
178 |
180 |
179 // If the platform request is used to start arbitrary native application, |
181 // If the platform request is used to start arbitrary native application, |
180 // check that MIDlet is in manufacturer or operator domain |
182 // check that MIDlet is in manufacturer or operator domain |
181 if (startsArbitraryNativeApp(url)) |
183 if (startsArbitraryNativeApp(url)) |
182 { |
184 { |
374 return false; |
376 return false; |
375 } |
377 } |
376 |
378 |
377 private String parseHandlerName(String url) throws ConnectionNotFoundException |
379 private String parseHandlerName(String url) throws ConnectionNotFoundException |
378 { |
380 { |
379 // Parse handler name from URL. Remove java:// prefix. |
381 // Parse handler name from URL. Remove JRT_SCHEME prefix. |
380 String handlerName = url.substring(7).trim(); |
382 String handlerName = url.substring(JRT_SCHEME.length()).trim(); |
381 |
383 |
382 // name format: handlername?query |
384 // name format: handlername?query |
383 int nameEndIndex = handlerName.indexOf('?'); |
385 int nameEndIndex = handlerName.indexOf('?'); |
384 |
386 |
385 if (nameEndIndex != -1) |
387 if (nameEndIndex != -1) |
386 { |
388 { |
387 handlerName = handlerName.substring(0, nameEndIndex); |
389 return handlerName.substring(0, nameEndIndex); |
388 return handlerName; |
390 } |
389 } |
391 throw new ConnectionNotFoundException("Handler not found for URL: " + url); |
390 else |
|
391 { |
|
392 throw new ConnectionNotFoundException("Handler not found for URL"); |
|
393 } |
|
394 } |
392 } |
395 |
393 |
396 private boolean invokeSchemeHandler(String handlerName, String url) |
394 private boolean invokeSchemeHandler(String handlerName, String url) |
397 throws ConnectionNotFoundException |
395 throws ConnectionNotFoundException |
398 { |
396 { |
399 try |
397 try |
400 { |
398 { |
401 // Avoid loading whatever class from the system using handler |
399 // Avoid loading whatever class from the system using handler |
402 // as package name. |
400 // as package name. |
403 Class clazz = Class.forName("com.nokia.mj.impl.rt." + handlerName + ".SchemeHandler"); |
401 Class clazz = Class.forName("com.nokia.mj.impl.rt." + handlerName + ".SchemeHandlerImpl"); |
404 |
402 |
405 SchemeHandlerBase handler = (SchemeHandlerBase)clazz.newInstance(); |
403 SchemeHandler handler = (SchemeHandler)clazz.newInstance(); |
406 |
404 |
407 handler.execute(url); |
405 handler.execute(url); |
408 return false; // No need to close MIDlet. |
406 return false; // No need to close MIDlet. |
409 } |
407 } |
410 catch (Throwable t) |
408 catch (Throwable t) |
411 { |
409 { |
412 Logger.ELOG(Logger.EJavaRuntime, "Cannot invoke scheme handler: " + t.toString()); |
410 Logger.ELOG(Logger.EJavaRuntime, "Cannot invoke scheme handler for url: " |
|
411 + url + " : " + t.toString()); |
413 // ClassNotFoundException, IllegalAccessException or InstantionException. |
412 // ClassNotFoundException, IllegalAccessException or InstantionException. |
414 throw new ConnectionNotFoundException("Handler not found for URL"); |
413 throw new ConnectionNotFoundException("Handler not found for URL: " + url); |
415 } |
414 } |
416 } |
415 } |
417 |
416 |
418 private void enforceSecurityDomain(int type, String domain) |
417 private void enforceSecurityDomain(int type, String domain) |
419 throws ConnectionNotFoundException |
418 throws ConnectionNotFoundException |