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


Java AccessController.doPrivileged方法代码示例

本文整理汇总了Java中java.security.AccessController.doPrivileged方法的典型用法代码示例。如果您正苦于以下问题:Java AccessController.doPrivileged方法的具体用法?Java AccessController.doPrivileged怎么用?Java AccessController.doPrivileged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.AccessController的用法示例。


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

示例1: doPrivilegedIOException

import java.security.AccessController; //导入方法依赖的package包/类
public static <T> T doPrivilegedIOException(PrivilegedExceptionAction<T> operation) throws IOException {
    SpecialPermission.check();
    try {
        return AccessController.doPrivileged(operation);
    } catch (PrivilegedActionException e) {
        throw (IOException) e.getCause();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:SocketAccess.java

示例2: checkPackageAccess

import java.security.AccessController; //导入方法依赖的package包/类
private void checkPackageAccess(Class<?> cls, ProtectionDomain pd) {
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        if (ReflectUtil.isNonPublicProxyClass(cls)) {
            for (Class<?> intf: cls.getInterfaces()) {
                checkPackageAccess(intf, pd);
            }
            return;
        }

        final String name = cls.getName();
        final int i = name.lastIndexOf('.');
        if (i != -1) {
            AccessController.doPrivileged(new PrivilegedAction<Void>() {
                public Void run() {
                    sm.checkPackageAccess(name.substring(0, i));
                    return null;
                }
            }, new AccessControlContext(new ProtectionDomain[] {pd}));
        }
    }
    domains.add(pd);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:ClassLoader.java

示例3: setProperty

import java.security.AccessController; //导入方法依赖的package包/类
/**
 * Set property to given value.
 * <p>
 * Specifying a null value will cause the property to be cleared
 *
 * @param name
 * @param value
 * @return previous value
 */
private static String setProperty(final String name, final String value) {

    final PrivilegedAction<String> action;
    if (value != null)
        action = new PrivilegedAction<String>() {

            @Override
            public String run() {

                return System.setProperty(name, value);
            }
        };
    else
        action = new PrivilegedAction<String>() {

            @Override
            public String run() {

                return System.clearProperty(name);
            }
        };
    return AccessController.doPrivileged(action);
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:33,代码来源:HttpRequest.java

示例4: XRCompositeManager

import java.security.AccessController; //导入方法依赖的package包/类
private XRCompositeManager(XRSurfaceData surface) {
    con = new XRBackendNative();

    String gradProp =
        AccessController.doPrivileged(new PrivilegedAction<String>() {
            public String run() {
                return System.getProperty("sun.java2d.xrgradcache");
            }
        });

    enableGradCache = gradProp == null ||
                      !(gradProp.equalsIgnoreCase("false") ||
                      gradProp.equalsIgnoreCase("f"));

    XRPaints.register(this);

    initResources(surface);

    maskBuffer = new MaskTileManager(this, surface.getXid());
    textRenderer = new XRTextRenderer(this);
    maskImage = new XRMaskImage(this, surface.getXid());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:XRCompositeManager.java

示例5: postProcessBeforeInitialization

import java.security.AccessController; //导入方法依赖的package包/类
@Override
public Object postProcessBeforeInitialization(final Object bean, String beanName) throws BeansException {
	AccessControlContext acc = null;
	if (System.getSecurityManager() != null && (bean instanceof DisruptorEventPublisherAware )) {
		acc = getAccessControlContext();
	}
	if (acc != null) {
		AccessController.doPrivileged(new PrivilegedAction<Object>() {
			@Override
			public Object run() {
				invokeAwareInterfaces(bean);
				return null;
			}
		}, acc);
	}
	else {
		invokeAwareInterfaces(bean);
	}

	return bean;
}
 
开发者ID:vindell,项目名称:spring-boot-starter-disruptor,代码行数:22,代码来源:DisruptorEventAwareProcessor.java

示例6: getOutputStream

import java.security.AccessController; //导入方法依赖的package包/类
public OutputStream getOutputStream() throws IOException {
    if (!sc.isOpen())
        throw new SocketException("Socket is closed");
    if (!sc.isConnected())
        throw new SocketException("Socket is not connected");
    if (!sc.isOutputOpen())
        throw new SocketException("Socket output is shutdown");
    OutputStream os = null;
    try {
        os = AccessController.doPrivileged(
            new PrivilegedExceptionAction<OutputStream>() {
                public OutputStream run() throws IOException {
                    return Channels.newOutputStream(sc);
                }
            });
    } catch (java.security.PrivilegedActionException e) {
        throw (IOException)e.getException();
    }
    return os;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:SocketAdaptor.java

示例7: processDocument

import java.security.AccessController; //导入方法依赖的package包/类
@Override
public void processDocument(String inputText, IngestDocument ingestDocument) throws Exception {
    // call /categories endpoint and set the top result in the field
    DocumentRequest<CategoriesOptions> request = new DocumentRequest.Builder<CategoriesOptions>().content(inputText).build();
    CategoriesResponse response;
    try {
        // RosApi client binding's Jackson needs elevated privilege
        response = AccessController.doPrivileged((PrivilegedAction<CategoriesResponse>) () ->
                rosAPI.getHttpRosetteAPI().perform(HttpRosetteAPI.CATEGORIES_SERVICE_PATH, request, CategoriesResponse.class)
        );
    } catch (HttpRosetteAPIException ex) {
        LOGGER.error(ex.getErrorResponse().getMessage());
        throw new ElasticsearchException(ex.getErrorResponse().getMessage(), ex);
    }

    if (response.getCategories() != null
            && !response.getCategories().isEmpty()
            && response.getCategories().get(0) != null
            && !Strings.isNullOrEmpty(response.getCategories().get(0).getLabel())) {
        ingestDocument.setFieldValue(targetField, response.getCategories().get(0).getLabel());
    } else {
        throw new ElasticsearchException(TYPE + " ingest processor failed to categorize document.");
    }
}
 
开发者ID:rosette-api,项目名称:rosette-elasticsearch-plugin,代码行数:25,代码来源:CategoriesProcessor.java

示例8: getCharacterSet

import java.security.AccessController; //导入方法依赖的package包/类
/** Looks up a named character set. A character set is a 256-entry
 *  array of characters, mapping unsigned byte values to their Unicode
 *  equivalents. The character set is loaded if necessary.
 *
 *  @return the character set
 */
public static Object
getCharacterSet(final String name)
    throws IOException
{
    char[] set = characterSets.get(name);
    if (set == null) {
        InputStream charsetStream = AccessController.doPrivileged(
                new PrivilegedAction<InputStream>() {
                    public InputStream run() {
                        return RTFReader.class.getResourceAsStream("charsets/" + name + ".txt");
                    }
                });
        set = readCharset(charsetStream);
        defineCharacterSet(name, set);
    }
    return set;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:RTFReader.java

示例9: getDecimalFormatSymbolsProvider

import java.security.AccessController; //导入方法依赖的package包/类
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    if (decimalFormatSymbolsProvider == null) {
        DecimalFormatSymbolsProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<DecimalFormatSymbolsProvider>) () ->
                new DecimalFormatSymbolsProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("FormatData")));

        synchronized (this) {
            if (decimalFormatSymbolsProvider == null) {
                decimalFormatSymbolsProvider = provider;
            }
        }
    }
    return decimalFormatSymbolsProvider;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:JRELocaleProviderAdapter.java

示例10: getSerialVersion

import java.security.AccessController; //导入方法依赖的package包/类
private static Long getSerialVersion(final long csuid, final Class cl)
{
    return (Long) AccessController.doPrivileged(new PrivilegedAction() {
      public Object run() {
        long suid;
        try {
            final Field f = cl.getDeclaredField("serialVersionUID");
            int mods = f.getModifiers();
            if (Modifier.isStatic(mods) &&
                Modifier.isFinal(mods) && Modifier.isPrivate(mods)) {
                suid = csuid;
             } else {
                suid = _computeSerialVersionUID(cl);
             }
          } catch (NoSuchFieldException ex) {
              suid = _computeSerialVersionUID(cl);
          //} catch (IllegalAccessException ex) {
          //     suid = _computeSerialVersionUID(cl);
          }
          return new Long(suid);
       }
    });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:ObjectStreamClassUtil_1_3.java

示例11: unbind

import java.security.AccessController; //导入方法依赖的package包/类
private void unbind() {
	if (clBindRequired) {
		if (Globals.IS_SECURITY_ENABLED) {
			PrivilegedAction<Void> pa = new PrivilegedSetTccl(MY_CLASSLOADER);
			AccessController.doPrivileged(pa);
		} else {
			Thread.currentThread().setContextClassLoader(MY_CLASSLOADER);
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:11,代码来源:PersistentValve.java

示例12: checkFPMethodOverridden

import java.security.AccessController; //导入方法依赖的package包/类
private static boolean checkFPMethodOverridden(final Class<?> className,
                                               final String methodName,
                                               final FPMethodArgs methodArgs) {

    return AccessController
            .doPrivileged(new PrivilegedAction<Boolean>() {
                @Override
                public Boolean run() {
                    return isFPMethodOverridden(methodName, className,
                                                methodArgs.getMethodArguments(false),
                                                methodArgs.getMethodArguments(true));
                }
            });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:PlainView.java

示例13: newThread

import java.security.AccessController; //导入方法依赖的package包/类
@Override
public Thread newThread(Runnable r) {
    ExecutorService owner = getExecutor();
    Thread thread = AccessController.doPrivileged(new PrivilegedAction<Thread>() {
        @Override
        public Thread run() {
            Thread t = InnocuousThread.newThread(new BootstrapMessageLoggerTask(owner, r));
            t.setName("BootstrapMessageLoggerTask-"+t.getName());
            return t;
        }
    }, null, new RuntimePermission("enableContextClassLoaderOverride"));
    thread.setDaemon(true);
    return thread;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:BootstrapLogger.java

示例14: Spi

import java.security.AccessController; //导入方法依赖的package包/类
public Spi(final Configuration.Parameters params) throws IOException {

            // call in a doPrivileged
            //
            // we have already passed the Configuration.getInstance
            // security check.  also this class is not freely accessible
            // (it is in the "sun" package).

            try {
                AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        if (params == null) {
                            init();
                        } else {
                            if (!(params instanceof URIParameter)) {
                                throw new IllegalArgumentException
                                        ("Unrecognized parameter: " + params);
                            }
                            URIParameter uriParam = (URIParameter)params;
                            url = uriParam.getURI().toURL();
                            init();
                        }
                        return null;
                    }
                });
            } catch (PrivilegedActionException pae) {
                throw (IOException)pae.getException();
            }

            // if init() throws some other RuntimeException,
            // let it percolate up naturally.
        }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:ConfigFile.java

示例15: setDateHeader

import java.security.AccessController; //导入方法依赖的package包/类
@Override
public void setDateHeader(String name, long date) {

    if (isCommitted()) {
        return;
    }

    if(Globals.IS_SECURITY_ENABLED) {
        AccessController.doPrivileged(new DateHeaderPrivilegedAction
                                         (name, date, false));
    } else {
        response.setDateHeader(name, date);
    }

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:16,代码来源:ResponseFacade.java


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