/**
   * Constructor for development subclass.
   *
   * @param callerSecurityToken security token for the calling class
   * @param suitePermissions security token of the suite
   * @param pushSetting can this MIDlet suite interrupt other suites
   * @param trustedFlag true if the suite is to considered trusted (not to be confused with a domain
   *     named "trusted", this only shown to the user and not used for permissions)
   * @param theStorageName name to separate this suite's storage from others
   */
  protected MIDletSuiteImpl(
      SecurityToken callerSecurityToken,
      byte[][] suitePermissions,
      int pushSetting,
      boolean trustedFlag,
      String theStorageName) {

    callerSecurityToken.checkIfPermissionAllowed(Permissions.MIDP);

    permissions = suitePermissions;
    securityToken = new SecurityToken(classSecurityToken, permissions);
    pushInterruptSetting = pushSetting;
    trusted = trustedFlag;
    storageName = theStorageName;
  }
  /**
   * get an available connection and set the boolean flag to true (unavailable) in the connection
   * pool. Also removes any stale connections, since this method gets called more than add or
   * remove.
   *
   * @param callerSecurityToken The security token of the caller
   * @param p_protocol The protocol for the connection
   * @param p_host The Hostname for the connection
   * @param p_port The port number for the connection
   * @return A stream connection element or null if not found
   */
  public synchronized StreamConnectionElement get(
      SecurityToken callerSecurityToken, String p_protocol, String p_host, int p_port) {

    StreamConnectionElement result = null;
    long c_time = System.currentTimeMillis();
    Enumeration cons = m_connections.elements();

    callerSecurityToken.checkIfPermissionAllowed(Permissions.MIDP);

    while (cons.hasMoreElements()) {
      StreamConnectionElement sce = (StreamConnectionElement) cons.nextElement();

      if ((c_time - sce.m_time) > m_connectionLingerTime) {
        if (!sce.m_in_use) {
          sce.close();
        } else {
          // signal returnToUse() to close
          sce.m_removed = true;
        }

        m_connections.removeElement(sce);
        continue;
      }

      if (p_host.equals(sce.m_host)
          && p_port == sce.m_port
          && p_protocol.equals(sce.m_protocol)
          && !sce.m_in_use) {
        result = sce;

        // do not break out so old connections can be removed
        continue;
      }
    }

    if (result != null) {
      result.m_in_use = true;
    }

    return result;
  }
  /**
   * Constructs MIDletSuiteImpl from an installed MIDlet Suite.
   *
   * @param callerSecurityToken security token for the calling class
   * @param theStorageRoot root path of any files for this suite
   * @param theStorageName unique vendor and suite name identifying this suite
   * @param theCA name of CA that authorized this suite
   * @param midletToRun the name of the initial MIDlet in this suite to run, can be null
   */
  MIDletSuiteImpl(
      SecurityToken callerSecurityToken,
      String theStorageRoot,
      String theStorageName,
      String theCA,
      String midletToRun) {
    callerSecurityToken.checkIfPermissionAllowed(Permissions.MIDP);

    storageRoot = theStorageRoot;

    storageName = theStorageName;

    ca = theCA;

    readSettings();

    securityToken = new SecurityToken(classSecurityToken, permissions);

    if (midletToRun != null) {
      initialMIDletClassName = getMIDletClassName(midletToRun);
    }
  }
Exemple #4
0
 /**
  * Secure method to send VM hint about end of a MIDlet startup phase within specified isolate
  *
  * @param token security token with the AMS permission allowed
  * @param midletIsolateId ID of the started MIDlet isolate
  */
 public static void vmEndStartUp(SecurityToken token, int midletIsolateId) {
   token.checkIfPermissionAllowed(Permissions.AMS);
   vmEndStartUp(midletIsolateId);
 }
 /**
  * Default constructor.
  *
  * @param token security token for initilaization
  * @param isolateId id of the Isolate this instance is created in
  */
 public DisplayContainer(SecurityToken token, int isolateId) {
   token.checkIfPermissionAllowed(Permissions.MIDP);
   this.isolateId = isolateId;
 }
 /**
  * Checks to see the suite has the ALLOW level for specific permission. This is used for by
  * internal APIs that only provide access to trusted system applications.
  *
  * @param permission permission ID from com.sun.midp.security.Permissions
  * @exception SecurityException if the suite is not ALLOWed the permission
  */
 public void checkIfPermissionAllowed(int permission) {
   securityToken.checkIfPermissionAllowed(permission);
 }