當前位置: 首頁>>代碼示例>>Java>>正文


Java PrivilegedActionException.getMessage方法代碼示例

本文整理匯總了Java中java.security.PrivilegedActionException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java PrivilegedActionException.getMessage方法的具體用法?Java PrivilegedActionException.getMessage怎麽用?Java PrivilegedActionException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.PrivilegedActionException的用法示例。


在下文中一共展示了PrivilegedActionException.getMessage方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: castToFiles

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
private ArrayList<String> castToFiles(final List files,
                                      final ProtectionDomain userProtectionDomain) throws IOException
{
    final ArrayList<String> fileList = new ArrayList<String>();
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction() {
            public Object run() throws IOException {
                for (Object fileObject : files)
                {
                    File file = castToFile(fileObject);
                    if (file != null &&
                        (null == System.getSecurityManager() ||
                        !(isFileInWebstartedCache(file) ||
                        isForbiddenToRead(file, userProtectionDomain))))
                    {
                        fileList.add(file.getCanonicalPath());
                    }
                }
                return null;
            }
        });
    } catch (PrivilegedActionException pae) {
        throw new IOException(pae.getMessage());
    }
    return fileList;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:27,代碼來源:DataTransferer.java

示例2: castToFiles

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
private ArrayList<String> castToFiles(final List<?> files,
                                      final ProtectionDomain userProtectionDomain) throws IOException {
    try {
        return AccessController.doPrivileged((PrivilegedExceptionAction<ArrayList<String>>) () -> {
            ArrayList<String> fileList = new ArrayList<>();
            for (Object fileObject : files)
            {
                File file = castToFile(fileObject);
                if (file != null &&
                    (null == System.getSecurityManager() ||
                    !(isFileInWebstartedCache(file) ||
                    isForbiddenToRead(file, userProtectionDomain))))
                {
                    fileList.add(file.getCanonicalPath());
                }
            }
            return fileList;
        });
    } catch (PrivilegedActionException pae) {
        throw new IOException(pae.getMessage());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:DataTransferer.java

示例3: getTgt

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
private static KerberosTicket getTgt(GSSCaller caller, Krb5NameElement name,
                                             int initLifetime)
    throws GSSException {

    final String clientPrincipal;

    /*
     * Find the TGT for the realm that the client is in. If the client
     * name is not available, then use the default realm.
     */
    if (name != null) {
        clientPrincipal = (name.getKrb5PrincipalName()).getName();
    } else {
        clientPrincipal = null;
    }

    final AccessControlContext acc = AccessController.getContext();

    try {
        final GSSCaller realCaller = (caller == GSSCaller.CALLER_UNKNOWN)
                               ? GSSCaller.CALLER_INITIATE
                               : caller;
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<KerberosTicket>() {
            public KerberosTicket run() throws Exception {
                // It's OK to use null as serverPrincipal. TGT is almost
                // the first ticket for a principal and we use list.
                return Krb5Util.getTicket(
                    realCaller,
                    clientPrincipal, null, acc);
                    }});
    } catch (PrivilegedActionException e) {
        GSSException ge =
            new GSSException(GSSException.NO_CRED, -1,
                "Attempt to obtain new INITIATE credentials failed!" +
                " (" + e.getMessage() + ")");
        ge.initCause(e.getException());
        throw ge;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:41,代碼來源:Krb5InitCredential.java

示例4: removeSuspectedData

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
private String removeSuspectedData(DataFlavor flavor, final Transferable contents, final String str)
        throws IOException
{
    if (null == System.getSecurityManager()
        || !flavor.isMimeTypeEqual("text/uri-list"))
    {
        return str;
    }

    final ProtectionDomain userProtectionDomain = getUserProtectionDomain(contents);

    try {
        return AccessController.doPrivileged((PrivilegedExceptionAction<String>) () -> {

            StringBuilder allowedFiles = new StringBuilder(str.length());
            String [] uriArray = str.split("(\\s)+");

            for (String fileName : uriArray)
            {
                File file = new File(fileName);
                if (file.exists() &&
                    !(isFileInWebstartedCache(file) ||
                    isForbiddenToRead(file, userProtectionDomain)))
                {
                    if (0 != allowedFiles.length())
                    {
                        allowedFiles.append("\\r\\n");
                    }

                    allowedFiles.append(fileName);
                }
            }

            return allowedFiles.toString();
        });
    } catch (PrivilegedActionException pae) {
        throw new IOException(pae.getMessage(), pae);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:40,代碼來源:DataTransferer.java

示例5: removeSuspectedData

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
private String removeSuspectedData(DataFlavor flavor, final Transferable contents, final String str)
        throws IOException
{
    if (null == System.getSecurityManager()
        || !flavor.isMimeTypeEqual("text/uri-list"))
    {
        return str;
    }


    String ret_val = "";
    final ProtectionDomain userProtectionDomain = getUserProtectionDomain(contents);

    try {
        ret_val = (String) AccessController.doPrivileged(new PrivilegedExceptionAction() {
                public Object run() {

                    StringBuffer allowedFiles = new StringBuffer(str.length());
                    String [] uriArray = str.split("(\\s)+");

                    for (String fileName : uriArray)
                    {
                        File file = new File(fileName);
                        if (file.exists() &&
                            !(isFileInWebstartedCache(file) ||
                            isForbiddenToRead(file, userProtectionDomain)))
                        {

                            if (0 != allowedFiles.length())
                            {
                                allowedFiles.append("\\r\\n");
                            }

                            allowedFiles.append(fileName);
                        }
                    }

                    return allowedFiles.toString();
                }
            });
    } catch (PrivilegedActionException pae) {
        throw new IOException(pae.getMessage(), pae);
    }

    return ret_val;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:47,代碼來源:DataTransferer.java


注:本文中的java.security.PrivilegedActionException.getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。