Search in sources :

Example 1 with GSSExceptionImpl

use of sun.security.jgss.GSSExceptionImpl in project jdk8u_jdk by JetBrains.

the class NativeGSSContext method getMechFromSpNegoToken.

// Retrieve the (preferred) mech out of SPNEGO tokens, i.e.
// NegTokenInit & NegTokenTarg
private static Oid getMechFromSpNegoToken(byte[] token, boolean isInitiator) throws GSSException {
    Oid mech = null;
    if (isInitiator) {
        GSSHeader header = null;
        try {
            header = new GSSHeader(new ByteArrayInputStream(token));
        } catch (IOException ioe) {
            throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
        }
        int negTokenLen = header.getMechTokenLength();
        byte[] negToken = new byte[negTokenLen];
        System.arraycopy(token, token.length - negTokenLen, negToken, 0, negToken.length);
        NegTokenInit ntok = new NegTokenInit(negToken);
        if (ntok.getMechToken() != null) {
            Oid[] mechList = ntok.getMechTypeList();
            mech = mechList[0];
        }
    } else {
        NegTokenTarg ntok = new NegTokenTarg(token);
        mech = ntok.getSupportedMech();
    }
    return mech;
}
Also used : NegTokenTarg(sun.security.jgss.spnego.NegTokenTarg) NegTokenInit(sun.security.jgss.spnego.NegTokenInit) GSSExceptionImpl(sun.security.jgss.GSSExceptionImpl) GSSHeader(sun.security.jgss.GSSHeader)

Example 2 with GSSExceptionImpl

use of sun.security.jgss.GSSExceptionImpl in project jdk8u_jdk by JetBrains.

the class NativeGSSContext method unwrap.

public void unwrap(InputStream inStream, OutputStream outStream, MessageProp msgProp) throws GSSException {
    try {
        byte[] wrapped = new byte[inStream.available()];
        int wLength = inStream.read(wrapped);
        byte[] data = unwrap(wrapped, 0, wLength, msgProp);
        outStream.write(data);
        outStream.flush();
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
Also used : GSSExceptionImpl(sun.security.jgss.GSSExceptionImpl)

Example 3 with GSSExceptionImpl

use of sun.security.jgss.GSSExceptionImpl in project jdk8u_jdk by JetBrains.

the class NativeGSSContext method unwrap.

public int unwrap(InputStream inStream, byte[] outBuf, int outOffset, MessageProp msgProp) throws GSSException {
    byte[] wrapped = null;
    int wLength = 0;
    try {
        wrapped = new byte[inStream.available()];
        wLength = inStream.read(wrapped);
        byte[] result = unwrap(wrapped, 0, wLength, msgProp);
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
    byte[] result = unwrap(wrapped, 0, wLength, msgProp);
    System.arraycopy(result, 0, outBuf, outOffset, result.length);
    return result.length;
}
Also used : GSSExceptionImpl(sun.security.jgss.GSSExceptionImpl)

Example 4 with GSSExceptionImpl

use of sun.security.jgss.GSSExceptionImpl in project jdk8u_jdk by JetBrains.

the class NativeGSSContext method verifyMIC.

public void verifyMIC(InputStream tokStream, InputStream msgStream, MessageProp msgProp) throws GSSException {
    try {
        byte[] msg = new byte[msgStream.available()];
        int mLength = msgStream.read(msg);
        byte[] tok = new byte[tokStream.available()];
        int tLength = tokStream.read(tok);
        verifyMIC(tok, 0, tLength, msg, 0, mLength, msgProp);
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
Also used : GSSExceptionImpl(sun.security.jgss.GSSExceptionImpl)

Example 5 with GSSExceptionImpl

use of sun.security.jgss.GSSExceptionImpl in project jdk8u_jdk by JetBrains.

the class NativeGSSContext method getMIC.

public void getMIC(InputStream inStream, OutputStream outStream, MessageProp msgProp) throws GSSException {
    try {
        int length = 0;
        byte[] msg = new byte[inStream.available()];
        length = inStream.read(msg);
        byte[] msgToken = getMIC(msg, 0, length, msgProp);
        if ((msgToken != null) && msgToken.length != 0) {
            outStream.write(msgToken);
        }
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
Also used : GSSExceptionImpl(sun.security.jgss.GSSExceptionImpl)

Aggregations

GSSExceptionImpl (sun.security.jgss.GSSExceptionImpl)9 GSSHeader (sun.security.jgss.GSSHeader)2 ObjectIdentifier (sun.security.util.ObjectIdentifier)2 IOException (java.io.IOException)1 NegTokenInit (sun.security.jgss.spnego.NegTokenInit)1 NegTokenTarg (sun.security.jgss.spnego.NegTokenTarg)1 DerInputStream (sun.security.util.DerInputStream)1 DerValue (sun.security.util.DerValue)1