⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 securitydomain.java

📁 有关j2me的很好的例子可以研究一下
💻 JAVA
字号:
/* *  @(#)SecurityDomain.java	1.4 01/08/08 *  *  Copyright (c) 2001 Sun Microsystems, Inc., 901 San Antonio Road, *  Palo Alto, CA 94303, U.S.A.  All Rights Reserved. * *  Sun Microsystems, Inc. has intellectual property rights relating *  to the technology embodied in this software.  In particular, and *  without limitation, these intellectual property rights may include *  one or more U.S. patents, foreign patents, or pending *  applications.  Sun, Sun Microsystems, the Sun logo, Java, KJava, *  and all Sun-based and Java-based marks are trademarks or *  registered trademarks of Sun Microsystems, Inc.  in the United *  States and other countries. * *  This software is distributed under licenses restricting its use, *  copying, distribution, and decompilation.  No part of this *  software may be reproduced in any form by any means without prior *  written authorization of Sun and its licensors, if any. * *  FEDERAL ACQUISITIONS:  Commercial Software -- Government Users *  Subject to Standard License Terms and Conditions */package com.sun.midp.security;/** * Contains methods to get various security state information of the currently * running MIDlet suite. It cannot be instantiated. */public final class SecurityDomain {    /** Name of the internal domain. */    // according to the MExE spec the user of phone has full control.    public static final String INTERNAL_DOMAIN_NAME = "user";    /** Enables the first domain be constructed without a domain. */    private static boolean firstCaller = true;    /** Domain name. */    private String name;    /** Permitted actions. */    private int actions[] = null;    /**     * Creates a security domain with a list of permitted actions or no list     * to indicate all actions. The caller must be have permission for     * <code>Actions.DEVICE_CORE_FUNCTION</code> or be the first caller of     * the method for this instance of the VM.     * @param securityDomain security domain of the caller, can be null for     *                       the first caller     * @param theName domain to create, can be null     * @exception SecurityException if caller is not permitted to call this     *            method     */    public SecurityDomain(SecurityDomain securityDomain, String theName) {        // assume the JAM is the first caller        if (firstCaller) {            firstCaller = false;        } else {            securityDomain.checkIfPermitted(Actions.DEVICE_CORE_FUNCTION);        }        if (theName == null) {            name = INTERNAL_DOMAIN_NAME;            /* signal all actions by keeping the actions field null */            return;        }        name = theName;        actions = Actions.forDomain(name);    }    /**     * Check to see the domain permitted to perform a specific action.     *     * @param action an action code     * @exception SecurityException if the domain is not     *            permitted to perform the specified action.     */    public void checkIfPermitted(int action) {        if (actions == null) {            /* totally trusted, all actions are permitted */            return;        }        for (int i = 0; i < actions.length; i++) {            if (actions[i] == action) {                return;            }        }        throw new SecurityException("Application not authorized " +                                    "to access the restricted API");    }    /**     * Gets the name of this security domain.     *     * @return name of this security domain     */    public String getName() {        return name;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -