当前位置: 首页>>代码示例>>Java>>正文


Java KeyTab类代码示例

本文整理汇总了Java中sun.security.krb5.internal.ktab.KeyTab的典型用法代码示例。如果您正苦于以下问题:Java KeyTab类的具体用法?Java KeyTab怎么用?Java KeyTab使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


KeyTab类属于sun.security.krb5.internal.ktab包,在下文中一共展示了KeyTab类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import sun.security.krb5.internal.ktab.KeyTab; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    String name = "ktab";
    KeyTab kt = KeyTab.create(name);
    kt.addEntry(new PrincipalName("[email protected]"), "x".toCharArray(), 1, true);
    kt.save();
    check(name);
    check("FILE:" + name);

    name = new File(name).getAbsolutePath().toString();

    check(name);
    check("FILE:" + name);

    // The bug reporter uses this style, should only work for
    // absolute path
    check("FILE:/" + name);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:FileKeyTab.java

示例2: main

import sun.security.krb5.internal.ktab.KeyTab; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    KeyTab kt = KeyTab.create("ktab");
    // Two entries with very different length, so that it's easy to
    // observice the abnormal change of "index" field.
    kt.addEntry(new PrincipalName(
            "[email protected]"),
            "x".toCharArray(), 1, true);
    kt.addEntry(new PrincipalName("[email protected]"), "x".toCharArray(), 1, true);
    kt.save();
    Runnable t = new Runnable() {
        @Override
        public void run() {
            KeyTab.getInstance("ktab").getClass();
        }
    };
    for (int i=0; i<10; i++) {
        new Thread(t).start();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:KeyTabIndex.java

示例3: writeKtab

import sun.security.krb5.internal.ktab.KeyTab; //导入依赖的package包/类
/**
 * Writes or appends keys into a keytab.
 * <p>
 * Attention: This is the most basic one of a series of methods below on
 * keytab creation or modification. All these methods reference krb5.conf
 * settings. If you need to modify krb5.conf or switch to another krb5.conf
 * later, please call <code>Config.refresh()</code> again. For example:
 * <pre>
 * kdc.writeKtab("/etc/kdc/ktab", true);  // Config is initialized,
 * System.setProperty("java.security.krb5.conf", "/home/mykrb5.conf");
 * Config.refresh();
 * </pre>
 * Inside this method there are 2 places krb5.conf is used:
 * <ol>
 * <li> (Fatal) Generating keys: EncryptionKey.acquireSecretKeys
 * <li> (Has workaround) Creating PrincipalName
 * </ol>
 * @param tab the keytab file name
 * @param append true if append, otherwise, overwrite.
 * @param names the names to write into, write all if names is empty
 */
public void writeKtab(String tab, boolean append, String... names)
        throws IOException, KrbException {
    KeyTab ktab = append ? KeyTab.getInstance(tab) : KeyTab.create(tab);
    Iterable<String> entries =
            (names.length != 0) ? Arrays.asList(names): passwords.keySet();
    for (String name : entries) {
        char[] pass = passwords.get(name);
        int kvno = 0;
        if (Character.isDigit(pass[pass.length-1])) {
            kvno = pass[pass.length-1] - '0';
        }
        PrincipalName pn = new PrincipalName(name,
                    name.indexOf('/') < 0 ?
                        PrincipalName.KRB_NT_UNKNOWN :
                        PrincipalName.KRB_NT_SRV_HST);
        ktab.addEntry(pn,
                    getSalt(pn),
                    pass,
                    kvno,
                    true);
    }
    ktab.save();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:45,代码来源:KDC.java

示例4: main

import sun.security.krb5.internal.ktab.KeyTab; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        // 0. Non-existing keytab
        Files.deleteIfExists(Paths.get(NAME));
        check(true);

        // 1. Create with KeyTab
        Files.deleteIfExists(Paths.get(NAME));
        KeyTab.getInstance(NAME).save();
        check(false);

        // 2. Create with the tool
        Files.deleteIfExists(Paths.get(NAME));
        try {
            Class ktab = Class.forName("sun.security.krb5.internal.tools.Ktab");
            ktab.getDeclaredMethod("main", String[].class).invoke(null,
                    (Object)(("-k " + NAME + " -a [email protected] pass").split(" ")));
        } catch (ClassNotFoundException cnfe) {
            // Only Windows has ktab tool
            System.out.println("No ktab tool here. Ignored.");
            return;
        }
        check(false);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:KtabZero.java

示例5: main

import sun.security.krb5.internal.ktab.KeyTab; //导入依赖的package包/类
/**
 * Checks if a keytab contains exactly the keys (kvno and etype)
 * @param args keytabname kvno etype...
 */
public static void main(String[] args) throws Exception {
    System.out.println("Checking " + Arrays.toString(args));
    KeyTab ktab = KeyTab.getInstance(args[0]);
    Set<String> expected = new HashSet<>();
    for (int i=1; i<args.length; i += 2) {
        expected.add(args[i]+":"+args[i+1]);
    }
    for (KeyTabEntry e: ktab.getEntries()) {
        // KVNO and etype
        String vne = e.getKey().getKeyVersionNumber() + ":" +
                e.getKey().getEType();
        if (!expected.contains(vne)) {
            throw new Exception("No " + vne + " in expected");
        }
        expected.remove(vne);
    }
    if (!expected.isEmpty()) {
        throw new Exception("Extra elements in expected");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:KtabCheck.java

示例6: main

import sun.security.krb5.internal.ktab.KeyTab; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        // 0. Non-existing keytab
        Files.deleteIfExists(Paths.get(NAME));
        check(true);

        // 1. Create with KeyTab
        Files.deleteIfExists(Paths.get(NAME));
        KeyTab.getInstance(NAME).save();
        check(false);

        // 2. Create with the tool
        Files.deleteIfExists(Paths.get(NAME));
        sun.security.krb5.internal.tools.Ktab.main(
            ("-k " + NAME + " -a [email protected] pass").split(" "));
        check(false);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:KtabZero.java

示例7: writeKtab0

import sun.security.krb5.internal.ktab.KeyTab; //导入依赖的package包/类
/**
 * Writes or appends KDC keys into a keytab. See doc for writeMultiKtab.
 * @param append true if append, otherwise, overwrite.
 */
private static void writeKtab0(String tab, boolean append, KDC... kdcs)
        throws IOException, KrbException {
    KeyTab ktab = append ? KeyTab.getInstance(tab) : KeyTab.create(tab);
    for (KDC kdc: kdcs) {
        for (String name : kdc.passwords.keySet()) {
            char[] pass = kdc.passwords.get(name);
            int kvno = 0;
            if (Character.isDigit(pass[pass.length-1])) {
                kvno = pass[pass.length-1] - '0';
            }
            ktab.addEntry(new PrincipalName(name,
                    name.indexOf('/') < 0 ?
                        PrincipalName.KRB_NT_UNKNOWN :
                        PrincipalName.KRB_NT_SRV_HST),
                        pass,
                        kvno,
                        true);
        }
    }
    ktab.save();
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:26,代码来源:KDC.java


注:本文中的sun.security.krb5.internal.ktab.KeyTab类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。