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


Java KerberosTicket.getClientAddresses方法代码示例

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


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

示例1: ticketToCreds

import javax.security.auth.kerberos.KerberosTicket; //导入方法依赖的package包/类
public static Credentials ticketToCreds(KerberosTicket kerbTicket)
        throws KrbException, IOException {
    return new Credentials(
        kerbTicket.getEncoded(),
        kerbTicket.getClient().getName(),
        kerbTicket.getServer().getName(),
        kerbTicket.getSessionKey().getEncoded(),
        kerbTicket.getSessionKeyType(),
        kerbTicket.getFlags(),
        kerbTicket.getAuthTime(),
        kerbTicket.getStartTime(),
        kerbTicket.getEndTime(),
        kerbTicket.getRenewTill(),
        kerbTicket.getClientAddresses());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:Krb5Util.java

示例2: getInstance

import javax.security.auth.kerberos.KerberosTicket; //导入方法依赖的package包/类
static Krb5InitCredential getInstance(GSSCaller caller, Krb5NameElement name,
                               int initLifetime)
    throws GSSException {

    KerberosTicket tgt = getTgt(caller, name, initLifetime);
    if (tgt == null)
        throw new GSSException(GSSException.NO_CRED, -1,
                               "Failed to find any Kerberos tgt");

    if (name == null) {
        String fullName = tgt.getClient().getName();
        name = Krb5NameElement.getInstance(fullName,
                                   Krb5MechFactory.NT_GSS_KRB5_PRINCIPAL);
    }

    return new Krb5InitCredential(name,
                                  tgt.getEncoded(),
                                  tgt.getClient(),
                                  tgt.getServer(),
                                  tgt.getSessionKey().getEncoded(),
                                  tgt.getSessionKeyType(),
                                  tgt.getFlags(),
                                  tgt.getAuthTime(),
                                  tgt.getStartTime(),
                                  tgt.getEndTime(),
                                  tgt.getRenewTill(),
                                  tgt.getClientAddresses());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:Krb5InitCredential.java

示例3: ticketToCreds

import javax.security.auth.kerberos.KerberosTicket; //导入方法依赖的package包/类
public static Credentials ticketToCreds(KerberosTicket kerbTicket)
    throws KrbException, IOException {
    return new Credentials(
        kerbTicket.getEncoded(),
        kerbTicket.getClient().getName(),
        kerbTicket.getServer().getName(),
        kerbTicket.getSessionKey().getEncoded(),
        kerbTicket.getSessionKeyType(),
        kerbTicket.getFlags(),
        kerbTicket.getAuthTime(),
        kerbTicket.getStartTime(),
        kerbTicket.getEndTime(),
        kerbTicket.getRenewTill(),
        kerbTicket.getClientAddresses());
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:16,代码来源:Krb5Util.java

示例4: main

import javax.security.auth.kerberos.KerberosTicket; //导入方法依赖的package包/类
public static void main(String[] args)
        throws Exception {

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

    String extraLine;
    switch (args[0]) {
        case "1": extraLine = "noaddresses = false"; break;
        case "2": extraLine = "noaddresses = true"; break;
        default: extraLine = ""; break;
    }

    KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
            extraLine);
    Config.refresh();

    Context c = Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
    Set<KerberosTicket> tickets =
            c.s().getPrivateCredentials(KerberosTicket.class);

    if (tickets.isEmpty()) throw new Exception();
    KerberosTicket ticket = tickets.iterator().next();
    InetAddress[] addresses = ticket.getClientAddresses();

    switch (args[0]) {
        case "1":
            if (addresses == null || addresses.length == 0) {
                throw new Exception("No addresses");
            }
            if (ticket.getServer().getNameType()
                    != KerberosPrincipal.KRB_NT_SRV_INST) {
                throw new Exception(
                        "Wrong type: " + ticket.getServer().getNameType());
            }
            break;
        default:
            if (addresses != null && addresses.length != 0) {
                throw new Exception("See addresses");
            }
            break;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:44,代码来源:AddressesAndNameType.java

示例5: main

import javax.security.auth.kerberos.KerberosTicket; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        KDC.saveConfig(OneKDC.KRB5_CONF, new OneKDC(null),
                "noaddresses = false",
                "extra_addresses = 10.0.0.10, 10.0.0.11 10.0.0.12");
        Config.refresh();

        KerberosTicket ticket =
                Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false)
                        .s().getPrivateCredentials(KerberosTicket.class)
                        .iterator().next();

        InetAddress loopback = InetAddress.getLoopbackAddress();
        InetAddress extra1 = InetAddress.getByName("10.0.0.10");
        InetAddress extra2 = InetAddress.getByName("10.0.0.11");
        InetAddress extra3 = InetAddress.getByName("10.0.0.12");

        boolean loopbackFound = false;
        boolean extra1Found = false;
        boolean extra2Found = false;
        boolean extra3Found = false;
        boolean networkFound = false;

        for (InetAddress ia: ticket.getClientAddresses()) {
            System.out.println(ia);
            if (ia.equals(loopback)) {
                loopbackFound = true;
                System.out.println("  loopback found");
            } else if (ia.equals(extra1)) {
                extra1Found = true;
                System.out.println("  extra1 found");
            } else if (ia.equals(extra2)) {
                extra2Found = true;
                System.out.println("  extra2 found");
            } else if (ia.equals(extra3)) {
                extra3Found = true;
                System.out.println("  extra3 found");
            } else if (ia instanceof Inet4Address) {
                networkFound = true;
                System.out.println("  another address (" + ia +
                        "), assumed real network");
            }
        }

        if (!loopbackFound || !networkFound
                || !extra1Found || !extra2Found || !extra3Found ) {
            throw new Exception();
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:50,代码来源:Addresses.java


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