Java Code Examples for sun.security.util.Debug#println()

The following examples show how to use sun.security.util.Debug#println() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SocketPermission.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private boolean isUntrusted()
    throws UnknownHostException
{
    if (trusted) return false;
    if (invalid || untrusted) return true;
    try {
        if (!trustNameService && (defaultDeny ||
            sun.net.www.URLConnection.isProxiedHost(hostname))) {
            if (this.cname == null) {
                this.getCanonName();
            }
            if (!match(cname, hostname)) {
                // Last chance
                if (!authorized(hostname, addresses[0].getAddress())) {
                    untrusted = true;
                    Debug debug = getDebug();
                    if (debug != null && Debug.isOn("failure")) {
                        debug.println("socket access restriction: proxied host " + "(" + addresses[0] + ")" + " does not match " + cname + " from reverse lookup");
                    }
                    return true;
                }
            }
            trusted = true;
        }
    } catch (UnknownHostException uhe) {
        invalid = true;
        throw uhe;
    }
    return false;
}
 
Example 2
Source File: SocketPermission.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private boolean isUntrusted()
    throws UnknownHostException
{
    if (trusted) return false;
    if (invalid || untrusted) return true;
    try {
        if (!trustNameService && (defaultDeny ||
            sun.net.www.URLConnection.isProxiedHost(hostname))) {
            if (this.cname == null) {
                this.getCanonName();
            }
            if (!match(cname, hostname)) {
                // Last chance
                if (!authorized(hostname, addresses[0].getAddress())) {
                    untrusted = true;
                    Debug debug = getDebug();
                    if (debug != null && Debug.isOn("failure")) {
                        debug.println("socket access restriction: proxied host " + "(" + addresses[0] + ")" + " does not match " + cname + " from reverse lookup");
                    }
                    return true;
                }
            }
            trusted = true;
        }
    } catch (UnknownHostException uhe) {
        invalid = true;
        throw uhe;
    }
    return false;
}
 
Example 3
Source File: AccessController.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether the access request indicated by the
 * specified permission should be allowed or denied, based on
 * the current AccessControlContext and security policy.
 * This method quietly returns if the access request
 * is permitted, or throws an AccessControlException otherwise. The
 * getPermission method of the AccessControlException returns the
 * {@code perm} Permission object instance.
 *
 * @param perm the requested permission.
 *
 * @exception AccessControlException if the specified permission
 *            is not permitted, based on the current security policy.
 * @exception NullPointerException if the specified permission
 *            is {@code null} and is checked based on the
 *            security policy currently in effect.
 */

public static void checkPermission(Permission perm)
    throws AccessControlException
{
    //System.err.println("checkPermission "+perm);
    //Thread.currentThread().dumpStack();

    if (perm == null) {
        throw new NullPointerException("permission can't be null");
    }

    AccessControlContext stack = getStackAccessControlContext();
    // if context is null, we had privileged system code on the stack.
    if (stack == null) {
        Debug debug = AccessControlContext.getDebug();
        boolean dumpDebug = false;
        if (debug != null) {
            dumpDebug = !Debug.isOn("codebase=");
            dumpDebug &= !Debug.isOn("permission=") ||
                Debug.isOn("permission=" + perm.getClass().getCanonicalName());
        }

        if (dumpDebug && Debug.isOn("stack")) {
            Thread.dumpStack();
        }

        if (dumpDebug && Debug.isOn("domain")) {
            debug.println("domain (context is null)");
        }

        if (dumpDebug) {
            debug.println("access allowed "+perm);
        }
        return;
    }

    AccessControlContext acc = stack.optimize();
    acc.checkPermission(perm);
}
 
Example 4
Source File: Policy.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set or installed. This method is called by
 * SubjectDomainCombiner to provide backwards compatibility for
 * developers that provide their own javax.security.auth.Policy
 * implementations.
 *
 * @return true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set; false otherwise
 */
static boolean isCustomPolicySet(Debug debug) {
    if (policy != null) {
        if (debug != null && isCustomPolicy) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policy.toString());
        }
        return isCustomPolicy;
    }
    // check if custom policy has been set using auth.policy.provider prop
    String policyClass = java.security.AccessController.doPrivileged
        (new java.security.PrivilegedAction<String>() {
            public String run() {
                return Security.getProperty("auth.policy.provider");
            }
    });
    if (policyClass != null && !policyClass.equals(AUTH_POLICY)) {
        if (debug != null) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policyClass);
        }
        return true;
    }
    return false;
}
 
Example 5
Source File: SocketPermission.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private boolean isUntrusted()
    throws UnknownHostException
{
    if (trusted) return false;
    if (invalid || untrusted) return true;
    try {
        if (!trustNameService && (defaultDeny ||
            sun.net.www.URLConnection.isProxiedHost(hostname))) {
            if (this.cname == null) {
                this.getCanonName();
            }
            if (!match(cname, hostname)) {
                // Last chance
                if (!authorized(hostname, addresses[0].getAddress())) {
                    untrusted = true;
                    Debug debug = getDebug();
                    if (debug != null && Debug.isOn("failure")) {
                        debug.println("socket access restriction: proxied host " + "(" + addresses[0] + ")" + " does not match " + cname + " from reverse lookup");
                    }
                    return true;
                }
            }
            trusted = true;
        }
    } catch (UnknownHostException uhe) {
        invalid = true;
        throw uhe;
    }
    return false;
}
 
Example 6
Source File: AccessController.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether the access request indicated by the
 * specified permission should be allowed or denied, based on
 * the current AccessControlContext and security policy.
 * This method quietly returns if the access request
 * is permitted, or throws an AccessControlException otherwise. The
 * getPermission method of the AccessControlException returns the
 * {@code perm} Permission object instance.
 *
 * @param perm the requested permission.
 *
 * @exception AccessControlException if the specified permission
 *            is not permitted, based on the current security policy.
 * @exception NullPointerException if the specified permission
 *            is {@code null} and is checked based on the
 *            security policy currently in effect.
 */

public static void checkPermission(Permission perm)
    throws AccessControlException
{
    //System.err.println("checkPermission "+perm);
    //Thread.currentThread().dumpStack();

    if (perm == null) {
        throw new NullPointerException("permission can't be null");
    }

    AccessControlContext stack = getStackAccessControlContext();
    // if context is null, we had privileged system code on the stack.
    if (stack == null) {
        Debug debug = AccessControlContext.getDebug();
        boolean dumpDebug = false;
        if (debug != null) {
            dumpDebug = !Debug.isOn("codebase=");
            dumpDebug &= !Debug.isOn("permission=") ||
                Debug.isOn("permission=" + perm.getClass().getCanonicalName());
        }

        if (dumpDebug && Debug.isOn("stack")) {
            Thread.dumpStack();
        }

        if (dumpDebug && Debug.isOn("domain")) {
            debug.println("domain (context is null)");
        }

        if (dumpDebug) {
            debug.println("access allowed "+perm);
        }
        return;
    }

    AccessControlContext acc = stack.optimize();
    acc.checkPermission(perm);
}
 
Example 7
Source File: Policy.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set or installed. This method is called by
 * SubjectDomainCombiner to provide backwards compatibility for
 * developers that provide their own javax.security.auth.Policy
 * implementations.
 *
 * @return true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set; false otherwise
 */
static boolean isCustomPolicySet(Debug debug) {
    if (policy != null) {
        if (debug != null && isCustomPolicy) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policy.toString());
        }
        return isCustomPolicy;
    }
    // check if custom policy has been set using auth.policy.provider prop
    String policyClass = java.security.AccessController.doPrivileged
        (new java.security.PrivilegedAction<String>() {
            public String run() {
                return Security.getProperty("auth.policy.provider");
            }
    });
    if (policyClass != null && !policyClass.equals(AUTH_POLICY)) {
        if (debug != null) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policyClass);
        }
        return true;
    }
    return false;
}
 
Example 8
Source File: SocketPermission.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private boolean isUntrusted()
    throws UnknownHostException
{
    if (trusted) return false;
    if (invalid || untrusted) return true;
    try {
        if (!trustNameService && (defaultDeny ||
            sun.net.www.URLConnection.isProxiedHost(hostname))) {
            if (this.cname == null) {
                this.getCanonName();
            }
            if (!match(cname, hostname)) {
                // Last chance
                if (!authorized(hostname, addresses[0].getAddress())) {
                    untrusted = true;
                    Debug debug = getDebug();
                    if (debug != null && Debug.isOn("failure")) {
                        debug.println("socket access restriction: proxied host " + "(" + addresses[0] + ")" + " does not match " + cname + " from reverse lookup");
                    }
                    return true;
                }
            }
            trusted = true;
        }
    } catch (UnknownHostException uhe) {
        invalid = true;
        throw uhe;
    }
    return false;
}
 
Example 9
Source File: AccessController.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Determines whether the access request indicated by the
 * specified permission should be allowed or denied, based on
 * the current AccessControlContext and security policy.
 * This method quietly returns if the access request
 * is permitted, or throws an AccessControlException otherwise. The
 * getPermission method of the AccessControlException returns the
 * {@code perm} Permission object instance.
 *
 * @param perm the requested permission.
 *
 * @exception AccessControlException if the specified permission
 *            is not permitted, based on the current security policy.
 * @exception NullPointerException if the specified permission
 *            is {@code null} and is checked based on the
 *            security policy currently in effect.
 */

public static void checkPermission(Permission perm)
    throws AccessControlException
{
    //System.err.println("checkPermission "+perm);
    //Thread.currentThread().dumpStack();

    if (perm == null) {
        throw new NullPointerException("permission can't be null");
    }

    AccessControlContext stack = getStackAccessControlContext();
    // if context is null, we had privileged system code on the stack.
    if (stack == null) {
        Debug debug = AccessControlContext.getDebug();
        boolean dumpDebug = false;
        if (debug != null) {
            dumpDebug = !Debug.isOn("codebase=");
            dumpDebug &= !Debug.isOn("permission=") ||
                Debug.isOn("permission=" + perm.getClass().getCanonicalName());
        }

        if (dumpDebug && Debug.isOn("stack")) {
            Thread.dumpStack();
        }

        if (dumpDebug && Debug.isOn("domain")) {
            debug.println("domain (context is null)");
        }

        if (dumpDebug) {
            debug.println("access allowed "+perm);
        }
        return;
    }

    AccessControlContext acc = stack.optimize();
    acc.checkPermission(perm);
}
 
Example 10
Source File: SocketPermission.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private boolean isUntrusted()
    throws UnknownHostException
{
    if (trusted) return false;
    if (invalid || untrusted) return true;
    try {
        if (!trustNameService && (defaultDeny ||
            sun.net.www.URLConnection.isProxiedHost(hostname))) {
            if (this.cname == null) {
                this.getCanonName();
            }
            if (!match(cname, hostname)) {
                // Last chance
                if (!authorized(hostname, addresses[0].getAddress())) {
                    untrusted = true;
                    Debug debug = getDebug();
                    if (debug != null && Debug.isOn("failure")) {
                        debug.println("socket access restriction: proxied host " + "(" + addresses[0] + ")" + " does not match " + cname + " from reverse lookup");
                    }
                    return true;
                }
            }
            trusted = true;
        }
    } catch (UnknownHostException uhe) {
        invalid = true;
        throw uhe;
    }
    return false;
}
 
Example 11
Source File: AccessController.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether the access request indicated by the
 * specified permission should be allowed or denied, based on
 * the current AccessControlContext and security policy.
 * This method quietly returns if the access request
 * is permitted, or throws an AccessControlException otherwise. The
 * getPermission method of the AccessControlException returns the
 * {@code perm} Permission object instance.
 *
 * @param perm the requested permission.
 *
 * @exception AccessControlException if the specified permission
 *            is not permitted, based on the current security policy.
 * @exception NullPointerException if the specified permission
 *            is {@code null} and is checked based on the
 *            security policy currently in effect.
 */

public static void checkPermission(Permission perm)
    throws AccessControlException
{
    //System.err.println("checkPermission "+perm);
    //Thread.currentThread().dumpStack();

    if (perm == null) {
        throw new NullPointerException("permission can't be null");
    }

    AccessControlContext stack = getStackAccessControlContext();
    // if context is null, we had privileged system code on the stack.
    if (stack == null) {
        Debug debug = AccessControlContext.getDebug();
        boolean dumpDebug = false;
        if (debug != null) {
            dumpDebug = !Debug.isOn("codebase=");
            dumpDebug &= !Debug.isOn("permission=") ||
                Debug.isOn("permission=" + perm.getClass().getCanonicalName());
        }

        if (dumpDebug && Debug.isOn("stack")) {
            Thread.dumpStack();
        }

        if (dumpDebug && Debug.isOn("domain")) {
            debug.println("domain (context is null)");
        }

        if (dumpDebug) {
            debug.println("access allowed "+perm);
        }
        return;
    }

    AccessControlContext acc = stack.optimize();
    acc.checkPermission(perm);
}
 
Example 12
Source File: AccessController.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether the access request indicated by the
 * specified permission should be allowed or denied, based on
 * the current AccessControlContext and security policy.
 * This method quietly returns if the access request
 * is permitted, or throws an AccessControlException otherwise. The
 * getPermission method of the AccessControlException returns the
 * {@code perm} Permission object instance.
 *
 * @param perm the requested permission.
 *
 * @exception AccessControlException if the specified permission
 *            is not permitted, based on the current security policy.
 * @exception NullPointerException if the specified permission
 *            is {@code null} and is checked based on the
 *            security policy currently in effect.
 */

public static void checkPermission(Permission perm)
    throws AccessControlException
{
    //System.err.println("checkPermission "+perm);
    //Thread.currentThread().dumpStack();

    if (perm == null) {
        throw new NullPointerException("permission can't be null");
    }

    AccessControlContext stack = getStackAccessControlContext();
    // if context is null, we had privileged system code on the stack.
    if (stack == null) {
        Debug debug = AccessControlContext.getDebug();
        boolean dumpDebug = false;
        if (debug != null) {
            dumpDebug = !Debug.isOn("codebase=");
            dumpDebug &= !Debug.isOn("permission=") ||
                Debug.isOn("permission=" + perm.getClass().getCanonicalName());
        }

        if (dumpDebug && Debug.isOn("stack")) {
            Thread.dumpStack();
        }

        if (dumpDebug && Debug.isOn("domain")) {
            debug.println("domain (context is null)");
        }

        if (dumpDebug) {
            debug.println("access allowed "+perm);
        }
        return;
    }

    AccessControlContext acc = stack.optimize();
    acc.checkPermission(perm);
}
 
Example 13
Source File: Policy.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set or installed. This method is called by
 * SubjectDomainCombiner to provide backwards compatibility for
 * developers that provide their own javax.security.auth.Policy
 * implementations.
 *
 * @return true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set; false otherwise
 */
static boolean isCustomPolicySet(Debug debug) {
    if (policy != null) {
        if (debug != null && isCustomPolicy) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policy.toString());
        }
        return isCustomPolicy;
    }
    // check if custom policy has been set using auth.policy.provider prop
    String policyClass = java.security.AccessController.doPrivileged
        (new java.security.PrivilegedAction<String>() {
            public String run() {
                return Security.getProperty("auth.policy.provider");
            }
    });
    if (policyClass != null && !policyClass.equals(AUTH_POLICY)) {
        if (debug != null) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policyClass);
        }
        return true;
    }
    return false;
}
 
Example 14
Source File: SocketPermission.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private boolean isUntrusted()
    throws UnknownHostException
{
    if (trusted) return false;
    if (invalid || untrusted) return true;
    try {
        if (!trustNameService && (defaultDeny ||
            sun.net.www.URLConnection.isProxiedHost(hostname))) {
            if (this.cname == null) {
                this.getCanonName();
            }
            if (!match(cname, hostname)) {
                // Last chance
                if (!authorized(hostname, addresses[0].getAddress())) {
                    untrusted = true;
                    Debug debug = getDebug();
                    if (debug != null && Debug.isOn("failure")) {
                        debug.println("socket access restriction: proxied host " + "(" + addresses[0] + ")" + " does not match " + cname + " from reverse lookup");
                    }
                    return true;
                }
            }
            trusted = true;
        }
    } catch (UnknownHostException uhe) {
        invalid = true;
        throw uhe;
    }
    return false;
}
 
Example 15
Source File: AccessController.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines whether the access request indicated by the
 * specified permission should be allowed or denied, based on
 * the current AccessControlContext and security policy.
 * This method quietly returns if the access request
 * is permitted, or throws an AccessControlException otherwise. The
 * getPermission method of the AccessControlException returns the
 * {@code perm} Permission object instance.
 *
 * @param perm the requested permission.
 *
 * @exception AccessControlException if the specified permission
 *            is not permitted, based on the current security policy.
 * @exception NullPointerException if the specified permission
 *            is {@code null} and is checked based on the
 *            security policy currently in effect.
 */

public static void checkPermission(Permission perm)
    throws AccessControlException
{
    //System.err.println("checkPermission "+perm);
    //Thread.currentThread().dumpStack();

    if (perm == null) {
        throw new NullPointerException("permission can't be null");
    }

    AccessControlContext stack = getStackAccessControlContext();
    // if context is null, we had privileged system code on the stack.
    if (stack == null) {
        Debug debug = AccessControlContext.getDebug();
        boolean dumpDebug = false;
        if (debug != null) {
            dumpDebug = !Debug.isOn("codebase=");
            dumpDebug &= !Debug.isOn("permission=") ||
                Debug.isOn("permission=" + perm.getClass().getCanonicalName());
        }

        if (dumpDebug && Debug.isOn("stack")) {
            Thread.dumpStack();
        }

        if (dumpDebug && Debug.isOn("domain")) {
            debug.println("domain (context is null)");
        }

        if (dumpDebug) {
            debug.println("access allowed "+perm);
        }
        return;
    }

    AccessControlContext acc = stack.optimize();
    acc.checkPermission(perm);
}
 
Example 16
Source File: Policy.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set or installed. This method is called by
 * SubjectDomainCombiner to provide backwards compatibility for
 * developers that provide their own javax.security.auth.Policy
 * implementations.
 *
 * @return true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set; false otherwise
 */
static boolean isCustomPolicySet(Debug debug) {
    if (policy != null) {
        if (debug != null && isCustomPolicy) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policy.toString());
        }
        return isCustomPolicy;
    }
    // check if custom policy has been set using auth.policy.provider prop
    String policyClass = java.security.AccessController.doPrivileged
        (new java.security.PrivilegedAction<String>() {
            public String run() {
                return Security.getProperty("auth.policy.provider");
            }
    });
    if (policyClass != null && !policyClass.equals(AUTH_POLICY)) {
        if (debug != null) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policyClass);
        }
        return true;
    }
    return false;
}
 
Example 17
Source File: SocketPermission.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private boolean isUntrusted()
    throws UnknownHostException
{
    if (trusted) return false;
    if (invalid || untrusted) return true;
    try {
        if (!trustNameService && (defaultDeny ||
            sun.net.www.URLConnection.isProxiedHost(hostname))) {
            if (this.cname == null) {
                this.getCanonName();
            }
            if (!match(cname, hostname)) {
                // Last chance
                if (!authorized(hostname, addresses[0].getAddress())) {
                    untrusted = true;
                    Debug debug = getDebug();
                    if (debug != null && Debug.isOn("failure")) {
                        debug.println("socket access restriction: proxied host " + "(" + addresses[0] + ")" + " does not match " + cname + " from reverse lookup");
                    }
                    return true;
                }
            }
            trusted = true;
        }
    } catch (UnknownHostException uhe) {
        invalid = true;
        throw uhe;
    }
    return false;
}
 
Example 18
Source File: Policy.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set or installed. This method is called by
 * SubjectDomainCombiner to provide backwards compatibility for
 * developers that provide their own javax.security.auth.Policy
 * implementations.
 *
 * @return true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set; false otherwise
 */
static boolean isCustomPolicySet(Debug debug) {
    if (policy != null) {
        if (debug != null && isCustomPolicy) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policy.toString());
        }
        return isCustomPolicy;
    }
    // check if custom policy has been set using auth.policy.provider prop
    String policyClass = java.security.AccessController.doPrivileged
        (new java.security.PrivilegedAction<String>() {
            public String run() {
                return Security.getProperty("auth.policy.provider");
            }
    });
    if (policyClass != null && !policyClass.equals(AUTH_POLICY)) {
        if (debug != null) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policyClass);
        }
        return true;
    }
    return false;
}
 
Example 19
Source File: AccessController.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Determines whether the access request indicated by the
 * specified permission should be allowed or denied, based on
 * the current AccessControlContext and security policy.
 * This method quietly returns if the access request
 * is permitted, or throws an AccessControlException otherwise. The
 * getPermission method of the AccessControlException returns the
 * {@code perm} Permission object instance.
 *
 * @param perm the requested permission.
 *
 * @throws    AccessControlException if the specified permission
 *            is not permitted, based on the current security policy.
 * @throws    NullPointerException if the specified permission
 *            is {@code null} and is checked based on the
 *            security policy currently in effect.
 */

public static void checkPermission(Permission perm)
    throws AccessControlException
{
    //System.err.println("checkPermission "+perm);
    //Thread.currentThread().dumpStack();

    if (perm == null) {
        throw new NullPointerException("permission can't be null");
    }

    AccessControlContext stack = getStackAccessControlContext();
    // if context is null, we had privileged system code on the stack.
    if (stack == null) {
        Debug debug = AccessControlContext.getDebug();
        boolean dumpDebug = false;
        if (debug != null) {
            dumpDebug = !Debug.isOn("codebase=");
            dumpDebug &= !Debug.isOn("permission=") ||
                Debug.isOn("permission=" + perm.getClass().getCanonicalName());
        }

        if (dumpDebug && Debug.isOn("stack")) {
            Thread.dumpStack();
        }

        if (dumpDebug && Debug.isOn("domain")) {
            debug.println("domain (context is null)");
        }

        if (dumpDebug) {
            debug.println("access allowed "+perm);
        }
        return;
    }

    AccessControlContext acc = stack.optimize();
    acc.checkPermission(perm);
}
 
Example 20
Source File: SocketPermission.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private boolean isUntrusted()
    throws UnknownHostException
{
    if (trusted) return false;
    if (invalid || untrusted) return true;
    try {
        if (!trustNameService && (defaultDeny ||
            sun.net.www.URLConnection.isProxiedHost(hostname))) {
            if (this.cname == null) {
                this.getCanonName();
            }
            if (!match(cname, hostname)) {
                // Last chance
                if (!authorized(hostname, addresses[0].getAddress())) {
                    untrusted = true;
                    Debug debug = getDebug();
                    if (debug != null && Debug.isOn("failure")) {
                        debug.println("socket access restriction: proxied host " + "(" + addresses[0] + ")" + " does not match " + cname + " from reverse lookup");
                    }
                    return true;
                }
            }
            trusted = true;
        }
    } catch (UnknownHostException uhe) {
        invalid = true;
        throw uhe;
    }
    return false;
}