sun.security.jgss.GSSExceptionImpl Java Examples

The following examples show how to use sun.security.jgss.GSSExceptionImpl. 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: NativeGSSContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #2
Source File: NativeGSSContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #3
Source File: NativeGSSContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #4
Source File: NativeGSSContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #5
Source File: NativeGSSFactory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public GSSNameSpi getNameElement(String nameStr, Oid nameType)
    throws GSSException {
    try {
        byte[] nameBytes =
            (nameStr == null ? null : nameStr.getBytes("UTF-8"));
        return new GSSNameElement(nameBytes, nameType, cStub);
    } catch (UnsupportedEncodingException uee) {
        // Shouldn't happen
        throw new GSSExceptionImpl(GSSException.FAILURE, uee);
    }
}
 
Example #6
Source File: NativeGSSContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private byte[] retrieveToken(InputStream is, int mechTokenLen)
    throws GSSException {
    try {
        byte[] result = null;
        if (mechTokenLen != -1) {
            // Need to add back the GSS header for a complete GSS token
            SunNativeProvider.debug("Precomputed mechToken length: " +
                                     mechTokenLen);
            GSSHeader gssHeader = new GSSHeader
                (new ObjectIdentifier(cStub.getMech().toString()),
                 mechTokenLen);
            ByteArrayOutputStream baos = new ByteArrayOutputStream(600);

            byte[] mechToken = new byte[mechTokenLen];
            int len = is.read(mechToken);
            assert(mechTokenLen == len);
            gssHeader.encode(baos);
            baos.write(mechToken);
            result = baos.toByteArray();
        } else {
            // Must be unparsed GSS token or SPNEGO's NegTokenTarg token
            assert(mechTokenLen == -1);
            DerValue dv = new DerValue(is);
            result = dv.toByteArray();
        }
        SunNativeProvider.debug("Complete Token length: " +
                                result.length);
        return result;
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #7
Source File: NativeGSSContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void wrap(byte inBuf[], int offset, int len,
                 OutputStream os, MessageProp msgProp)
    throws GSSException {
    try {
    byte[] result = wrap(inBuf, offset, len, msgProp);
    os.write(result);
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #8
Source File: NativeGSSContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #9
Source File: NativeGSSContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #10
Source File: NativeGSSContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #11
Source File: NativeGSSContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #12
Source File: NativeGSSContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #13
Source File: NativeGSSContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private byte[] retrieveToken(InputStream is, int mechTokenLen)
    throws GSSException {
    try {
        byte[] result = null;
        if (mechTokenLen != -1) {
            // Need to add back the GSS header for a complete GSS token
            SunNativeProvider.debug("Precomputed mechToken length: " +
                                     mechTokenLen);
            GSSHeader gssHeader = new GSSHeader
                (new ObjectIdentifier(cStub.getMech().toString()),
                 mechTokenLen);
            ByteArrayOutputStream baos = new ByteArrayOutputStream(600);

            byte[] mechToken = new byte[mechTokenLen];
            int len = is.read(mechToken);
            assert(mechTokenLen == len);
            gssHeader.encode(baos);
            baos.write(mechToken);
            result = baos.toByteArray();
        } else {
            // Must be unparsed GSS token or SPNEGO's NegTokenTarg token
            assert(mechTokenLen == -1);
            DerValue dv = new DerValue(is);
            result = dv.toByteArray();
        }
        SunNativeProvider.debug("Complete Token length: " +
                                result.length);
        return result;
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #14
Source File: NativeGSSFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public GSSNameSpi getNameElement(String nameStr, Oid nameType)
    throws GSSException {
    try {
        byte[] nameBytes =
            (nameStr == null ? null : nameStr.getBytes("UTF-8"));
        return new GSSNameElement(nameBytes, nameType, cStub);
    } catch (UnsupportedEncodingException uee) {
        // Shouldn't happen
        throw new GSSExceptionImpl(GSSException.FAILURE, uee);
    }
}
 
Example #15
Source File: NativeGSSContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #16
Source File: NativeGSSContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void wrap(byte inBuf[], int offset, int len,
                 OutputStream os, MessageProp msgProp)
    throws GSSException {
    try {
    byte[] result = wrap(inBuf, offset, len, msgProp);
    os.write(result);
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #17
Source File: NativeGSSContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #18
Source File: NativeGSSContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void wrap(InputStream inStream, OutputStream outStream,
                 MessageProp msgProp) throws GSSException {
    try {
        byte[] data = new byte[inStream.available()];
        int length = inStream.read(data);
        byte[] token = wrap(data, 0, length, msgProp);
        outStream.write(token);
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #19
Source File: NativeGSSContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void wrap(byte inBuf[], int offset, int len,
                 OutputStream os, MessageProp msgProp)
    throws GSSException {
    try {
    byte[] result = wrap(inBuf, offset, len, msgProp);
    os.write(result);
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #20
Source File: NativeGSSContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private byte[] retrieveToken(InputStream is, int mechTokenLen)
    throws GSSException {
    try {
        byte[] result = null;
        if (mechTokenLen != -1) {
            // Need to add back the GSS header for a complete GSS token
            SunNativeProvider.debug("Precomputed mechToken length: " +
                                     mechTokenLen);
            GSSHeader gssHeader = new GSSHeader
                (new ObjectIdentifier(cStub.getMech().toString()),
                 mechTokenLen);
            ByteArrayOutputStream baos = new ByteArrayOutputStream(600);

            byte[] mechToken = new byte[mechTokenLen];
            int len = is.read(mechToken);
            assert(mechTokenLen == len);
            gssHeader.encode(baos);
            baos.write(mechToken);
            result = baos.toByteArray();
        } else {
            // Must be unparsed GSS token or SPNEGO's NegTokenTarg token
            assert(mechTokenLen == -1);
            DerValue dv = new DerValue(is);
            result = dv.toByteArray();
        }
        SunNativeProvider.debug("Complete Token length: " +
                                result.length);
        return result;
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #21
Source File: NativeGSSFactory.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public GSSNameSpi getNameElement(String nameStr, Oid nameType)
    throws GSSException {
    try {
        byte[] nameBytes =
            (nameStr == null ? null : nameStr.getBytes("UTF-8"));
        return new GSSNameElement(nameBytes, nameType, cStub);
    } catch (UnsupportedEncodingException uee) {
        // Shouldn't happen
        throw new GSSExceptionImpl(GSSException.FAILURE, uee);
    }
}
 
Example #22
Source File: NativeGSSContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #23
Source File: NativeGSSContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void wrap(byte inBuf[], int offset, int len,
                 OutputStream os, MessageProp msgProp)
    throws GSSException {
    try {
    byte[] result = wrap(inBuf, offset, len, msgProp);
    os.write(result);
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #24
Source File: NativeGSSContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #25
Source File: NativeGSSContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void wrap(InputStream inStream, OutputStream outStream,
                 MessageProp msgProp) throws GSSException {
    try {
        byte[] data = new byte[inStream.available()];
        int length = inStream.read(data);
        byte[] token = wrap(data, 0, length, msgProp);
        outStream.write(token);
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #26
Source File: NativeGSSContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void wrap(byte[] inBuf, int offset, int len,
                 OutputStream os, MessageProp msgProp)
    throws GSSException {
    try {
    byte[] result = wrap(inBuf, offset, len, msgProp);
    os.write(result);
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #27
Source File: NativeGSSContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private byte[] retrieveToken(InputStream is, int mechTokenLen)
    throws GSSException {
    try {
        byte[] result = null;
        if (mechTokenLen != -1) {
            // Need to add back the GSS header for a complete GSS token
            SunNativeProvider.debug("Precomputed mechToken length: " +
                                     mechTokenLen);
            GSSHeader gssHeader = new GSSHeader
                (new ObjectIdentifier(cStub.getMech().toString()),
                 mechTokenLen);
            ByteArrayOutputStream baos = new ByteArrayOutputStream(600);

            byte[] mechToken = new byte[mechTokenLen];
            int len = is.read(mechToken);
            assert(mechTokenLen == len);
            gssHeader.encode(baos);
            baos.write(mechToken);
            result = baos.toByteArray();
        } else {
            // Must be unparsed GSS token or SPNEGO's NegTokenTarg token
            assert(mechTokenLen == -1);
            DerValue dv = new DerValue(is);
            result = dv.toByteArray();
        }
        SunNativeProvider.debug("Complete Token length: " +
                                result.length);
        return result;
    } catch (IOException ioe) {
        throw new GSSExceptionImpl(GSSException.FAILURE, ioe);
    }
}
 
Example #28
Source File: NativeGSSFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public GSSNameSpi getNameElement(String nameStr, Oid nameType)
    throws GSSException {
    try {
        byte[] nameBytes =
            (nameStr == null ? null : nameStr.getBytes("UTF-8"));
        return new GSSNameElement(nameBytes, nameType, cStub);
    } catch (UnsupportedEncodingException uee) {
        // Shouldn't happen
        throw new GSSExceptionImpl(GSSException.FAILURE, uee);
    }
}
 
Example #29
Source File: NativeGSSContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #30
Source File: NativeGSSContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}