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


Java PrincipalName.KRB_NT_SRV_HST属性代码示例

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


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

示例1: getPrincipalHostName

@Override
public String getPrincipalHostName(Principal principal) {
    if (principal == null) {
       return null;
    }
    String hostName = null;
    try {
        PrincipalName princName =
            new PrincipalName(principal.getName(),
                    PrincipalName.KRB_NT_SRV_HST);
        String[] nameParts = princName.getNameStrings();
        if (nameParts.length >= 2) {
            hostName = nameParts[1];
        }
    } catch (Exception e) {
        // ignore
    }
    return hostName;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Krb5ProxyImpl.java

示例2: HostAddresses

public HostAddresses(PrincipalName serverPrincipal)
    throws UnknownHostException, KrbException {

    String[] components = serverPrincipal.getNameStrings();

    if (serverPrincipal.getNameType() != PrincipalName.KRB_NT_SRV_HST ||
        components.length < 2)
        throw new KrbException(Krb5.KRB_ERR_GENERIC, "Bad name");

    String host = components[1];
    InetAddress addr[] = InetAddress.getAllByName(host);
    HostAddress hAddrs[] = new HostAddress[addr.length];

    for (int i = 0; i < addr.length; i++) {
        hAddrs[i] = new HostAddress(addr[i]);
    }

    addresses = hAddrs;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:HostAddresses.java

示例3: HostAddresses

public HostAddresses(PrincipalName serverPrincipal)
    throws UnknownHostException, KrbException {

    String[] components = serverPrincipal.getNameStrings();

    if (serverPrincipal.getNameType() != PrincipalName.KRB_NT_SRV_HST ||
        components.length < 2)
        throw new KrbException(Krb5.KRB_ERR_GENERIC, "Bad name");

    String host = components[1];
    InetAddress[] addr = InetAddress.getAllByName(host);
    HostAddress[] hAddrs = new HostAddress[addr.length];

    for (int i = 0; i < addr.length; i++) {
        hAddrs[i] = new HostAddress(addr[i]);
    }

    addresses = hAddrs;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:HostAddresses.java

示例4: getServiceHostName

@Override
public String getServiceHostName(Principal principal) {
    if (principal == null) {
        return null;
    }
    String hostName = null;
    try {
        PrincipalName princName =
                new PrincipalName(principal.getName(),
                        PrincipalName.KRB_NT_SRV_HST);
        String[] nameParts = princName.getNameStrings();
        if (nameParts.length >= 2) {
            hostName = nameParts[1];
        }
    } catch (Exception e) {
        // ignore
    }
    return hostName;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Krb5KeyExchangeService.java

示例5: check

static void check(String input, String output) throws Exception {
    System.out.println(input + " -> " + output);
    PrincipalName pn = new PrincipalName("host/"+input,
            PrincipalName.KRB_NT_SRV_HST);
    if (!pn.getNameStrings()[1].equals(output)) {
        throw new Exception("Output is " + pn);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:Test.java

示例6: main

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

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

    // In KDC, it's 2
    char[] pass = "pass2".toCharArray();
    kdc.addPrincipal(OneKDC.SERVER, pass);

    // In ktab, kvno is 1 or 3, 3 has the same password
    KeyTab ktab = KeyTab.create(OneKDC.KTAB);
    PrincipalName p = new PrincipalName(
        OneKDC.SERVER+"@"+OneKDC.REALM, PrincipalName.KRB_NT_SRV_HST);
    ktab.addEntry(p, "pass1".toCharArray(), 1, true);
    ktab.addEntry(p, "pass2".toCharArray(), 3, true);
    ktab.save();

    Context c, s;

    c = Context.fromUserPass("dummy", "bogus".toCharArray(), false);
    s = Context.fromJAAS("server");

    c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
    s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);

    Context.handshake(c, s);

    s.dispose();
    c.dispose();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:KvnoNA.java

示例7: 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) {
        // Since 7197159, different kvno is accepted, this return code
        // will never be thrown out again.
        //KrbException ke = (KrbException)gsse.getCause();
        //if (ke.returnCode() != Krb5.KRB_AP_ERR_BADKEYVER) {
        //    throw new Exception("Not expected failure code: " +
        //            ke.returnCode());
        //}
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:39,代码来源:MoreKvno.java

示例8: 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.PrincipalName.KRB_NT_SRV_HST属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。