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


Java GSSNameSpi类代码示例

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


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

示例1: getName

import sun.security.jgss.spi.GSSNameSpi; //导入依赖的package包/类
public GSSNameSpi getName() throws GSSException {
    return cred.getName();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:SpNegoCredElement.java

示例2: impersonate

import sun.security.jgss.spi.GSSNameSpi; //导入依赖的package包/类
@Override
public GSSCredentialSpi impersonate(GSSNameSpi name) throws GSSException {
    return cred.impersonate(name);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:SpNegoCredElement.java

示例3: equals

import sun.security.jgss.spi.GSSNameSpi; //导入依赖的package包/类
public boolean equals(GSSNameSpi other) throws GSSException {
    if (!(other instanceof GSSNameElement)) {
        return false;
    }
    return cStub.compareName(pName, ((GSSNameElement)other).pName);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:GSSNameElement.java

示例4: impersonate

import sun.security.jgss.spi.GSSNameSpi; //导入依赖的package包/类
@Override
public GSSCredentialSpi impersonate(GSSNameSpi name) throws GSSException {
    throw new GSSException(GSSException.FAILURE, -1,
            "Not supported yet");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:GSSCredElement.java

示例5: getSubject

import sun.security.jgss.spi.GSSNameSpi; //导入依赖的package包/类
/**
 * Note: The current impl only works with Sun's impl of
 * GSSName and GSSCredential since it depends on package
 * private APIs.
 */
public static Subject getSubject(GSSName name,
                                 GSSCredential creds) {

    HashSet<Object> privCredentials = null;
    HashSet<Object> pubCredentials = new HashSet<Object>(); // empty Set

    Set<GSSCredentialSpi> gssCredentials = null;

    Set<KerberosPrincipal> krb5Principals =
                            new HashSet<KerberosPrincipal>();

    if (name instanceof GSSNameImpl) {
        try {
            GSSNameSpi ne = ((GSSNameImpl) name).getElement
                (GSS_KRB5_MECH_OID);
            String krbName = ne.toString();
            if (ne instanceof Krb5NameElement) {
                krbName =
                    ((Krb5NameElement) ne).getKrb5PrincipalName().getName();
            }
            KerberosPrincipal krbPrinc = new KerberosPrincipal(krbName);
            krb5Principals.add(krbPrinc);
        } catch (GSSException ge) {
            debug("Skipped name " + name + " due to " + ge);
        }
    }

    if (creds instanceof GSSCredentialImpl) {
        gssCredentials = ((GSSCredentialImpl) creds).getElements();
        privCredentials = new HashSet<Object>(gssCredentials.size());
        populateCredentials(privCredentials, gssCredentials);
    } else {
        privCredentials = new HashSet<Object>(); // empty Set
    }
    debug("Created Subject with the following");
    debug("principals=" + krb5Principals);
    debug("public creds=" + pubCredentials);
    debug("private creds=" + privCredentials);

    return new Subject(false, krb5Principals, pubCredentials,
                       privCredentials);

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:GSSUtil.java

示例6: searchSubject

import sun.security.jgss.spi.GSSNameSpi; //导入依赖的package包/类
/**
 * Searches the private credentials of current Subject with the
 * specified criteria and returns the matching GSSCredentialSpi
 * object out of Sun's impl of GSSCredential. Returns null if
 * no Subject present or a Vector which contains 0 or more
 * matching GSSCredentialSpi objects.
 */
public static <T extends GSSCredentialSpi> Vector<T>
        searchSubject(final GSSNameSpi name,
                      final Oid mech,
                      final boolean initiate,
                      final Class<? extends T> credCls) {
    debug("Search Subject for " + getMechStr(mech) +
          (initiate? " INIT" : " ACCEPT") + " cred (" +
          (name == null? "<<DEF>>" : name.toString()) + ", " +
          credCls.getName() + ")");
    final AccessControlContext acc = AccessController.getContext();
    try {
        Vector<T> creds =
            AccessController.doPrivileged
            (new PrivilegedExceptionAction<Vector<T>>() {
                public Vector<T> run() throws Exception {
                    Subject accSubj = Subject.getSubject(acc);
                    Vector<T> result = null;
                    if (accSubj != null) {
                        result = new Vector<T>();
                        Iterator<GSSCredentialImpl> iterator =
                            accSubj.getPrivateCredentials
                            (GSSCredentialImpl.class).iterator();
                        while (iterator.hasNext()) {
                            GSSCredentialImpl cred = iterator.next();
                            debug("...Found cred" + cred);
                            try {
                                GSSCredentialSpi ce =
                                    cred.getElement(mech, initiate);
                                debug("......Found element: " + ce);
                                if (ce.getClass().equals(credCls) &&
                                    (name == null ||
                                     name.equals((Object) ce.getName()))) {
                                    result.add(credCls.cast(ce));
                                } else {
                                    debug("......Discard element");
                                }
                            } catch (GSSException ge) {
                                debug("...Discard cred (" + ge + ")");
                            }
                        }
                    } else debug("No Subject");
                    return result;
                }
            });
        return creds;
    } catch (PrivilegedActionException pae) {
        debug("Unexpected exception when searching Subject:");
        if (DEBUG) pae.printStackTrace();
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:59,代码来源:GSSUtil.java


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