java.security.PKCS12Attribute#sun.security.util.Debug源码实例Demo

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

源代码1 项目: dragonwell8_jdk   文件: DSA.java
/**
 * Return a human readable rendition of the engine.
 */
public String toString() {
    String printable = "DSA Signature";
    if (presetP != null && presetQ != null && presetG != null) {
        printable += "\n\tp: " + Debug.toHexString(presetP);
        printable += "\n\tq: " + Debug.toHexString(presetQ);
        printable += "\n\tg: " + Debug.toHexString(presetG);
    } else {
        printable += "\n\t P, Q or G not initialized.";
    }
    if (presetY != null) {
        printable += "\n\ty: " + Debug.toHexString(presetY);
    }
    if (presetY == null && presetX == null) {
        printable += "\n\tUNINIIALIZED";
    }
    return printable;
}
 
源代码2 项目: openjdk-jdk9   文件: MultiOptions.java
public static void main(String args[]) throws Exception {

        if (!Debug.isOn("access") ||
                !Debug.isOn("stack") ||
                !Debug.isOn("logincontext") ||
                !Debug.isOn("domain") ||
                !Debug.isOn("combiner") ||
                !Debug.isOn("failure") ||
                !Debug.isOn("jar") ||
                !Debug.isOn("permission=sun.dummy.DummyPermission") ||
                Debug.isOn("permission=sun.dummy.dummypermission") ||
                !Debug.isOn("permission=sun.Dummy.DummyPermission2") ||
                !Debug.isOn("permission=sun.dummy.DummyPermission3") ||
                !Debug.isOn("codebase=/dir1/DIR2/Dir3/File.java") ||
                Debug.isOn("codebase=/dir1/dir2/dir3/file.java") ||
                !Debug.isOn("codebase=www.sun.com") ||
                !Debug.isOn("codebase=file:///C:/temp/foo%20more/a.txt") ||
                !Debug.isOn("codebase=http://www.sun.com/search?q=SunMicro") ) {
            throw new Exception("sun.security.Debug failed to parse options");
        }
    }
 
源代码3 项目: jdk8u-jdk   文件: MultiOptions.java
public static void main(String args[]) throws Exception {

        if (!Debug.isOn("access") ||
                !Debug.isOn("stack") ||
                !Debug.isOn("logincontext") ||
                !Debug.isOn("domain") ||
                !Debug.isOn("combiner") ||
                !Debug.isOn("failure") ||
                !Debug.isOn("jar") ||
                !Debug.isOn("permission=sun.dummy.DummyPermission") ||
                Debug.isOn("permission=sun.dummy.dummypermission") ||
                !Debug.isOn("permission=sun.Dummy.DummyPermission2") ||
                !Debug.isOn("permission=sun.dummy.DummyPermission3") ||
                !Debug.isOn("codebase=/dir1/DIR2/Dir3/File.java") ||
                Debug.isOn("codebase=/dir1/dir2/dir3/file.java") ||
                !Debug.isOn("codebase=www.sun.com") ||
                !Debug.isOn("codebase=file:///C:/temp/foo%20more/a.txt") ||
                !Debug.isOn("codebase=http://www.sun.com/search?q=SunMicro") ) {
            throw new Exception("sun.security.Debug failed to parse options");
        }
    }
 
源代码4 项目: Bytecoder   文件: SignerInfo.java
public String toString() {
    HexDumpEncoder hexDump = new HexDumpEncoder();

    String out = "";

    out += "Signer Info for (issuer): " + issuerName + "\n";
    out += "\tversion: " + Debug.toHexString(version) + "\n";
    out += "\tcertificateSerialNumber: " +
           Debug.toHexString(certificateSerialNumber) + "\n";
    out += "\tdigestAlgorithmId: " + digestAlgorithmId + "\n";
    if (authenticatedAttributes != null) {
        out += "\tauthenticatedAttributes: " + authenticatedAttributes +
               "\n";
    }
    out += "\tdigestEncryptionAlgorithmId: " + digestEncryptionAlgorithmId +
        "\n";

    out += "\tencryptedDigest: " + "\n" +
        hexDump.encodeBuffer(encryptedDigest) + "\n";
    if (unauthenticatedAttributes != null) {
        out += "\tunauthenticatedAttributes: " +
               unauthenticatedAttributes + "\n";
    }
    return out;
}
 
源代码5 项目: TencentKona-8   文件: MultiOptions.java
public static void main(String args[]) throws Exception {

        if (!Debug.isOn("access") ||
                !Debug.isOn("stack") ||
                !Debug.isOn("logincontext") ||
                !Debug.isOn("domain") ||
                !Debug.isOn("combiner") ||
                !Debug.isOn("failure") ||
                !Debug.isOn("jar") ||
                !Debug.isOn("permission=sun.dummy.DummyPermission") ||
                Debug.isOn("permission=sun.dummy.dummypermission") ||
                !Debug.isOn("permission=sun.Dummy.DummyPermission2") ||
                !Debug.isOn("permission=sun.dummy.DummyPermission3") ||
                !Debug.isOn("codebase=/dir1/DIR2/Dir3/File.java") ||
                Debug.isOn("codebase=/dir1/dir2/dir3/file.java") ||
                !Debug.isOn("codebase=www.sun.com") ||
                !Debug.isOn("codebase=file:///C:/temp/foo%20more/a.txt") ||
                !Debug.isOn("codebase=http://www.sun.com/search?q=SunMicro") ) {
            throw new Exception("sun.security.Debug failed to parse options");
        }
    }
 
源代码6 项目: jdk8u60   文件: DSA.java
/**
 * Return a human readable rendition of the engine.
 */
public String toString() {
    String printable = "DSA Signature";
    if (presetP != null && presetQ != null && presetG != null) {
        printable += "\n\tp: " + Debug.toHexString(presetP);
        printable += "\n\tq: " + Debug.toHexString(presetQ);
        printable += "\n\tg: " + Debug.toHexString(presetG);
    } else {
        printable += "\n\t P, Q or G not initialized.";
    }
    if (presetY != null) {
        printable += "\n\ty: " + Debug.toHexString(presetY);
    }
    if (presetY == null && presetX == null) {
        printable += "\n\tUNINIIALIZED";
    }
    return printable;
}
 
源代码7 项目: julongchain   文件: CryptoUtil.java
/**
 * 读取私钥文件
 * @param skPath
 * @return
 * @throws CspException
 * @throws IOException
 */
public static byte[] readSkFile(String skPath) throws CspException, IOException {
    InputStreamReader reader = new InputStreamReader(new FileInputStream(skPath));
    PemReader pemReader = new PemReader(reader);
    PemObject pemObject = pemReader.readPemObject();
    reader.close();
    byte[] encodedData = pemObject.getContent();
    DerValue derValue = new DerValue(new ByteArrayInputStream(encodedData));
    byte[] rawPrivateKey = null;
    if (derValue.tag != 48) {
        throw new CspException("invalid key format");
    } else {
        BigInteger version = derValue.data.getBigInteger();
        if (!version.equals(BigInteger.ZERO)) {
            throw new CspException("version mismatch: (supported: " + Debug.toHexString(BigInteger.ZERO) + ", parsed: " + Debug.toHexString(version));
        } else {
            AlgorithmId algId = AlgorithmId.parse(derValue.data.getDerValue());
            rawPrivateKey = derValue.data.getOctetString();
        }
        return rawPrivateKey;
    }
}
 
源代码8 项目: jdk8u-jdk   文件: SignerInfo.java
public String toString() {
    HexDumpEncoder hexDump = new HexDumpEncoder();

    String out = "";

    out += "Signer Info for (issuer): " + issuerName + "\n";
    out += "\tversion: " + Debug.toHexString(version) + "\n";
    out += "\tcertificateSerialNumber: " +
           Debug.toHexString(certificateSerialNumber) + "\n";
    out += "\tdigestAlgorithmId: " + digestAlgorithmId + "\n";
    if (authenticatedAttributes != null) {
        out += "\tauthenticatedAttributes: " + authenticatedAttributes +
               "\n";
    }
    out += "\tdigestEncryptionAlgorithmId: " + digestEncryptionAlgorithmId +
        "\n";

    out += "\tencryptedDigest: " + "\n" +
        hexDump.encodeBuffer(encryptedDigest) + "\n";
    if (unauthenticatedAttributes != null) {
        out += "\tunauthenticatedAttributes: " +
               unauthenticatedAttributes + "\n";
    }
    return out;
}
 
源代码9 项目: openjdk-jdk8u   文件: SignerInfo.java
public String toString() {
    HexDumpEncoder hexDump = new HexDumpEncoder();

    String out = "";

    out += "Signer Info for (issuer): " + issuerName + "\n";
    out += "\tversion: " + Debug.toHexString(version) + "\n";
    out += "\tcertificateSerialNumber: " +
           Debug.toHexString(certificateSerialNumber) + "\n";
    out += "\tdigestAlgorithmId: " + digestAlgorithmId + "\n";
    if (authenticatedAttributes != null) {
        out += "\tauthenticatedAttributes: " + authenticatedAttributes +
               "\n";
    }
    out += "\tdigestEncryptionAlgorithmId: " + digestEncryptionAlgorithmId +
        "\n";

    out += "\tencryptedDigest: " + "\n" +
        hexDump.encodeBuffer(encryptedDigest) + "\n";
    if (unauthenticatedAttributes != null) {
        out += "\tunauthenticatedAttributes: " +
               unauthenticatedAttributes + "\n";
    }
    return out;
}
 
源代码10 项目: openjdk-jdk8u   文件: DSA.java
/**
 * Return a human readable rendition of the engine.
 */
public String toString() {
    String printable = "DSA Signature";
    if (presetP != null && presetQ != null && presetG != null) {
        printable += "\n\tp: " + Debug.toHexString(presetP);
        printable += "\n\tq: " + Debug.toHexString(presetQ);
        printable += "\n\tg: " + Debug.toHexString(presetG);
    } else {
        printable += "\n\t P, Q or G not initialized.";
    }
    if (presetY != null) {
        printable += "\n\ty: " + Debug.toHexString(presetY);
    }
    if (presetY == null && presetX == null) {
        printable += "\n\tUNINIIALIZED";
    }
    return printable;
}
 
源代码11 项目: jdk8u-jdk   文件: DSA.java
/**
 * Return a human readable rendition of the engine.
 */
public String toString() {
    String printable = "DSA Signature";
    if (presetP != null && presetQ != null && presetG != null) {
        printable += "\n\tp: " + Debug.toHexString(presetP);
        printable += "\n\tq: " + Debug.toHexString(presetQ);
        printable += "\n\tg: " + Debug.toHexString(presetG);
    } else {
        printable += "\n\t P, Q or G not initialized.";
    }
    if (presetY != null) {
        printable += "\n\ty: " + Debug.toHexString(presetY);
    }
    if (presetY == null && presetX == null) {
        printable += "\n\tUNINIIALIZED";
    }
    return printable;
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: SignerInfo.java
public String toString() {
    HexDumpEncoder hexDump = new HexDumpEncoder();

    String out = "";

    out += "Signer Info for (issuer): " + issuerName + "\n";
    out += "\tversion: " + Debug.toHexString(version) + "\n";
    out += "\tcertificateSerialNumber: " +
           Debug.toHexString(certificateSerialNumber) + "\n";
    out += "\tdigestAlgorithmId: " + digestAlgorithmId + "\n";
    if (authenticatedAttributes != null) {
        out += "\tauthenticatedAttributes: " + authenticatedAttributes +
               "\n";
    }
    out += "\tdigestEncryptionAlgorithmId: " + digestEncryptionAlgorithmId +
        "\n";

    out += "\tencryptedDigest: " + "\n" +
        hexDump.encodeBuffer(encryptedDigest) + "\n";
    if (unauthenticatedAttributes != null) {
        out += "\tunauthenticatedAttributes: " +
               unauthenticatedAttributes + "\n";
    }
    return out;
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: DSA.java
/**
 * Return a human readable rendition of the engine.
 */
public String toString() {
    String printable = "DSA Signature";
    if (presetP != null && presetQ != null && presetG != null) {
        printable += "\n\tp: " + Debug.toHexString(presetP);
        printable += "\n\tq: " + Debug.toHexString(presetQ);
        printable += "\n\tg: " + Debug.toHexString(presetG);
    } else {
        printable += "\n\t P, Q or G not initialized.";
    }
    if (presetY != null) {
        printable += "\n\ty: " + Debug.toHexString(presetY);
    }
    if (presetY == null && presetX == null) {
        printable += "\n\tUNINIIALIZED";
    }
    return printable;
}
 
源代码14 项目: openjdk-jdk8u-backup   文件: MultiOptions.java
public static void main(String args[]) throws Exception {

        if (!Debug.isOn("access") ||
                !Debug.isOn("stack") ||
                !Debug.isOn("logincontext") ||
                !Debug.isOn("domain") ||
                !Debug.isOn("combiner") ||
                !Debug.isOn("failure") ||
                !Debug.isOn("jar") ||
                !Debug.isOn("permission=sun.dummy.DummyPermission") ||
                Debug.isOn("permission=sun.dummy.dummypermission") ||
                !Debug.isOn("permission=sun.Dummy.DummyPermission2") ||
                !Debug.isOn("permission=sun.dummy.DummyPermission3") ||
                !Debug.isOn("codebase=/dir1/DIR2/Dir3/File.java") ||
                Debug.isOn("codebase=/dir1/dir2/dir3/file.java") ||
                !Debug.isOn("codebase=www.sun.com") ||
                !Debug.isOn("codebase=file:///C:/temp/foo%20more/a.txt") ||
                !Debug.isOn("codebase=http://www.sun.com/search?q=SunMicro") ) {
            throw new Exception("sun.security.Debug failed to parse options");
        }
    }
 
static Debug getDebug()
{
    if (debugInit)
        return debug;
    else {
        if (Policy.isSet()) {
            debug = Debug.getInstance("access");
            debugInit = true;
        }
        return debug;
    }
}
 
源代码16 项目: jdk1.8-source-analysis   文件: AccessController.java
/**
 * Determines whether the access request indicated by the
 * specified permission should be allowed or denied, based on
 * the current AccessControlContext and security policy.
 * This method quietly returns if the access request
 * is permitted, or throws an AccessControlException otherwise. The
 * getPermission method of the AccessControlException returns the
 * {@code perm} Permission object instance.
 *
 * @param perm the requested permission.
 *
 * @exception AccessControlException if the specified permission
 *            is not permitted, based on the current security policy.
 * @exception NullPointerException if the specified permission
 *            is {@code null} and is checked based on the
 *            security policy currently in effect.
 */

public static void checkPermission(Permission perm)
    throws AccessControlException
{
    //System.err.println("checkPermission "+perm);
    //Thread.currentThread().dumpStack();

    if (perm == null) {
        throw new NullPointerException("permission can't be null");
    }

    AccessControlContext stack = getStackAccessControlContext();
    // if context is null, we had privileged system code on the stack.
    if (stack == null) {
        Debug debug = AccessControlContext.getDebug();
        boolean dumpDebug = false;
        if (debug != null) {
            dumpDebug = !Debug.isOn("codebase=");
            dumpDebug &= !Debug.isOn("permission=") ||
                Debug.isOn("permission=" + perm.getClass().getCanonicalName());
        }

        if (dumpDebug && Debug.isOn("stack")) {
            Thread.dumpStack();
        }

        if (dumpDebug && Debug.isOn("domain")) {
            debug.println("domain (context is null)");
        }

        if (dumpDebug) {
            debug.println("access allowed "+perm);
        }
        return;
    }

    AccessControlContext acc = stack.optimize();
    acc.checkPermission(perm);
}
 
源代码17 项目: jdk8u-jdk   文件: Policy.java
/**
 * Returns true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set or installed. This method is called by
 * SubjectDomainCombiner to provide backwards compatibility for
 * developers that provide their own javax.security.auth.Policy
 * implementations.
 *
 * @return true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set; false otherwise
 */
static boolean isCustomPolicySet(Debug debug) {
    if (policy != null) {
        if (debug != null && isCustomPolicy) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policy.toString());
        }
        return isCustomPolicy;
    }
    // check if custom policy has been set using auth.policy.provider prop
    String policyClass = java.security.AccessController.doPrivileged
        (new java.security.PrivilegedAction<String>() {
            public String run() {
                return Security.getProperty("auth.policy.provider");
            }
    });
    if (policyClass != null && !policyClass.equals(AUTH_POLICY)) {
        if (debug != null) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policyClass);
        }
        return true;
    }
    return false;
}
 
源代码18 项目: jdk1.8-source-analysis   文件: Policy.java
/**
 * Returns true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set or installed. This method is called by
 * SubjectDomainCombiner to provide backwards compatibility for
 * developers that provide their own javax.security.auth.Policy
 * implementations.
 *
 * @return true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set; false otherwise
 */
static boolean isCustomPolicySet(Debug debug) {
    if (policy != null) {
        if (debug != null && isCustomPolicy) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policy.toString());
        }
        return isCustomPolicy;
    }
    // check if custom policy has been set using auth.policy.provider prop
    String policyClass = java.security.AccessController.doPrivileged
        (new java.security.PrivilegedAction<String>() {
            public String run() {
                return Security.getProperty("auth.policy.provider");
            }
    });
    if (policyClass != null && !policyClass.equals(AUTH_POLICY)) {
        if (debug != null) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policyClass);
        }
        return true;
    }
    return false;
}
 
源代码19 项目: dragonwell8_jdk   文件: AccessControlContext.java
static Debug getDebug()
{
    if (debugInit)
        return debug;
    else {
        if (Policy.isSet()) {
            debug = Debug.getInstance("access");
            debugInit = true;
        }
        return debug;
    }
}
 
源代码20 项目: dragonwell8_jdk   文件: AccessController.java
/**
 * Determines whether the access request indicated by the
 * specified permission should be allowed or denied, based on
 * the current AccessControlContext and security policy.
 * This method quietly returns if the access request
 * is permitted, or throws an AccessControlException otherwise. The
 * getPermission method of the AccessControlException returns the
 * {@code perm} Permission object instance.
 *
 * @param perm the requested permission.
 *
 * @exception AccessControlException if the specified permission
 *            is not permitted, based on the current security policy.
 * @exception NullPointerException if the specified permission
 *            is {@code null} and is checked based on the
 *            security policy currently in effect.
 */

public static void checkPermission(Permission perm)
    throws AccessControlException
{
    //System.err.println("checkPermission "+perm);
    //Thread.currentThread().dumpStack();

    if (perm == null) {
        throw new NullPointerException("permission can't be null");
    }

    AccessControlContext stack = getStackAccessControlContext();
    // if context is null, we had privileged system code on the stack.
    if (stack == null) {
        Debug debug = AccessControlContext.getDebug();
        boolean dumpDebug = false;
        if (debug != null) {
            dumpDebug = !Debug.isOn("codebase=");
            dumpDebug &= !Debug.isOn("permission=") ||
                Debug.isOn("permission=" + perm.getClass().getCanonicalName());
        }

        if (dumpDebug && Debug.isOn("stack")) {
            Thread.dumpStack();
        }

        if (dumpDebug && Debug.isOn("domain")) {
            debug.println("domain (context is null)");
        }

        if (dumpDebug) {
            debug.println("access allowed "+perm);
        }
        return;
    }

    AccessControlContext acc = stack.optimize();
    acc.checkPermission(perm);
}
 
源代码21 项目: dragonwell8_jdk   文件: SocketPermission.java
private boolean isUntrusted()
    throws UnknownHostException
{
    if (trusted) return false;
    if (invalid || untrusted) return true;
    try {
        if (!trustNameService && (defaultDeny ||
            sun.net.www.URLConnection.isProxiedHost(hostname))) {
            if (this.cname == null) {
                this.getCanonName();
            }
            if (!match(cname, hostname)) {
                // Last chance
                if (!authorized(hostname, addresses[0].getAddress())) {
                    untrusted = true;
                    Debug debug = getDebug();
                    if (debug != null && Debug.isOn("failure")) {
                        debug.println("socket access restriction: proxied host " + "(" + addresses[0] + ")" + " does not match " + cname + " from reverse lookup");
                    }
                    return true;
                }
            }
            trusted = true;
        }
    } catch (UnknownHostException uhe) {
        invalid = true;
        throw uhe;
    }
    return false;
}
 
源代码22 项目: openjdk-jdk9   文件: AccessControlContext.java
static Debug getDebug()
{
    if (debugInit)
        return debug;
    else {
        if (Policy.isSet()) {
            debug = Debug.getInstance("access");
            debugInit = true;
        }
        return debug;
    }
}
 
源代码23 项目: dragonwell8_jdk   文件: PKCS12KeyStore.java
private Set<KeyStore.Entry.Attribute> getAttributes(Entry entry) {

        if (entry.attributes == null) {
            entry.attributes = new HashSet<>();
        }

        // friendlyName
        entry.attributes.add(new PKCS12Attribute(
            PKCS9FriendlyName_OID.toString(), entry.alias));

        // localKeyID
        byte[] keyIdValue = entry.keyId;
        if (keyIdValue != null) {
            entry.attributes.add(new PKCS12Attribute(
                PKCS9LocalKeyId_OID.toString(), Debug.toString(keyIdValue)));
        }

        // trustedKeyUsage
        if (entry instanceof CertEntry) {
            ObjectIdentifier[] trustedKeyUsageValue =
                ((CertEntry) entry).trustedKeyUsage;
            if (trustedKeyUsageValue != null) {
                if (trustedKeyUsageValue.length == 1) { // omit brackets
                    entry.attributes.add(new PKCS12Attribute(
                        TrustedKeyUsage_OID.toString(),
                        trustedKeyUsageValue[0].toString()));
                } else { // multi-valued
                    entry.attributes.add(new PKCS12Attribute(
                        TrustedKeyUsage_OID.toString(),
                        Arrays.toString(trustedKeyUsageValue)));
                }
            }
        }

        return entry.attributes;
    }
 
源代码24 项目: TencentKona-8   文件: AccessControlContext.java
static Debug getDebug()
{
    if (debugInit)
        return debug;
    else {
        if (Policy.isSet()) {
            debug = Debug.getInstance("access");
            debugInit = true;
        }
        return debug;
    }
}
 
源代码25 项目: TencentKona-8   文件: AccessController.java
/**
 * Determines whether the access request indicated by the
 * specified permission should be allowed or denied, based on
 * the current AccessControlContext and security policy.
 * This method quietly returns if the access request
 * is permitted, or throws an AccessControlException otherwise. The
 * getPermission method of the AccessControlException returns the
 * {@code perm} Permission object instance.
 *
 * @param perm the requested permission.
 *
 * @exception AccessControlException if the specified permission
 *            is not permitted, based on the current security policy.
 * @exception NullPointerException if the specified permission
 *            is {@code null} and is checked based on the
 *            security policy currently in effect.
 */

public static void checkPermission(Permission perm)
    throws AccessControlException
{
    //System.err.println("checkPermission "+perm);
    //Thread.currentThread().dumpStack();

    if (perm == null) {
        throw new NullPointerException("permission can't be null");
    }

    AccessControlContext stack = getStackAccessControlContext();
    // if context is null, we had privileged system code on the stack.
    if (stack == null) {
        Debug debug = AccessControlContext.getDebug();
        boolean dumpDebug = false;
        if (debug != null) {
            dumpDebug = !Debug.isOn("codebase=");
            dumpDebug &= !Debug.isOn("permission=") ||
                Debug.isOn("permission=" + perm.getClass().getCanonicalName());
        }

        if (dumpDebug && Debug.isOn("stack")) {
            Thread.dumpStack();
        }

        if (dumpDebug && Debug.isOn("domain")) {
            debug.println("domain (context is null)");
        }

        if (dumpDebug) {
            debug.println("access allowed "+perm);
        }
        return;
    }

    AccessControlContext acc = stack.optimize();
    acc.checkPermission(perm);
}
 
源代码26 项目: openjdk-jdk9   文件: PKCS12KeyStore.java
private Set<KeyStore.Entry.Attribute> getAttributes(Entry entry) {

        if (entry.attributes == null) {
            entry.attributes = new HashSet<>();
        }

        // friendlyName
        entry.attributes.add(new PKCS12Attribute(
            PKCS9FriendlyName_OID.toString(), entry.alias));

        // localKeyID
        byte[] keyIdValue = entry.keyId;
        if (keyIdValue != null) {
            entry.attributes.add(new PKCS12Attribute(
                PKCS9LocalKeyId_OID.toString(), Debug.toString(keyIdValue)));
        }

        // trustedKeyUsage
        if (entry instanceof CertEntry) {
            ObjectIdentifier[] trustedKeyUsageValue =
                ((CertEntry) entry).trustedKeyUsage;
            if (trustedKeyUsageValue != null) {
                if (trustedKeyUsageValue.length == 1) { // omit brackets
                    entry.attributes.add(new PKCS12Attribute(
                        TrustedKeyUsage_OID.toString(),
                        trustedKeyUsageValue[0].toString()));
                } else { // multi-valued
                    entry.attributes.add(new PKCS12Attribute(
                        TrustedKeyUsage_OID.toString(),
                        Arrays.toString(trustedKeyUsageValue)));
                }
            }
        }

        return entry.attributes;
    }
 
源代码27 项目: TencentKona-8   文件: SocketPermission.java
private boolean isUntrusted()
    throws UnknownHostException
{
    if (trusted) return false;
    if (invalid || untrusted) return true;
    try {
        if (!trustNameService && (defaultDeny ||
            sun.net.www.URLConnection.isProxiedHost(hostname))) {
            if (this.cname == null) {
                this.getCanonName();
            }
            if (!match(cname, hostname)) {
                // Last chance
                if (!authorized(hostname, addresses[0].getAddress())) {
                    untrusted = true;
                    Debug debug = getDebug();
                    if (debug != null && Debug.isOn("failure")) {
                        debug.println("socket access restriction: proxied host " + "(" + addresses[0] + ")" + " does not match " + cname + " from reverse lookup");
                    }
                    return true;
                }
            }
            trusted = true;
        }
    } catch (UnknownHostException uhe) {
        invalid = true;
        throw uhe;
    }
    return false;
}
 
源代码28 项目: TencentKona-8   文件: PKCS12KeyStore.java
private Set<KeyStore.Entry.Attribute> getAttributes(Entry entry) {

        if (entry.attributes == null) {
            entry.attributes = new HashSet<>();
        }

        // friendlyName
        entry.attributes.add(new PKCS12Attribute(
            PKCS9FriendlyName_OID.toString(), entry.alias));

        // localKeyID
        byte[] keyIdValue = entry.keyId;
        if (keyIdValue != null) {
            entry.attributes.add(new PKCS12Attribute(
                PKCS9LocalKeyId_OID.toString(), Debug.toString(keyIdValue)));
        }

        // trustedKeyUsage
        if (entry instanceof CertEntry) {
            ObjectIdentifier[] trustedKeyUsageValue =
                ((CertEntry) entry).trustedKeyUsage;
            if (trustedKeyUsageValue != null) {
                if (trustedKeyUsageValue.length == 1) { // omit brackets
                    entry.attributes.add(new PKCS12Attribute(
                        TrustedKeyUsage_OID.toString(),
                        trustedKeyUsageValue[0].toString()));
                } else { // multi-valued
                    entry.attributes.add(new PKCS12Attribute(
                        TrustedKeyUsage_OID.toString(),
                        Arrays.toString(trustedKeyUsageValue)));
                }
            }
        }

        return entry.attributes;
    }
 
源代码29 项目: TencentKona-8   文件: Policy.java
/**
 * Returns true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set or installed. This method is called by
 * SubjectDomainCombiner to provide backwards compatibility for
 * developers that provide their own javax.security.auth.Policy
 * implementations.
 *
 * @return true if a custom (not AUTH_POLICY) system-wide policy object
 * has been set; false otherwise
 */
static boolean isCustomPolicySet(Debug debug) {
    if (policy != null) {
        if (debug != null && isCustomPolicy) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policy.toString());
        }
        return isCustomPolicy;
    }
    // check if custom policy has been set using auth.policy.provider prop
    String policyClass = java.security.AccessController.doPrivileged
        (new java.security.PrivilegedAction<String>() {
            public String run() {
                return Security.getProperty("auth.policy.provider");
            }
    });
    if (policyClass != null && !policyClass.equals(AUTH_POLICY)) {
        if (debug != null) {
            debug.println("Providing backwards compatibility for " +
                          "javax.security.auth.policy implementation: " +
                          policyClass);
        }
        return true;
    }
    return false;
}
 
源代码30 项目: jdk8u60   文件: AccessControlContext.java
static Debug getDebug()
{
    if (debugInit)
        return debug;
    else {
        if (Policy.isSet()) {
            debug = Debug.getInstance("access");
            debugInit = true;
        }
        return debug;
    }
}