java.security.PrivilegedActionException#toString ( )源码实例Demo

下面列出了java.security.PrivilegedActionException#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: NbfsUtil.java
/**
 * 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;
    }
}
 
源代码2 项目: qpid-jms   文件: GssapiMechanism.java
@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);
    }
}
 
源代码3 项目: dragonwell8_jdk   文件: RuleBasedBreakIterator.java
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;
}
 
源代码4 项目: TencentKona-8   文件: RuleBasedBreakIterator.java
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;
}
 
源代码5 项目: jdk8u60   文件: RuleBasedBreakIterator.java
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;
}
 
源代码6 项目: openjdk-jdk8u   文件: RuleBasedBreakIterator.java
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;
}
 
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;
}
 
源代码8 项目: jdk8u-jdk   文件: RuleBasedBreakIterator.java
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;
}
 
源代码9 项目: hottub   文件: RuleBasedBreakIterator.java
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;
}
 
源代码10 项目: openjdk-8-source   文件: RuleBasedBreakIterator.java
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;
}
 
源代码11 项目: openjdk-8   文件: RuleBasedBreakIterator.java
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;
}
 
源代码12 项目: jdk8u_jdk   文件: RuleBasedBreakIterator.java
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;
}
 
源代码13 项目: jdk8u-jdk   文件: RuleBasedBreakIterator.java
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;
}
 
源代码14 项目: jdk8u-dev-jdk   文件: RuleBasedBreakIterator.java
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;
}