Java Code Examples for java.security.PrivilegedActionException.getMessage()

The following are Jave code examples for showing how to use getMessage() of the java.security.PrivilegedActionException class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: OpenJSharp   File: DataTransferer.java   Source Code and License Vote up 6 votes
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;
}
 
Example 2
Project: jdk8u-jdk   File: DataTransferer.java   Source Code and License Vote up 6 votes
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;
}
 
Example 3
Project: openjdk-jdk10   File: DataTransferer.java   Source Code and License Vote up 6 votes
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());
    }
}
 
Example 4
Project: OpenJSharp   File: Krb5InitCredential.java   Source Code and License Vote up 5 votes
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;
    }
}
 
Example 5
Project: jdk8u-jdk   File: Krb5InitCredential.java   Source Code and License Vote up 5 votes
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;
    }
}
 
Example 6
Project: openjdk-jdk10   File: Krb5InitCredential.java   Source Code and License Vote up 5 votes
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;
    }
}
 
Example 7
Project: openjdk-jdk10   File: DataTransferer.java   Source Code and License Vote up 5 votes
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);
    }
}
 
Example 8
Project: OpenJSharp   File: DataTransferer.java   Source Code and License Vote up 4 votes
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;
}
 
Example 9
Project: jdk8u-jdk   File: DataTransferer.java   Source Code and License Vote up 4 votes
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;
}