当前位置: 首页>>代码示例>>Java>>正文


Java SocketPermission类代码示例

本文整理汇总了Java中java.net.SocketPermission的典型用法代码示例。如果您正苦于以下问题:Java SocketPermission类的具体用法?Java SocketPermission怎么用?Java SocketPermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SocketPermission类属于java.net包,在下文中一共展示了SocketPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: plainConnect

import java.net.SocketPermission; //导入依赖的package包/类
protected void plainConnect()  throws IOException {
    synchronized (this) {
        if (connected) {
            return;
        }
    }
    SocketPermission p = URLtoSocketPermission(this.url);
    if (p != null) {
        try {
            AccessController.doPrivilegedWithCombiner(
                new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        plainConnect0();
                        return null;
                    }
                }, null, p
            );
        } catch (PrivilegedActionException e) {
                throw (IOException) e.getException();
        }
    } else {
        // run without additional permission
        plainConnect0();
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:26,代码来源:HttpURLConnection.java

示例2: execute

import java.net.SocketPermission; //导入依赖的package包/类
/**
 * Executes the provided operation against this store
 */
// we can do FS ops with only two elevated permissions:
// 1) hadoop dynamic proxy is messy with access rules
// 2) allow hadoop to add credentials to our Subject
<V> V execute(Operation<V> operation) throws IOException {
    SpecialPermission.check();
    if (closed) {
        throw new AlreadyClosedException("HdfsBlobStore is closed: " + this);
    }
    try {
        return AccessController.doPrivileged((PrivilegedExceptionAction<V>)
                () -> operation.run(fileContext), null, new ReflectPermission("suppressAccessChecks"),
                 new AuthPermission("modifyPrivateCredentials"), new SocketPermission("*", "connect"));
    } catch (PrivilegedActionException pae) {
        throw (IOException) pae.getException();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:HdfsBlobStore.java

示例3: getKnownInstance

import java.net.SocketPermission; //导入依赖的package包/类
/**
 * Creates one of the well-known permissions directly instead of
 * via reflection. Keep list short to not penalize non-JDK-defined
 * permissions.
 */
private static final Permission getKnownInstance(Class<?> claz,
    String name, String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else {
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:PolicyFile.java

示例4: plainConnect

import java.net.SocketPermission; //导入依赖的package包/类
protected void plainConnect()  throws IOException {
    synchronized (this) {
        if (connected) {
            return;
        }
    }
    SocketPermission p = URLtoSocketPermission(this.url);
    if (p != null) {
        try {
            AccessController.doPrivileged(
                new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        plainConnect0();
                        return null;
                    }
                }, null, p
            );
        } catch (PrivilegedActionException e) {
                throw (IOException) e.getException();
        }
    } else {
        // run without additional permission
        plainConnect0();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:HttpURLConnection.java

示例5: getOutputStream

import java.net.SocketPermission; //导入依赖的package包/类
@Override
public synchronized OutputStream getOutputStream() throws IOException {
    connecting = true;
    SocketPermission p = URLtoSocketPermission(this.url);

    if (p != null) {
        try {
            return AccessController.doPrivileged(
                new PrivilegedExceptionAction<OutputStream>() {
                    public OutputStream run() throws IOException {
                        return getOutputStream0();
                    }
                }, null, p
            );
        } catch (PrivilegedActionException e) {
            throw (IOException) e.getException();
        }
    } else {
        return getOutputStream0();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:HttpURLConnection.java

示例6: getInputStream

import java.net.SocketPermission; //导入依赖的package包/类
@Override
public synchronized InputStream getInputStream() throws IOException {
    connecting = true;
    SocketPermission p = URLtoSocketPermission(this.url);

    if (p != null) {
        try {
            return AccessController.doPrivileged(
                new PrivilegedExceptionAction<InputStream>() {
                    public InputStream run() throws IOException {
                        return getInputStream0();
                    }
                }, null, p
            );
        } catch (PrivilegedActionException e) {
            throw (IOException) e.getException();
        }
    } else {
        return getInputStream0();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:HttpURLConnection.java

示例7: getApplet

import java.net.SocketPermission; //导入依赖的package包/类
/**
 * Get an applet by name.
 */
@Override
public Applet getApplet(String name) {
    AppletSecurity security = (AppletSecurity)System.getSecurityManager();
    name = name.toLowerCase();
    SocketPermission panelSp =
        new SocketPermission(panel.getCodeBase().getHost(), "connect");
    for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) {
        AppletPanel p = (AppletPanel)e.nextElement();
        String param = p.getParameter("name");
        if (param != null) {
            param = param.toLowerCase();
        }
        if (name.equals(param) &&
            p.getDocumentBase().equals(panel.getDocumentBase())) {

            SocketPermission sp =
                new SocketPermission(p.getCodeBase().getHost(), "connect");

            if (panelSp.implies(sp)) {
                return p.applet;
            }
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:AppletViewer.java

示例8: getApplets

import java.net.SocketPermission; //导入依赖的package包/类
/**
 * Return an enumeration of all the accessible
 * applets on this page.
 */
@Override
public Enumeration getApplets() {
    AppletSecurity security = (AppletSecurity)System.getSecurityManager();
    Vector v = new Vector();
    SocketPermission panelSp =
        new SocketPermission(panel.getCodeBase().getHost(), "connect");

    for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) {
        AppletPanel p = (AppletPanel)e.nextElement();
        if (p.getDocumentBase().equals(panel.getDocumentBase())) {

            SocketPermission sp =
                new SocketPermission(p.getCodeBase().getHost(), "connect");
            if (panelSp.implies(sp)) {
                v.addElement(p.applet);
            }
        }
    }
    return v.elements();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:AppletViewer.java

示例9: getPermission

import java.net.SocketPermission; //导入依赖的package包/类
public final Permission getPermission() throws IOException {
    int hostPort;
    URL url = getURL();
    String hostName = url.getHost();
    if (url.getPort() != -1) {
        hostPort = url.getPort();
    } else {
        hostPort = HttpUrl.defaultPort(url.getProtocol());
    }
    if (usingProxy()) {
        InetSocketAddress proxyAddress = (InetSocketAddress) this.client.getProxy().address();
        hostName = proxyAddress.getHostName();
        hostPort = proxyAddress.getPort();
    }
    return new SocketPermission(hostName + ":" + hostPort, "connect, resolve");
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:HttpURLConnectionImpl.java

示例10: getOutputStream

import java.net.SocketPermission; //导入依赖的package包/类
@Override
public synchronized OutputStream getOutputStream() throws IOException {
    connecting = true;
    SocketPermission p = URLtoSocketPermission(this.url);

    if (p != null) {
        try {
            return AccessController.doPrivilegedWithCombiner(
                new PrivilegedExceptionAction<OutputStream>() {
                    public OutputStream run() throws IOException {
                        return getOutputStream0();
                    }
                }, null, p
            );
        } catch (PrivilegedActionException e) {
            throw (IOException) e.getException();
        }
    } else {
        return getOutputStream0();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:HttpURLConnection.java

示例11: getInputStream

import java.net.SocketPermission; //导入依赖的package包/类
@Override
public synchronized InputStream getInputStream() throws IOException {
    connecting = true;
    SocketPermission p = URLtoSocketPermission(this.url);

    if (p != null) {
        try {
            return AccessController.doPrivilegedWithCombiner(
                new PrivilegedExceptionAction<InputStream>() {
                    public InputStream run() throws IOException {
                        return getInputStream0();
                    }
                }, null, p
            );
        } catch (PrivilegedActionException e) {
            throw (IOException) e.getException();
        }
    } else {
        return getInputStream0();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:HttpURLConnection.java

示例12: trySockPC

import java.net.SocketPermission; //导入依赖的package包/类
static void trySockPC() throws Exception {
    try {
        SocketPermission p0= new SocketPermission("example.com","connect");
        PermissionCollection pc = p0.newPermissionCollection();
        pc.setReadOnly();   // this should lock out future adds
        //
        SocketPermission p1= new SocketPermission("example.net","connect");
        pc.add(p1);
        throw new
            Exception("Failed...SocketPermission added to readonly SocketPermissionCollection.");

    } catch (SecurityException se) {
        System.out.println("SocketPermissionCollection passed");
    }

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:AddToReadOnlyPermissionCollection.java

示例13: getKnownPermission

import java.net.SocketPermission; //导入依赖的package包/类
/**
 * Creates one of the well-known permissions in the java.base module
 * directly instead of via reflection. Keep list short to not penalize
 * permissions from other modules.
 */
private static Permission getKnownPermission(Class<?> claz, String name,
                                             String actions) {
    if (claz.equals(FilePermission.class)) {
        return new FilePermission(name, actions);
    } else if (claz.equals(SocketPermission.class)) {
        return new SocketPermission(name, actions);
    } else if (claz.equals(RuntimePermission.class)) {
        return new RuntimePermission(name, actions);
    } else if (claz.equals(PropertyPermission.class)) {
        return new PropertyPermission(name, actions);
    } else if (claz.equals(NetPermission.class)) {
        return new NetPermission(name, actions);
    } else if (claz.equals(AllPermission.class)) {
        return SecurityConstants.ALL_PERMISSION;
    } else if (claz.equals(SecurityPermission.class)) {
        return new SecurityPermission(name, actions);
    } else {
        return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:PolicyFile.java

示例14: plainConnect

import java.net.SocketPermission; //导入依赖的package包/类
protected void plainConnect()  throws IOException {
    synchronized (this) {
        if (connected) {
            return;
        }
    }
    SocketPermission p = URLtoSocketPermission(this.url);
    if (p != null) {
        try {
            AccessController.doPrivilegedWithCombiner(
                new PrivilegedExceptionAction<>() {
                    public Void run() throws IOException {
                        plainConnect0();
                        return null;
                    }
                }, null, p
            );
        } catch (PrivilegedActionException e) {
                throw (IOException) e.getException();
        }
    } else {
        // run without additional permission
        plainConnect0();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:HttpURLConnection.java

示例15: getOutputStream

import java.net.SocketPermission; //导入依赖的package包/类
@Override
public synchronized OutputStream getOutputStream() throws IOException {
    connecting = true;
    SocketPermission p = URLtoSocketPermission(this.url);

    if (p != null) {
        try {
            return AccessController.doPrivilegedWithCombiner(
                new PrivilegedExceptionAction<>() {
                    public OutputStream run() throws IOException {
                        return getOutputStream0();
                    }
                }, null, p
            );
        } catch (PrivilegedActionException e) {
            throw (IOException) e.getException();
        }
    } else {
        return getOutputStream0();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:HttpURLConnection.java


注:本文中的java.net.SocketPermission类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。