當前位置: 首頁>>代碼示例>>Java>>正文


Java GSSContext.getCredDelegState方法代碼示例

本文整理匯總了Java中org.ietf.jgss.GSSContext.getCredDelegState方法的典型用法代碼示例。如果您正苦於以下問題:Java GSSContext.getCredDelegState方法的具體用法?Java GSSContext.getCredDelegState怎麽用?Java GSSContext.getCredDelegState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.ietf.jgss.GSSContext的用法示例。


在下文中一共展示了GSSContext.getCredDelegState方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processIdentity

import org.ietf.jgss.GSSContext; //導入方法依賴的package包/類
private void processIdentity(GSSContext gssContext) throws GSSException, Exception
{
   setIdentity(createIdentity(gssContext.getSrcName().toString()));

   if (DEBUG)
   {
      log.debug("context.getCredDelegState() = " + gssContext.getCredDelegState());
      log.debug("context.getMutualAuthState() = " + gssContext.getMutualAuthState());
      log.debug("context.getSrcName() = " + gssContext.getSrcName().toString());
   }

   if (gssContext.getCredDelegState()) {
       delegatedCredential = gssContext.getDelegCred();
   }

   negotiationContext.setAuthenticationMethod(SPNEGO);
   negotiationContext.setAuthenticated(true);
}
 
開發者ID:wildfly-security,項目名稱:jboss-negotiation,代碼行數:19,代碼來源:SPNEGOLoginModule.java

示例2: buildGSSResult

import org.ietf.jgss.GSSContext; //導入方法依賴的package包/類
private GSSResult buildGSSResult(NegotiationContext context, String securityDomain) throws LoginException {
    if (context.getResponseMessage() instanceof KerberosMessage) {
        try {
            KerberosMessage km = (KerberosMessage)context.getResponseMessage();
            GSSContext securityContext = (GSSContext) context.getSchemeContext();           
            return new GSSResult(km.getToken(), context.isAuthenticated(), securityContext.getCredDelegState()?securityContext.getDelegCred():null);
        } catch (GSSException e) {
            // login exception can not take exception
            throw new LoginException(e.getMessage());
        }
    }
    throw new LoginException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50103, securityDomain));
}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:14,代碼來源:JBossSecurityHelper.java

示例3: go

import org.ietf.jgss.GSSContext; //導入方法依賴的package包/類
void go(
        boolean forwardable,
        boolean requestDelegState,
        boolean requestDelegPolicyState,
        boolean delegState,
        boolean delegPolicyState,
        boolean delegated
        ) throws Exception {
    OneKDC kdc = new OneKDC(null);
    kdc.setOption(KDC.Option.OK_AS_DELEGATE,
            System.getProperty("test.kdc.policy.ok-as-delegate"));
    kdc.writeJAASConf();
    if (!forwardable) {
        // The default OneKDC always includes "forwardable = true"
        // in krb5.conf, override it.
        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
                "default_keytab_name = " + OneKDC.KTAB);
        Config.refresh();
    }

    Context c, s;
    c = Context.fromJAAS("client");
    s = Context.fromJAAS("com.sun.security.jgss.krb5.accept");

    Oid mech = GSSUtil.GSS_KRB5_MECH_OID;
    if (System.getProperty("test.spnego") != null) {
        mech = GSSUtil.GSS_SPNEGO_MECH_OID;
    }
    c.startAsClient(OneKDC.SERVER, mech);
    ExtendedGSSContext cx = (ExtendedGSSContext)c.x();
    cx.requestCredDeleg(requestDelegState);
    cx.requestDelegPolicy(requestDelegPolicyState);
    s.startAsServer(mech);
    GSSContext sx = s.x();

    Context.handshake(c, s);

    if (cx.getCredDelegState() != delegState) {
        throw new Exception("Initiator cred state error");
    }
    if (sx.getCredDelegState() != delegState) {
        throw new Exception("Acceptor cred state error");
    }
    if (cx.getDelegPolicyState() != delegPolicyState) {
        throw new Exception("Initiator cred policy state error");
    }

    GSSCredential cred = null;
    try {
        cred = s.x().getDelegCred();
    } catch (GSSException e) {
        // leave cred as null
    }

    if (delegated != (cred != null)) {
        throw new Exception("get cred error");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:59,代碼來源:OkAsDelegate.java

示例4: doSpnegoAuth

import org.ietf.jgss.GSSContext; //導入方法依賴的package包/類
/**
 * Performs authentication using the SPNEGO mechanism.
 *
 * <p>
 * Returns null if authentication failed or if the provided 
 * the auth scheme did not contain the SPNEGO/GSS token.
 * </p>
 * 
 * @return SpnegoPrincipal for the given auth scheme.
 */
private SpnegoPrincipal doSpnegoAuth(
    final SpnegoAuthScheme scheme, final SpnegoHttpServletResponse resp) 
    throws GSSException, IOException {

    final String principal;
    final byte[] gss = scheme.getToken();

    if (0 == gss.length) {
        LOGGER.finer("GSS data was NULL.");
        return null;
    }

    GSSContext context = null;
    GSSCredential delegCred = null;
    
    try {
        byte[] token = null;
        
        SpnegoAuthenticator.LOCK.lock();
        try {
            context = SpnegoAuthenticator.MANAGER.createContext(this.serverCredentials);
            token = context.acceptSecContext(gss, 0, gss.length);
        } finally {
            SpnegoAuthenticator.LOCK.unlock();
        }

        if (null == token) {
            LOGGER.finer("Token was NULL.");
            return null;
        }

        resp.setHeader(Constants.AUTHN_HEADER, Constants.NEGOTIATE_HEADER 
                + ' ' + Base64.encode(token));

        if (!context.isEstablished()) {
            LOGGER.fine("context not established");
            resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED, true);
            return null;
        }

        principal = context.getSrcName().toString();
        
        if (this.allowDelegation && context.getCredDelegState()) {
            delegCred = context.getDelegCred();
        }

    } finally {
        if (null != context) {
            SpnegoAuthenticator.LOCK.lock();
            try {
                context.dispose();
            } finally {
                SpnegoAuthenticator.LOCK.unlock();
            }
        }
    }

    return new SpnegoPrincipal(principal, KerberosPrincipal.KRB_NT_PRINCIPAL, delegCred);
}
 
開發者ID:codelibs,項目名稱:spnego,代碼行數:70,代碼來源:SpnegoAuthenticator.java


注:本文中的org.ietf.jgss.GSSContext.getCredDelegState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。