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 Project: dragonwell8_jdk   Author: alibaba   File: NativeGSSFactory.java    License: 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 #2
Source Project: dragonwell8_jdk   Author: alibaba   File: NativeGSSContext.java    License: 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 #3
Source Project: dragonwell8_jdk   Author: alibaba   File: NativeGSSContext.java    License: 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 #4
Source Project: dragonwell8_jdk   Author: alibaba   File: NativeGSSContext.java    License: 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 #5
Source Project: dragonwell8_jdk   Author: alibaba   File: NativeGSSContext.java    License: 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 #6
Source Project: dragonwell8_jdk   Author: alibaba   File: NativeGSSContext.java    License: 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 #7
Source Project: dragonwell8_jdk   Author: alibaba   File: NativeGSSContext.java    License: 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 #8
Source Project: TencentKona-8   Author: Tencent   File: NativeGSSFactory.java    License: 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 #9
Source Project: TencentKona-8   Author: Tencent   File: NativeGSSContext.java    License: 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 #10
Source Project: TencentKona-8   Author: Tencent   File: NativeGSSContext.java    License: 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 #11
Source Project: TencentKona-8   Author: Tencent   File: NativeGSSContext.java    License: 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 #12
Source Project: TencentKona-8   Author: Tencent   File: NativeGSSContext.java    License: 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 Project: TencentKona-8   Author: Tencent   File: NativeGSSContext.java    License: 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 #14
Source Project: TencentKona-8   Author: Tencent   File: NativeGSSContext.java    License: 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 #15
Source Project: jdk8u60   Author: chenghanpeng   File: NativeGSSFactory.java    License: 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 #16
Source Project: jdk8u60   Author: chenghanpeng   File: NativeGSSContext.java    License: 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 #17
Source Project: jdk8u60   Author: chenghanpeng   File: NativeGSSContext.java    License: 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 #18
Source Project: jdk8u60   Author: chenghanpeng   File: NativeGSSContext.java    License: 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 Project: jdk8u60   Author: chenghanpeng   File: NativeGSSContext.java    License: 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 #20
Source Project: jdk8u60   Author: chenghanpeng   File: NativeGSSContext.java    License: 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 #21
Source Project: jdk8u60   Author: chenghanpeng   File: NativeGSSContext.java    License: 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 #22
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: NativeGSSFactory.java    License: 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 #23
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: NativeGSSContext.java    License: 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 Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: NativeGSSContext.java    License: 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 #25
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: NativeGSSContext.java    License: 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 #26
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: NativeGSSContext.java    License: 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 #27
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: NativeGSSContext.java    License: 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 #28
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: NativeGSSFactory.java    License: 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 Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: NativeGSSContext.java    License: 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 #30
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: NativeGSSContext.java    License: 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);
    }
}