Java Code Examples for org.ietf.jgss.GSSException#DEFECTIVE_TOKEN

The following examples show how to use org.ietf.jgss.GSSException#DEFECTIVE_TOKEN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GGSSchemeBase.java    From ats-framework with Apache License 2.0 4 votes vote down vote up
@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);
    }
}
 
Example 2
Source File: GSSHeader.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 3
Source File: GSSHeader.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 4
Source File: GSSHeader.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 5
Source File: GSSHeader.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 6
Source File: GSSHeader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 7
Source File: GSSHeader.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 8
Source File: GSSHeader.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 9
Source File: GSSHeader.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 10
Source File: GSSHeader.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 11
Source File: GSSHeader.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 12
Source File: GSSHeader.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 13
Source File: GSSHeader.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}
 
Example 14
Source File: GSSHeader.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Reads in a GSSHeader from an InputStream. Typically this would be
 * used as part of reading the complete token from an InputStream
 * that is obtained from a socket.
 */
public GSSHeader(InputStream is)
    throws IOException, GSSException {

    //      debug("Parsing GSS token: ");

    int tag = is.read();

    //      debug("tag=" + tag);

    if (tag != TOKEN_ID)
        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                               "GSSHeader did not find the right tag");

    int length = getLength(is);

    DerValue temp = new DerValue(is);
    mechOidBytes = temp.toByteArray();
    mechOid = temp.getOID();
    //      debug (" oid=" + mechOid);

    //      debug (" len starting with oid=" + length);
    mechTokenLength = length - mechOidBytes.length;

    //      debug("  mechToken length=" + mechTokenLength);

}