• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GSSCaller类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getTicket

import sun.security.jgss.GSSCaller; //导入依赖的package包/类
/**
 * Retrieves the ticket corresponding to the client/server principal
 * pair from the Subject in the specified AccessControlContext.
 * If the ticket can not be found in the Subject, and if
 * useSubjectCredsOnly is false, then obtain ticket from
 * a LoginContext.
 */
static KerberosTicket getTicket(GSSCaller caller,
    String clientPrincipal, String serverPrincipal,
    AccessControlContext acc) throws LoginException {

    // Try to get ticket from acc's Subject
    Subject accSubj = Subject.getSubject(acc);
    KerberosTicket ticket =
        SubjectComber.find(accSubj, serverPrincipal, clientPrincipal,
              KerberosTicket.class);

    // Try to get ticket from Subject obtained from GSSUtil
    if (ticket == null && !GSSUtil.useSubjectCredsOnly(caller)) {
        Subject subject = GSSUtil.login(caller, GSSUtil.GSS_KRB5_MECH_OID);
        ticket = SubjectComber.find(subject,
            serverPrincipal, clientPrincipal, KerberosTicket.class);
    }
    return ticket;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:Krb5Util.java


示例2: getServiceCreds

import sun.security.jgss.GSSCaller; //导入依赖的package包/类
/**
 * Retrieves the ServiceCreds for the specified server principal from
 * the Subject in the specified AccessControlContext. If not found, and if
 * useSubjectCredsOnly is false, then obtain from a LoginContext.
 *
 * NOTE: This method is also used by JSSE Kerberos Cipher Suites
 */
public static ServiceCreds getServiceCreds(GSSCaller caller,
    String serverPrincipal, AccessControlContext acc)
            throws LoginException {

    Subject accSubj = Subject.getSubject(acc);
    ServiceCreds sc = null;
    if (accSubj != null) {
        sc = ServiceCreds.getInstance(accSubj, serverPrincipal);
    }
    if (sc == null && !GSSUtil.useSubjectCredsOnly(caller)) {
        Subject subject = GSSUtil.login(caller, GSSUtil.GSS_KRB5_MECH_OID);
        sc = ServiceCreds.getInstance(subject, serverPrincipal);
    }
    return sc;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:Krb5Util.java


示例3: tryConstrainedDelegation

import sun.security.jgss.GSSCaller; //导入依赖的package包/类
private void tryConstrainedDelegation() {
    if (state != STATE_IN_PROCESS && state != STATE_DONE) {
        return;
    }
    // We will only try constrained delegation once (if necessary).
    if (!isConstrainedDelegationTried) {
        if (delegatedCred == null) {
            if (DEBUG) {
                System.out.println(">>> Constrained deleg from " + caller);
            }
            // The constrained delegation part. The acceptor needs to have
            // isInitiator=true in order to get a TGT, either earlier at
            // logon stage, if useSubjectCredsOnly, or now.
            try {
                delegatedCred = new Krb5ProxyCredential(
                    Krb5InitCredential.getInstance(
                        GSSCaller.CALLER_ACCEPT, myName, lifetime),
                    peerName, serviceTicket);
            } catch (GSSException gsse) {
                // OK, delegatedCred is null then
            }
        }
        isConstrainedDelegationTried = true;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:Krb5Context.java


示例4: getInstance

import sun.security.jgss.GSSCaller; //导入依赖的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:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:Krb5InitCredential.java


示例5: getTgt

import sun.security.jgss.GSSCaller; //导入依赖的package包/类
private static KerberosTicket getTgt(GSSCaller caller, Krb5NameElement name,
                                             int initLifetime)
    throws GSSException {

    final String clientPrincipal;

    /*
     * Find the TGT for the realm that the client is in. If the client
     * name is not available, then use the default realm.
     */
    if (name != null) {
        clientPrincipal = (name.getKrb5PrincipalName()).getName();
    } else {
        clientPrincipal = null;
    }

    final AccessControlContext acc = AccessController.getContext();

    try {
        final GSSCaller realCaller = (caller == GSSCaller.CALLER_UNKNOWN)
                               ? GSSCaller.CALLER_INITIATE
                               : caller;
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<KerberosTicket>() {
            public KerberosTicket run() throws Exception {
                // It's OK to use null as serverPrincipal. TGT is almost
                // the first ticket for a principal and we use list.
                return Krb5Util.getTicket(
                    realCaller,
                    clientPrincipal, null, acc);
                    }});
    } catch (PrivilegedActionException e) {
        GSSException ge =
            new GSSException(GSSException.NO_CRED, -1,
                "Attempt to obtain new INITIATE credentials failed!" +
                " (" + e.getMessage() + ")");
        ge.initCause(e.getException());
        throw ge;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:Krb5InitCredential.java


示例6: getSubject

import sun.security.jgss.GSSCaller; //导入依赖的package包/类
/**
 * Retrieves the caller's Subject, or Subject obtained by logging in
 * via the specified caller.
 *
 * Caller must have permission to:
 *    - access the Subject
 *    - create LoginContext
 *    - read the auth.login.defaultCallbackHandler security property
 *
 * NOTE: This method is used by JSSE Kerberos Cipher Suites
 */
public static Subject getSubject(GSSCaller caller,
    AccessControlContext acc) throws LoginException {

    // Try to get the Subject from acc
    Subject subject = Subject.getSubject(acc);

    // Try to get Subject obtained from GSSUtil
    if (subject == null && !GSSUtil.useSubjectCredsOnly(caller)) {
        subject = GSSUtil.login(caller, GSSUtil.GSS_KRB5_MECH_OID);
    }
    return subject;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:Krb5Util.java


示例7: getInstance

import sun.security.jgss.GSSCaller; //导入依赖的package包/类
static Krb5AcceptCredential getInstance(final GSSCaller caller, Krb5NameElement name)
    throws GSSException {

    final String serverPrinc = (name == null? null:
        name.getKrb5PrincipalName().getName());
    final AccessControlContext acc = AccessController.getContext();

    ServiceCreds creds = null;
    try {
        creds = AccessController.doPrivileged(
                    new PrivilegedExceptionAction<ServiceCreds>() {
            public ServiceCreds run() throws Exception {
                return Krb5Util.getServiceCreds(
                    caller == GSSCaller.CALLER_UNKNOWN ? GSSCaller.CALLER_ACCEPT: caller,
                    serverPrinc, acc);
            }});
    } catch (PrivilegedActionException e) {
        GSSException ge =
            new GSSException(GSSException.NO_CRED, -1,
                "Attempt to obtain new ACCEPT credentials failed!");
        ge.initCause(e.getException());
        throw ge;
    }

    if (creds == null)
        throw new GSSException(GSSException.NO_CRED, -1,
                               "Failed to find any Kerberos credentails");

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

    return new Krb5AcceptCredential(name, creds);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:Krb5AcceptCredential.java


示例8: Krb5Context

import sun.security.jgss.GSSCaller; //导入依赖的package包/类
/**
 * Constructor for Krb5Context to be called on the context initiator's
 * side.
 */
Krb5Context(GSSCaller caller, Krb5NameElement peerName, Krb5CredElement myCred,
            int lifetime)
    throws GSSException {

    if (peerName == null)
        throw new IllegalArgumentException("Cannot have null peer name");

    this.caller = caller;
    this.peerName = peerName;
    this.myCred = myCred;
    this.lifetime = lifetime;
    this.initiator = true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:Krb5Context.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CDATA类代码示例发布时间:2022-05-21
下一篇:
Java KubernetesClientException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap