javaruntimes/midp/runtime/javasrc/com/nokia/mj/impl/rt/midp/MidletLifeCycle.java
changeset 50 023eef975703
parent 35 85266cc22c7f
child 87 1627c337e51e
equal deleted inserted replaced
49:35baca0e7a2e 50:023eef975703
    24 import java.util.Hashtable;
    24 import java.util.Hashtable;
    25 import java.util.Timer;
    25 import java.util.Timer;
    26 import java.util.TimerTask;
    26 import java.util.TimerTask;
    27 
    27 
    28 import java.security.AccessControlException;
    28 import java.security.AccessControlException;
       
    29 
       
    30 import com.nokia.mj.impl.gcf.PushSecurityUtils;
    29 
    31 
    30 import com.nokia.mj.impl.rt.utils.ExtensionUtil;
    32 import com.nokia.mj.impl.rt.utils.ExtensionUtil;
    31 import com.nokia.mj.impl.rt.utils.CmdLineArgsPermission;
    33 import com.nokia.mj.impl.rt.utils.CmdLineArgsPermission;
    32 
    34 
    33 import com.nokia.mj.impl.rt.support.Jvm;
    35 import com.nokia.mj.impl.rt.support.Jvm;
   990 
   992 
   991             // Inform the DRM util that the MIDlet is about to start.
   993             // Inform the DRM util that the MIDlet is about to start.
   992             DrmUtil.consumeRightsStart();
   994             DrmUtil.consumeRightsStart();
   993         }
   995         }
   994 
   996 
   995         // If the MIDlet launch is a result of auto invocation we need to
   997         // If the MIDlet launch is a result of push auto invocation we need to
   996         // ensure that user allows the start up.
   998         // ensure that user allows the start up.
   997         if ((mMainArgs.findArgument("-autoinvocation") != null) ||
   999         if (mMainArgs.findArgument("-autoinvocation") != null)
   998                 mAutoinvocationFromUrl)
  1000         {
   999         {
  1001             if (Log.mOn) Log.logI("Ensuring push autoinvocation.");
  1000             if (Log.mOn) Log.logI("Ensuring autoinvocation.");
       
  1001             String pushAdditionalInfo =
  1002             String pushAdditionalInfo =
  1002                 mMainArgs.findArgument("-autoInvocationAdditional");
  1003                 mMainArgs.findArgument("-autoInvocationAdditional");
  1003             if (Log.mOn) Log.logI("  addInfo: '" + pushAdditionalInfo + "'");
  1004             if (Log.mOn) Log.logI("  addInfo: '" + pushAdditionalInfo + "'");
       
  1005 
       
  1006             try
       
  1007             {
       
  1008                 PushSecurityUtils.ensurePermission("autoinvocation",
       
  1009                                                    pushAdditionalInfo);
       
  1010             }catch(SecurityException e)
       
  1011             {
       
  1012                 // The user didn't allow starting. Throw StartupException and
       
  1013                 // mark it as non fatal.
       
  1014                 if (Log.mOn) Log.logI("Push autoinvocation NOT allowed.");                
       
  1015                 throw new StartupException(e.toString(),
       
  1016                                            false);
       
  1017             }
       
  1018         }
       
  1019         
       
  1020         // If the MIDlet launch is triggered from url we need to
       
  1021         // ensure that user allows the start up.
       
  1022         if (mAutoinvocationFromUrl)
       
  1023         {
       
  1024             if (Log.mOn) Log.logI("Ensuring web start invocation.");
  1004 
  1025 
  1005             // ensure security
  1026             // ensure security
  1006             try
  1027             try
  1007             {
  1028             {
  1008                 ApplicationUtils appUtils = ApplicationUtils.getInstance();
  1029                 ApplicationUtils appUtils = ApplicationUtils.getInstance();
  1009                 CmdLineArgsPermission cmdLineArgsPermission = 
  1030                 CmdLineArgsPermission cmdLineArgsPermission = 
  1010                     new CmdLineArgsPermission();
  1031                     new CmdLineArgsPermission();
  1011                 appUtils.checkPermission(cmdLineArgsPermission);
  1032                 appUtils.checkPermission(cmdLineArgsPermission);
  1012                 if (Log.mOn) Log.logI("Autoinvocation allowed.");
  1033                 if (Log.mOn) Log.logI("Web start invocation allowed.");
  1013             }catch(AccessControlException e)
  1034             }catch(AccessControlException e)
  1014             {
  1035             {
  1015                 if (Log.mOn) Log.logI("Autoinvocation NOT allowed.");                
  1036                 if (Log.mOn) Log.logI("Web start invocation NOT allowed.");                
  1016                 throw new StartupException(e.toString(),
  1037                 throw new StartupException(e.toString(),
  1017                                            false);
  1038                                            false);
  1018             }
  1039             }
  1019         }
  1040         }
  1020 
  1041