sun.security.jgss.GSSHeader Java Examples

The following examples show how to use sun.security.jgss.GSSHeader. 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 dragonwell8_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 #2
Source File: NativeGSSContext.java    From TencentKona-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 #3
Source File: NativeGSSContext.java    From jdk8u60 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 #4
Source File: NativeGSSContext.java    From openjdk-jdk8u 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 #5
Source File: NativeGSSContext.java    From openjdk-jdk8u-backup 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 #6
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 #7
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 #8
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 #9
Source File: NativeGSSContext.java    From openjdk-8-source 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 #10
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 #11
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 #12
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 #13
Source File: NativeGSSContext.java    From jdk8u-dev-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);
    }
}