Java Code Examples for java.security.PrivilegedActionException#toString()

The following examples show how to use java.security.PrivilegedActionException#toString() . 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: NbfsUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Gets URL with nbfs protocol for passes fo
 * @param fo
 * @return url with nbfs protocol
 */
static URL getURL(final FileObject fo) {
    String fsPart;
    try {
        fsPart = encodeFsPart(fo);
    } catch (FileStateInvalidException x) {
        fsPart = "invalid";
    }
    final String foPart = encodeFoPart(fo);

    final String host = "nbhost"; //NOI18N
    final String file = combine(fsPart, foPart);

    // #13038: the URL constructor accepting a handler is a security-sensitive
    // operation. Sometimes a user class loaded internally (customized bean...),
    // which has no privileges, needs to make and use an nbfs: URL, since this
    // may be the URL used by e.g. ClassLoader.getResource for resources.
    try {
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<URL>() {
                public URL run() throws Exception {
                    // #30397: the fsPart name cannot be null
                    return new URL(FileURL.PROTOCOL, host, -1, file, new FileURL.Handler());
                }
            }
        );
    } catch (PrivilegedActionException pae) {
        // MalformedURLException is declared but should not happen.
        IllegalStateException ise = new IllegalStateException(pae.toString());
        ExternalUtil.annotate(ise, pae);
        throw ise;
    }
}
 
Example 2
Source File: GssapiMechanism.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] getChallengeResponse(final byte[] challenge) throws SaslException {
    try {
        return Subject.doAs(subject, new PrivilegedExceptionAction<byte[]>() {
            @Override
            public byte[] run() throws Exception {
                return saslClient.evaluateChallenge(challenge);
            }
        });
    } catch (PrivilegedActionException e) {
        throw new SaslException(e.toString(), e);
    }
}
 
Example 3
Source File: RuleBasedBreakIterator.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 4
Source File: RuleBasedBreakIterator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 5
Source File: RuleBasedBreakIterator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 6
Source File: RuleBasedBreakIterator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 7
Source File: RuleBasedBreakIterator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 8
Source File: RuleBasedBreakIterator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 9
Source File: RuleBasedBreakIterator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 10
Source File: RuleBasedBreakIterator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 11
Source File: RuleBasedBreakIterator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 12
Source File: RuleBasedBreakIterator.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 13
Source File: RuleBasedBreakIterator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}
 
Example 14
Source File: RuleBasedBreakIterator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected byte[] readFile(final String datafile)
    throws IOException, MissingResourceException {

    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(
            new PrivilegedExceptionAction<BufferedInputStream>() {
                @Override
                public BufferedInputStream run() throws Exception {
                    return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
                }
            }
        );
    }
    catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }

    int offset = 0;

    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length",
                                           datafile, "");
    }

    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number",
                                               datafile, "");
        }
    }

    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
                                           datafile, "");
    }

    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length",
                                           datafile, "");
    }

    is.close();

    return buf;
}