sun.security.util.SecurityProperties Java Examples

The following examples show how to use sun.security.util.SecurityProperties. 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: Manifest.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
static String getErrorPosition(String filename, final int lineNumber) {
    if (filename == null ||
            !SecurityProperties.INCLUDE_JAR_NAME_IN_EXCEPTIONS) {
        return "line " + lineNumber;
    }
    return "manifest of " + filename + ":" + lineNumber;
}
 
Example #2
Source File: FileCredentialsCache.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public sun.security.krb5.Credentials getInitialCreds() {

        Credentials defaultCreds = getDefaultCreds();
        if (defaultCreds == null) {
            return null;
        }
        sun.security.krb5.Credentials tgt = defaultCreds.setKrbCreds();

        CredentialsCache.ConfigEntry entry = getConfigEntry("proxy_impersonator");
        if (entry == null) {
            if (DEBUG) {
                System.out.println("get normal credential");
            }
            return tgt;
        }

        boolean force;
        String prop = SecurityProperties.privilegedGetOverridable(
                "jdk.security.krb5.default.initiate.credential");
        if (prop == null) {
            prop = "always-impersonate";
        }
        switch (prop) {
            case "no-impersonate": // never try impersonation
                if (DEBUG) {
                    System.out.println("get normal credential");
                }
                return tgt;
            case "try-impersonate":
                force = false;
                break;
            case "always-impersonate":
                force = true;
                break;
            default:
                throw new RuntimeException(
                        "Invalid jdk.security.krb5.default.initiate.credential");
        }

        try {
            PrincipalName service = new PrincipalName(
                    new String(entry.getData(), StandardCharsets.UTF_8));
            if (!tgt.getClient().equals(service)) {
                if (DEBUG) {
                    System.out.println("proxy_impersonator does not match service name");
                }
                return force ? null : tgt;
            }
            PrincipalName client = getPrimaryPrincipal();
            Credentials proxy = null;
            for (Credentials c : getCredsList()) {
                if (c.getClientPrincipal().equals(client)
                        && c.getServicePrincipal().equals(service)) {
                    proxy = c;
                    break;
                }
            }
            if (proxy == null) {
                if (DEBUG) {
                    System.out.println("Cannot find evidence ticket in ccache");
                }
                return force ? null : tgt;
            }
            if (DEBUG) {
                System.out.println("Get proxied credential");
            }
            return tgt.setProxy(proxy.setKrbCreds());
        } catch (KrbException e) {
            if (DEBUG) {
                System.out.println("Impersonation with ccache failed");
            }
            return force ? null : tgt;
        }
    }
 
Example #3
Source File: FileCredentialsCache.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public sun.security.krb5.Credentials getInitialCreds() {

        Credentials defaultCreds = getDefaultCreds();
        if (defaultCreds == null) {
            return null;
        }
        sun.security.krb5.Credentials tgt = defaultCreds.setKrbCreds();

        CredentialsCache.ConfigEntry entry = getConfigEntry("proxy_impersonator");
        if (entry == null) {
            if (DEBUG) {
                System.out.println("get normal credential");
            }
            return tgt;
        }

        boolean force;
        String prop = SecurityProperties.privilegedGetOverridable(
                "jdk.security.krb5.default.initiate.credential");
        if (prop == null) {
            prop = "always-impersonate";
        }
        switch (prop) {
            case "no-impersonate": // never try impersonation
                if (DEBUG) {
                    System.out.println("get normal credential");
                }
                return tgt;
            case "try-impersonate":
                force = false;
                break;
            case "always-impersonate":
                force = true;
                break;
            default:
                throw new RuntimeException(
                        "Invalid jdk.security.krb5.default.initiate.credential");
        }

        try {
            PrincipalName service = new PrincipalName(
                    new String(entry.getData(), StandardCharsets.UTF_8));
            if (!tgt.getClient().equals(service)) {
                if (DEBUG) {
                    System.out.println("proxy_impersonator does not match service name");
                }
                return force ? null : tgt;
            }
            PrincipalName client = getPrimaryPrincipal();
            Credentials proxy = null;
            for (Credentials c : getCredsList()) {
                if (c.getClientPrincipal().equals(client)
                        && c.getServicePrincipal().equals(service)) {
                    proxy = c;
                    break;
                }
            }
            if (proxy == null) {
                if (DEBUG) {
                    System.out.println("Cannot find evidence ticket in ccache");
                }
                return force ? null : tgt;
            }
            if (DEBUG) {
                System.out.println("Get proxied credential");
            }
            return tgt.setProxy(proxy.setKrbCreds());
        } catch (KrbException e) {
            if (DEBUG) {
                System.out.println("Impersonation with ccache failed");
            }
            return force ? null : tgt;
        }
    }
 
Example #4
Source File: FileCredentialsCache.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public sun.security.krb5.Credentials getInitialCreds() {

        Credentials defaultCreds = getDefaultCreds();
        if (defaultCreds == null) {
            return null;
        }
        sun.security.krb5.Credentials tgt = defaultCreds.setKrbCreds();

        CredentialsCache.ConfigEntry entry = getConfigEntry("proxy_impersonator");
        if (entry == null) {
            if (DEBUG) {
                System.out.println("get normal credential");
            }
            return tgt;
        }

        boolean force;
        String prop = SecurityProperties.privilegedGetOverridable(
                "jdk.security.krb5.default.initiate.credential");
        if (prop == null) {
            prop = "always-impersonate";
        }
        switch (prop) {
            case "no-impersonate": // never try impersonation
                if (DEBUG) {
                    System.out.println("get normal credential");
                }
                return tgt;
            case "try-impersonate":
                force = false;
                break;
            case "always-impersonate":
                force = true;
                break;
            default:
                throw new RuntimeException(
                        "Invalid jdk.security.krb5.default.initiate.credential");
        }

        try {
            PrincipalName service = new PrincipalName(
                    new String(entry.getData(), StandardCharsets.UTF_8));
            if (!tgt.getClient().equals(service)) {
                if (DEBUG) {
                    System.out.println("proxy_impersonator does not match service name");
                }
                return force ? null : tgt;
            }
            PrincipalName client = getPrimaryPrincipal();
            Credentials proxy = null;
            for (Credentials c : getCredsList()) {
                if (c.getClientPrincipal().equals(client)
                        && c.getServicePrincipal().equals(service)) {
                    proxy = c;
                    break;
                }
            }
            if (proxy == null) {
                if (DEBUG) {
                    System.out.println("Cannot find evidence ticket in ccache");
                }
                return force ? null : tgt;
            }
            if (DEBUG) {
                System.out.println("Get proxied credential");
            }
            return tgt.setProxy(proxy.setKrbCreds());
        } catch (KrbException e) {
            if (DEBUG) {
                System.out.println("Impersonation with ccache failed");
            }
            return force ? null : tgt;
        }
    }
 
Example #5
Source File: PKCS12KeyStore.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private static String defaultCertProtectionAlgorithm() {
    String result = SecurityProperties.privilegedGetOverridable(
            "keystore.pkcs12.certProtectionAlgorithm");
    return (result != null && !result.isEmpty())
            ? result : "PBEWithSHA1AndRC2_40";
}
 
Example #6
Source File: PKCS12KeyStore.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private static int defaultCertPbeIterationCount() {
    String result = SecurityProperties.privilegedGetOverridable(
            "keystore.pkcs12.certPbeIterationCount");
    return (result != null && !result.isEmpty())
            ? string2IC("certPbeIterationCount", result) : 50000;
}
 
Example #7
Source File: PKCS12KeyStore.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private static int defaultKeyPbeIterationCount() {
    String result = SecurityProperties.privilegedGetOverridable(
            "keystore.pkcs12.keyPbeIterationCount");
    return (result != null && !result.isEmpty())
            ? string2IC("keyPbeIterationCount", result) : 50000;
}
 
Example #8
Source File: PKCS12KeyStore.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private static String defaultMacAlgorithm() {
    String result = SecurityProperties.privilegedGetOverridable(
            "keystore.pkcs12.macAlgorithm");
    return (result != null && !result.isEmpty())
            ? result : "HmacPBESHA1";
}
 
Example #9
Source File: PKCS12KeyStore.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private static int defaultMacIterationCount() {
    String result = SecurityProperties.privilegedGetOverridable(
            "keystore.pkcs12.macIterationCount");
    return (result != null && !result.isEmpty())
            ? string2IC("macIterationCount", result) : 100000;
}
 
Example #10
Source File: FileCredentialsCache.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public sun.security.krb5.Credentials getInitialCreds() {

        Credentials defaultCreds = getDefaultCreds();
        if (defaultCreds == null) {
            return null;
        }
        sun.security.krb5.Credentials tgt = defaultCreds.setKrbCreds();

        CredentialsCache.ConfigEntry entry = getConfigEntry("proxy_impersonator");
        if (entry == null) {
            if (DEBUG) {
                System.out.println("get normal credential");
            }
            return tgt;
        }

        boolean force;
        String prop = SecurityProperties.privilegedGetOverridable(
                "jdk.security.krb5.default.initiate.credential");
        if (prop == null) {
            prop = "always-impersonate";
        }
        switch (prop) {
            case "no-impersonate": // never try impersonation
                if (DEBUG) {
                    System.out.println("get normal credential");
                }
                return tgt;
            case "try-impersonate":
                force = false;
                break;
            case "always-impersonate":
                force = true;
                break;
            default:
                throw new RuntimeException(
                        "Invalid jdk.security.krb5.default.initiate.credential");
        }

        try {
            PrincipalName service = new PrincipalName(
                    new String(entry.getData(), StandardCharsets.UTF_8));
            if (!tgt.getClient().equals(service)) {
                if (DEBUG) {
                    System.out.println("proxy_impersonator does not match service name");
                }
                return force ? null : tgt;
            }
            PrincipalName client = getPrimaryPrincipal();
            Credentials proxy = null;
            for (Credentials c : getCredsList()) {
                if (c.getClientPrincipal().equals(client)
                        && c.getServicePrincipal().equals(service)) {
                    proxy = c;
                    break;
                }
            }
            if (proxy == null) {
                if (DEBUG) {
                    System.out.println("Cannot find evidence ticket in ccache");
                }
                return force ? null : tgt;
            }
            if (DEBUG) {
                System.out.println("Get proxied credential");
            }
            return tgt.setProxy(proxy.setKrbCreds());
        } catch (KrbException e) {
            if (DEBUG) {
                System.out.println("Impersonation with ccache failed");
            }
            return force ? null : tgt;
        }
    }