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


Java Krb5.KRB_AP_ERR_BADKEYVER属性代码示例

本文整理汇总了Java中sun.security.krb5.internal.Krb5.KRB_AP_ERR_BADKEYVER属性的典型用法代码示例。如果您正苦于以下问题:Java Krb5.KRB_AP_ERR_BADKEYVER属性的具体用法?Java Krb5.KRB_AP_ERR_BADKEYVER怎么用?Java Krb5.KRB_AP_ERR_BADKEYVER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在sun.security.krb5.internal.Krb5的用法示例。


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

示例1: findKey

private static KerberosKey findKey(int etype, Integer version,
        KerberosKey[] keys) throws KrbException {
    int ktype;
    boolean etypeFound = false;
    for (int i = 0; i < keys.length; i++) {
        ktype = keys[i].getKeyType();
        if (etype == ktype) {
            etypeFound = true;
            if (versionMatches(version, keys[i].getVersionNumber())) {
                return keys[i];
            }
        }
    }
    // Key not found.
    // %%% kludge to allow DES keys to be used for diff etypes
    if ((etype == EncryptedData.ETYPE_DES_CBC_CRC ||
        etype == EncryptedData.ETYPE_DES_CBC_MD5)) {
        for (int i = 0; i < keys.length; i++) {
            ktype = keys[i].getKeyType();
            if (ktype == EncryptedData.ETYPE_DES_CBC_CRC ||
                    ktype == EncryptedData.ETYPE_DES_CBC_MD5) {
                etypeFound = true;
                if (versionMatches(version, keys[i].getVersionNumber())) {
                    return new KerberosKey(keys[i].getPrincipal(),
                        keys[i].getEncoded(),
                        etype,
                        keys[i].getVersionNumber());
                }
            }
        }
    }
    if (etypeFound) {
        throw new KrbException(Krb5.KRB_AP_ERR_BADKEYVER);
    }
    return null;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:36,代码来源:KerberosClientKeyExchangeImpl.java

示例2: main

public static void main(String[] args)
        throws Exception {

    OneKDC kdc = new OneKDC(null);
    kdc.writeJAASConf();

    // Rewrite keytab, 3 set of keys with different kvno
    KeyTab ktab = KeyTab.create(OneKDC.KTAB);
    p = new PrincipalName(
        OneKDC.SERVER+"@"+OneKDC.REALM, PrincipalName.KRB_NT_SRV_HST);
    ktab.addEntry(p, "pass1".toCharArray(), 1, true);
    ktab.addEntry(p, "pass3".toCharArray(), 3, true);
    ktab.addEntry(p, "pass2".toCharArray(), 2, true);
    ktab.save();

    char[] pass = "pass2".toCharArray();
    kdc.addPrincipal(OneKDC.SERVER, pass);
    go(OneKDC.SERVER, "com.sun.security.jgss.krb5.accept", pass);

    pass = "pass3".toCharArray();
    kdc.addPrincipal(OneKDC.SERVER, pass);
    // "server" initiate also, check pass2 is used at authentication
    go(OneKDC.SERVER, "server", pass);

    try {
        pass = "pass4".toCharArray();
        kdc.addPrincipal(OneKDC.SERVER, pass);
        go(OneKDC.SERVER, "com.sun.security.jgss.krb5.accept", pass);
        throw new Exception("This test should fail");
    } catch (GSSException gsse) {
        KrbException ke = (KrbException)gsse.getCause();
        if (ke.returnCode() != Krb5.KRB_AP_ERR_BADKEYVER) {
            throw new Exception("Not expected failure code: " +
                    ke.returnCode());
        }
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:37,代码来源:MoreKvno.java


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