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


Java PrincipalName类代码示例

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


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

示例1: getPrincipalHostName

import sun.security.krb5.PrincipalName; //导入依赖的package包/类
@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,代码行数:20,代码来源:Krb5ProxyImpl.java

示例2: HostAddresses

import sun.security.krb5.PrincipalName; //导入依赖的package包/类
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,代码行数:20,代码来源:HostAddresses.java

示例3: KRBError

import sun.security.krb5.PrincipalName; //导入依赖的package包/类
public KRBError(
                APOptions new_apOptions,
                KerberosTime new_cTime,
                Integer new_cuSec,
                KerberosTime new_sTime,
                Integer new_suSec,
                int new_errorCode,
                PrincipalName new_cname,
                PrincipalName new_sname,
                String new_eText,
                byte[] new_eData
                    ) throws IOException, Asn1Exception {
    pvno = Krb5.PVNO;
    msgType = Krb5.KRB_ERROR;
    cTime = new_cTime;
    cuSec = new_cuSec;
    sTime = new_sTime;
    suSec = new_suSec;
    errorCode = new_errorCode;
    cname = new_cname;
    sname = new_sname;
    eText = new_eText;
    eData = new_eData;

    parseEData(eData);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:KRBError.java

示例4: init

import sun.security.krb5.PrincipalName; //导入依赖的package包/类
/**
 * Initializes a Ticket object.
 * @param encoding a single DER-encoded value.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 * @exception KrbApErrException if the value read from the DER-encoded data stream does not match the pre-defined value.
 * @exception RealmException if an error occurs while parsing a Realm object.
 */

private void init(DerValue encoding) throws Asn1Exception,
RealmException, KrbApErrException, IOException {
    DerValue der;
    DerValue subDer;
    if (((encoding.getTag() & (byte)0x1F) != Krb5.KRB_TKT)
        || (encoding.isApplication() != true)
        || (encoding.isConstructed() != true))
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    der = encoding.getData().getDerValue();
    if (der.getTag() != DerValue.tag_Sequence)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    subDer = der.getData().getDerValue();
    if ((subDer.getTag() & (byte)0x1F) != (byte)0x00)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    tkt_vno = subDer.getData().getBigInteger().intValue();
    if (tkt_vno != Krb5.TICKET_VNO)
        throw new KrbApErrException(Krb5.KRB_AP_ERR_BADVERSION);
    Realm srealm = Realm.parse(der.getData(), (byte)0x01, false);
    sname = PrincipalName.parse(der.getData(), (byte)0x02, false, srealm);
    encPart = EncryptedData.parse(der.getData(), (byte)0x03, false);
    if (der.getData().available() > 0)
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:Ticket.java

示例5: readObject

import sun.security.krb5.PrincipalName; //导入依赖的package包/类
/**
 * Reads this object from a stream (i.e., deserializes it)
 */
private void readObject(ObjectInputStream ois)
        throws IOException, ClassNotFoundException {
    byte[] asn1EncPrincipal = (byte [])ois.readObject();
    byte[] encRealm = (byte [])ois.readObject();
    try {
       Realm realmObject = new Realm(new DerValue(encRealm));
       PrincipalName krb5Principal = new PrincipalName(
               new DerValue(asn1EncPrincipal), realmObject);
       realm = realmObject.toString();
       fullName = krb5Principal.toString();
       nameType = krb5Principal.getNameType();
    } catch (Exception e) {
        throw new IOException(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:KerberosPrincipal.java

示例6: main

import sun.security.krb5.PrincipalName; //导入依赖的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

示例7: main

import sun.security.krb5.PrincipalName; //导入依赖的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

示例8: main

import sun.security.krb5.PrincipalName; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:EmptyCC.java

示例9: main

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

        OneKDC kdc = new OneKDC(null);
        kdc.writeJAASConf();
        kdc.setOption(KDC.Option.RESP_NT, PrincipalName.KRB_NT_PRINCIPAL);

        Context c, s;
        c = Context.fromJAAS("client");
        s = Context.fromJAAS("server");

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

        Context.handshake(c, s);

        Context.transmit("i say high --", c, s);
        Context.transmit("   you say low", s, c);

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

示例10: HostAddresses

import sun.security.krb5.PrincipalName; //导入依赖的package包/类
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,代码行数:20,代码来源:HostAddresses.java

示例11: getServiceHostName

import sun.security.krb5.PrincipalName; //导入依赖的package包/类
@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,代码行数:20,代码来源:Krb5KeyExchangeService.java


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