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


Java GSSException.getMessage方法代碼示例

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


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

示例1: authenticate

import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
@Override
public Header authenticate(
                            final Credentials credentials,
                            final HttpRequest request,
                            final HttpContext context ) throws AuthenticationException {

    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    switch (state) {
        case UNINITIATED:
            throw new AuthenticationException(getSchemeName() + " authentication has not been initiated");
        case FAILED:
            throw new AuthenticationException(getSchemeName() + " authentication has failed");
        case CHALLENGE_RECEIVED:
            try {
                token = generateToken(token);
                state = State.TOKEN_GENERATED;
            } catch (GSSException gsse) {
                state = State.FAILED;
                if (gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
                    || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED)
                    throw new InvalidCredentialsException(gsse.getMessage(), gsse);
                if (gsse.getMajor() == GSSException.NO_CRED)
                    throw new InvalidCredentialsException(gsse.getMessage(), gsse);
                if (gsse.getMajor() == GSSException.DEFECTIVE_TOKEN
                    || gsse.getMajor() == GSSException.DUPLICATE_TOKEN
                    || gsse.getMajor() == GSSException.OLD_TOKEN)
                    throw new AuthenticationException(gsse.getMessage(), gsse);
                // other error
                throw new AuthenticationException(gsse.getMessage());
            }
            // continue to next case block
        case TOKEN_GENERATED:
            String tokenstr = new String(base64codec.encode(token));
            if (log.isDebugEnabled()) {
                log.debug("Sending response '" + tokenstr + "' back to the auth server");
            }
            return new BasicHeader("Authorization", "Negotiate " + tokenstr);
        default:
            throw new IllegalStateException("Illegal state: " + state);
    }
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:44,代碼來源:GGSSchemeBase.java

示例2: authenticate

import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
@Override
public Header authenticate(
        final Credentials credentials,
        final HttpRequest request,
        final HttpContext context) throws AuthenticationException {
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    switch (state) {
    case UNINITIATED:
        throw new AuthenticationException(getSchemeName() + " authentication has not been initiated");
    case FAILED:
        throw new AuthenticationException(getSchemeName() + " authentication has failed");
    case CHALLENGE_RECEIVED:
        try {
            String key = null;
            if (isProxy()) {
                key = ExecutionContext.HTTP_PROXY_HOST;
            } else {
                key = ExecutionContext.HTTP_TARGET_HOST;
            }
            HttpHost host = (HttpHost) context.getAttribute(key);
            if (host == null) {
                throw new AuthenticationException("Authentication host is not set " +
                        "in the execution context");
            }
            String authServer;
            if (!this.stripPort && host.getPort() > 0) {
                authServer = host.toHostString();
            } else {
                authServer = host.getHostName();
            }

            if (log.isDebugEnabled()) {
                log.debug("init " + authServer);
            }
            token = generateToken(token, authServer);
            state = State.TOKEN_GENERATED;
        } catch (GSSException gsse) {
            state = State.FAILED;
            if (gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
                    || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED)
                throw new InvalidCredentialsException(gsse.getMessage(), gsse);
            if (gsse.getMajor() == GSSException.NO_CRED )
                throw new InvalidCredentialsException(gsse.getMessage(), gsse);
            if (gsse.getMajor() == GSSException.DEFECTIVE_TOKEN
                    || gsse.getMajor() == GSSException.DUPLICATE_TOKEN
                    || gsse.getMajor() == GSSException.OLD_TOKEN)
                throw new AuthenticationException(gsse.getMessage(), gsse);
            // other error
            throw new AuthenticationException(gsse.getMessage());
        }
    case TOKEN_GENERATED:
        String tokenstr = new String(base64codec.encode(token));
        if (log.isDebugEnabled()) {
            log.debug("Sending response '" + tokenstr + "' back to the auth server");
        }
        return new BasicHeader("Authorization", "Negotiate " + tokenstr);
    default:
        throw new IllegalStateException("Illegal state: " + state);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:63,代碼來源:GGSSchemeBase.java

示例3: authenticate

import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
/**
 * Produces Negotiate authorization string based on token created by 
 * processChallenge.
 * 
 * @param credentials Never used be the Negotiate scheme but must be provided to 
 * satisfy common-httpclient API. Credentials from JAAS will be used insted.
 * @param method The method being authenticated
 * 
 * @throws AuthenticationException if authorization string cannot 
 *   be generated due to an authentication failure
 * 
 * @return an Negotiate authorization string
 * 
 * @since 3.0
 */
public String authenticate(
    Credentials credentials, 
    HttpMethod method
) throws AuthenticationException {
    LOG.debug("enter NegotiateScheme.authenticate(Credentials, HttpMethod)");

    if (state == UNINITIATED) {
        throw new IllegalStateException(
           "Negotiation authentication process has not been initiated");
    }

    try {
        try {                
            if(context==null) {
                LOG.info("host: " + method.getURI().getHost());
                init( method.getURI().getHost() );
            }
        } catch (org.apache.commons.httpclient.URIException urie) {
            LOG.error(urie.getMessage());
            state = FAILED;
            throw new AuthenticationException(urie.getMessage());
        }
    
        // HTTP 1.1 issue:
        // Mutual auth will never complete do to 200 insted of 401 in 
        // return from server. "state" will never reach ESTABLISHED
        // but it works anyway
        token = context.initSecContext(token, 0, token.length);
        LOG.info("got token, sending " + token.length + " to server");
    } catch (GSSException gsse) {
        LOG.fatal(gsse.getMessage());
        state = FAILED;
        if( gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
                || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED )
            throw new InvalidCredentialsException(gsse.getMessage(),gsse);
        if( gsse.getMajor() == GSSException.NO_CRED )
            throw new CredentialsNotAvailableException(gsse.getMessage(),gsse);
        if( gsse.getMajor() == GSSException.DEFECTIVE_TOKEN
                || gsse.getMajor() == GSSException.DUPLICATE_TOKEN
                || gsse.getMajor() == GSSException.OLD_TOKEN )
            throw new AuthChallengeException(gsse.getMessage(),gsse);
        // other error
        throw new AuthenticationException(gsse.getMessage());
    }
    return "Negotiate " + new String(new Base64().encode(token));
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:62,代碼來源:NegotiateScheme.java

示例4: authenticate

import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
@Override
public Header authenticate(
        final Credentials credentials,
        final HttpRequest request,
        final HttpContext context) throws AuthenticationException {
    Args.notNull(request, "HTTP request");
    switch (state) {
    case UNINITIATED:
        throw new AuthenticationException(getSchemeName() + " authentication has not been initiated");
    case FAILED:
        throw new AuthenticationException(getSchemeName() + " authentication has failed");
    case CHALLENGE_RECEIVED:
        try {
            final HttpRoute route = (HttpRoute) context.getAttribute(HttpClientContext.HTTP_ROUTE);
            if (route == null) {
                throw new AuthenticationException("Connection route is not available");
            }
            HttpHost host;
            if (isProxy()) {
                host = route.getProxyHost();
                if (host == null) {
                    host = route.getTargetHost();
                }
            } else {
                host = route.getTargetHost();
            }
            final String authServer;
            if (!this.stripPort && host.getPort() > 0) {
                authServer = host.toHostString();
            } else {
                authServer = host.getHostName();
            }

            if (log.isDebugEnabled()) {
                log.debug("init " + authServer);
            }
            token = generateToken(token, authServer);
            state = State.TOKEN_GENERATED;
        } catch (final GSSException gsse) {
            state = State.FAILED;
            if (gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
                    || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED) {
                throw new InvalidCredentialsException(gsse.getMessage(), gsse);
            }
            if (gsse.getMajor() == GSSException.NO_CRED ) {
                throw new InvalidCredentialsException(gsse.getMessage(), gsse);
            }
            if (gsse.getMajor() == GSSException.DEFECTIVE_TOKEN
                    || gsse.getMajor() == GSSException.DUPLICATE_TOKEN
                    || gsse.getMajor() == GSSException.OLD_TOKEN) {
                throw new AuthenticationException(gsse.getMessage(), gsse);
            }
            // other error
            throw new AuthenticationException(gsse.getMessage());
        }
    case TOKEN_GENERATED:
        final String tokenstr = new String(base64codec.encode(token));
        if (log.isDebugEnabled()) {
            log.debug("Sending response '" + tokenstr + "' back to the auth server");
        }
        final CharArrayBuffer buffer = new CharArrayBuffer(32);
        if (isProxy()) {
            buffer.append(AUTH.PROXY_AUTH_RESP);
        } else {
            buffer.append(AUTH.WWW_AUTH_RESP);
        }
        buffer.append(": Negotiate ");
        buffer.append(tokenstr);
        return new BufferedHeader(buffer);
    default:
        throw new IllegalStateException("Illegal state: " + state);
    }
}
 
開發者ID:reportportal,項目名稱:client-java-httpclient-repacked,代碼行數:74,代碼來源:GGSSchemeBase.java

示例5: MIEName

import org.ietf.jgss.GSSException; //導入方法依賴的package包/類
/**
 * Instance a <code>MIEName</code> object.
 * 
 * @param buf the name of context initiator or acceptor
 */
MIEName(byte[] buf){
    int i;
    int len;
    if(buf.length<TOK_ID_SIZE+MECH_OID_LEN_SIZE){
        throw new IllegalArgumentException();
    }
    // TOK_ID
    for (i = 0; i < TOK_ID.length; i++) {
        if(TOK_ID[i]!=buf[i]){
            throw new IllegalArgumentException();
        }
    }
    // MECH_OID_LEN
    len = 0xff00 & (buf[i++] << 8);
    len |= 0xff & buf[i++];
    
    // MECH_OID
    if(buf.length<i+len){
        throw new IllegalArgumentException();
    }
    byte[] bo = new byte[len]; 
    System.arraycopy(buf, i, bo, 0, len);
    i += len;
    try{
        oid = new Oid(bo);
    }catch (GSSException e) {
        throw new IllegalArgumentException(e.getMessage());
    }
    
    // NAME_LEN
    if(buf.length<i+NAME_LEN_SIZE){
        throw new IllegalArgumentException();
    }
    len  = 0xff000000 & (buf[i++] << 24);
    len |= 0x00ff0000 & (buf[i++] << 16);
    len |= 0x0000ff00 & (buf[i++] << 8);
    len |= 0x000000ff & buf[i++];
    
    // NAME
    if(buf.length<i+len){
        throw new IllegalArgumentException();
    }
    name = new String(buf, i, len);
    
}
 
開發者ID:jaeksoft,項目名稱:jcifs-krb5,代碼行數:51,代碼來源:MIEName.java


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