当前位置: 首页>>代码示例>>Java>>正文


Java Inflater类代码示例

本文整理汇总了Java中java.util.zip.Inflater的典型用法代码示例。如果您正苦于以下问题:Java Inflater类的具体用法?Java Inflater怎么用?Java Inflater使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Inflater类属于java.util.zip包,在下文中一共展示了Inflater类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyLogoutOneLogoutRequestNotAttempted

import java.util.zip.Inflater; //导入依赖的package包/类
@Test
public void verifyLogoutOneLogoutRequestNotAttempted() throws Exception {
    final SingleLogoutService service = new WebApplicationServiceFactory().createService(TEST_URL, SingleLogoutService.class);
    final LogoutRequest logoutRequest = new DefaultLogoutRequest(TICKET_ID,
            service,
            new URL(TEST_URL));
    final Event event = getLogoutEvent(Arrays.asList(logoutRequest));

    assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId());
    final List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext);
    assertEquals(1, list.size());
    final String url = (String) event.getAttributes().get(FrontChannelLogoutAction.DEFAULT_FLOW_ATTRIBUTE_LOGOUT_URL);
    assertTrue(url.startsWith(TEST_URL + '?' + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + '='));
    final byte[] samlMessage = CompressionUtils.decodeBase64ToByteArray(
            URLDecoder.decode(StringUtils.substringAfter(url, '?' + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + '='), "UTF-8"));
    final Inflater decompresser = new Inflater();
    decompresser.setInput(samlMessage);
    final byte[] result = new byte[1000];
    decompresser.inflate(result);
    decompresser.end();
    final String message = new String(result);
    assertTrue(message.startsWith("<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\""));
    assertTrue(message.contains("<samlp:SessionIndex>" + TICKET_ID + "</samlp:SessionIndex>"));
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:25,代码来源:FrontChannelLogoutActionTests.java

示例2: readChunkUnzip

import java.util.zip.Inflater; //导入依赖的package包/类
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
    try {
        do {
            int read = inflater.inflate(buffer, offset, length);
            if(read <= 0) {
                if(inflater.finished()) {
                    throw new EOFException();
                }
                if(inflater.needsInput()) {
                    refillInflater(inflater);
                } else {
                    throw new IOException("Can't inflate " + length + " bytes");
                }
            } else {
                offset += read;
                length -= read;
            }
        } while(length > 0);
    } catch (DataFormatException ex) {
        throw (IOException)(new IOException("inflate error").initCause(ex));
    }
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:23,代码来源:PNGDecoder.java

示例3: uncompress

import java.util.zip.Inflater; //导入依赖的package包/类
public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength) throws IOException
{
    Inflater inf = inflater.get();
    inf.reset();
    inf.setInput(input, inputOffset, inputLength);
    if (inf.needsInput())
        return 0;

    // We assume output is big enough
    try
    {
        return inf.inflate(output, outputOffset, maxOutputLength);
    }
    catch (DataFormatException e)
    {
        throw new IOException(e);
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:19,代码来源:DeflateCompressor.java

示例4: uncompress

import java.util.zip.Inflater; //导入依赖的package包/类
public static byte[] uncompress(final byte[] input) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Inflater decompressor = new Inflater();
    try {
        decompressor.setInput(input);
        final byte[] buf = new byte[2048];
        while (!decompressor.finished()) {
            int count = 0;
            try {
                count = decompressor.inflate(buf);
            } catch (DataFormatException e) {
                e.printStackTrace();
            }
            bos.write(buf, 0, count);
        }
    } finally {
        decompressor.end();
    }
    return bos.toByteArray();
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:21,代码来源:LogUtils.java

示例5: inflater

import java.util.zip.Inflater; //导入依赖的package包/类
/**
 * 解压缩.
 * 
 * @param inputByte
 *            byte[]数组类型的数据
 * @return 解压缩后的数据
 * @throws IOException
 */
public static byte[] inflater(final byte[] inputByte) throws IOException {
	int compressedDataLength = 0;
	Inflater compresser = new Inflater(false);
	compresser.setInput(inputByte, 0, inputByte.length);
	ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
	byte[] result = new byte[1024];
	try {
		while (!compresser.finished()) {
			compressedDataLength = compresser.inflate(result);
			if (compressedDataLength == 0) {
				break;
			}
			o.write(result, 0, compressedDataLength);
		}
	} catch (Exception ex) {
		System.err.println("Data format error!\n");
		ex.printStackTrace();
	} finally {
		o.close();
	}
	compresser.end();
	return o.toByteArray();
}
 
开发者ID:superkoh,项目名称:k-framework,代码行数:32,代码来源:SecureUtil.java

示例6: inflater

import java.util.zip.Inflater; //导入依赖的package包/类
/**
 * 解压缩.
 *
 * @param inputByte byte[]数组类型的数据
 * @return 解压缩后的数据
 * @throws IOException
 */
public static byte[] inflater(final byte[] inputByte) throws IOException {
    int compressedDataLength = 0;
    Inflater compresser = new Inflater(false);
    compresser.setInput(inputByte, 0, inputByte.length);
    ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
    byte[] result = new byte[1024];
    try {
        while (!compresser.finished()) {
            compressedDataLength = compresser.inflate(result);
            if (compressedDataLength == 0) {
                break;
            }
            o.write(result, 0, compressedDataLength);
        }
    } catch (Exception ex) {
        System.err.println("Data format error!\n");
        ex.printStackTrace();
    } finally {
        o.close();
    }
    compresser.end();
    return o.toByteArray();
}
 
开发者ID:howe,项目名称:nutz-pay,代码行数:31,代码来源:SDKUtil.java

示例7: verifyLogoutOneLogoutRequestNotAttempted

import java.util.zip.Inflater; //导入依赖的package包/类
@Test
public void verifyLogoutOneLogoutRequestNotAttempted() throws Exception {
    final LogoutRequest logoutRequest = new DefaultLogoutRequest(TICKET_ID,
            new SimpleWebApplicationServiceImpl(TEST_URL),
            new URL(TEST_URL));
    final Event event = getLogoutEvent(Arrays.asList(logoutRequest));

    assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId());
    final List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext);
    assertEquals(1, list.size());
    final String url = (String) event.getAttributes().get(FrontChannelLogoutAction.DEFAULT_FLOW_ATTRIBUTE_LOGOUT_URL);
    assertTrue(url.startsWith(TEST_URL + "?" + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + "="));
    final byte[] samlMessage = CompressionUtils.decodeBase64ToByteArray(
            URLDecoder.decode(StringUtils.substringAfter(url, "?" + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + "="), "UTF-8"));
    final Inflater decompresser = new Inflater();
    decompresser.setInput(samlMessage);
    final byte[] result = new byte[1000];
    decompresser.inflate(result);
    decompresser.end();
    final String message = new String(result);
    assertTrue(message.startsWith("<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\""));
    assertTrue(message.contains("<samlp:SessionIndex>" + TICKET_ID + "</samlp:SessionIndex>"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:24,代码来源:FrontChannelLogoutActionTests.java

示例8: b

import java.util.zip.Inflater; //导入依赖的package包/类
public static byte[] b(byte[] bArr) throws UnsupportedEncodingException, DataFormatException {
    int i = 0;
    if (bArr == null || bArr.length == 0) {
        return null;
    }
    Inflater inflater = new Inflater();
    inflater.setInput(bArr, 0, bArr.length);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    byte[] bArr2 = new byte[1024];
    while (!inflater.needsInput()) {
        int inflate = inflater.inflate(bArr2);
        byteArrayOutputStream.write(bArr2, i, inflate);
        i += inflate;
    }
    inflater.end();
    return byteArrayOutputStream.toByteArray();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:bs.java

示例9: inflate

import java.util.zip.Inflater; //导入依赖的package包/类
/**
 * Inflate the given byte array by {@link #INFLATED_ARRAY_LENGTH}.
 *
 * @param bytes the bytes
 * @return the array as a string with {@code UTF-8} encoding
 */
public static String inflate(final byte[] bytes) {
    final Inflater inflater = new Inflater(true);
    final byte[] xmlMessageBytes = new byte[INFLATED_ARRAY_LENGTH];

    final byte[] extendedBytes = new byte[bytes.length + 1];
    System.arraycopy(bytes, 0, extendedBytes, 0, bytes.length);
    extendedBytes[bytes.length] = 0;

    inflater.setInput(extendedBytes);

    try {
        final int resultLength = inflater.inflate(xmlMessageBytes);
        inflater.end();

        if (!inflater.finished()) {
            throw new RuntimeException("buffer not large enough.");
        }

        inflater.end();
        return new String(xmlMessageBytes, 0, resultLength, StandardCharsets.UTF_8);
    } catch (final DataFormatException e) {
        return null;
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:31,代码来源:CompressionUtils.java

示例10: verifyUserSig

import java.util.zip.Inflater; //导入依赖的package包/类
@Override
public boolean verifyUserSig(String identifier, String sig)throws QCloudException {
	try {
		Security.addProvider(new BouncyCastleProvider());
		
		//DeBaseUrl64 urlSig to json
		Base64 decoder = new Base64();

		byte [] compressBytes = Base64Url.base64DecodeUrl(sig.getBytes(Charset.forName("UTF-8")));
		
		//Decompression
		Inflater decompression =  new Inflater();
		decompression.setInput(compressBytes, 0, compressBytes.length);
		byte [] decompressBytes = new byte [1024];
		int decompressLength = decompression.inflate(decompressBytes);
		decompression.end();
		
		String jsonString = new String(Arrays.copyOfRange(decompressBytes, 0, decompressLength));
		
		//Get TLS.Sig from json
		JSONObject jsonObject= JSON.parseObject(jsonString);
		String sigTLS = jsonObject.getString("TLS.sig");
		
		//debase64 TLS.Sig to get serailString
		byte[] signatureBytes = decoder.decode(sigTLS.getBytes(Charset.forName("UTF-8")));
		
		String strSdkAppid = jsonObject.getString("TLS.sdk_appid");
		String sigTime = jsonObject.getString("TLS.time");
		String sigExpire = jsonObject.getString("TLS.expire_after");
		
		if (!imConfig.getSdkAppId().equals(strSdkAppid))
		{
			return false;
		}

		if ( System.currentTimeMillis()/1000 - Long.parseLong(sigTime) > Long.parseLong(sigExpire)) {
			return false;
		}
		
		//Get Serial String from json
		String SerialString = 
			"TLS.appid_at_3rd:" + 0 + "\n" +
			"TLS.account_type:" + 0 + "\n" +
			"TLS.identifier:" + identifier + "\n" + 
			"TLS.sdk_appid:" + imConfig.getSdkAppId() + "\n" + 
			"TLS.time:" + sigTime + "\n" + 
			"TLS.expire_after:" + sigExpire + "\n";
	
        Reader reader = new CharArrayReader(imConfig.getPublicKey().toCharArray());
        PEMParser  parser = new PEMParser(reader);
        JcaPEMKeyConverter converter = new JcaPEMKeyConverter();
        Object obj = parser.readObject();
        parser.close();
        PublicKey pubKeyStruct  = converter.getPublicKey((SubjectPublicKeyInfo) obj);

		Signature signature = Signature.getInstance("SHA256withECDSA","BC");
		signature.initVerify(pubKeyStruct);
		signature.update(SerialString.getBytes(Charset.forName("UTF-8")));
		return signature.verify(signatureBytes);
	}catch (Exception e) {
		throw new QCloudException(e);
	}
}
 
开发者ID:51wakeup,项目名称:wakeup-qcloud-sdk,代码行数:64,代码来源:DefaultQCloudClient.java

示例11: uncompress

import java.util.zip.Inflater; //导入依赖的package包/类
public static byte[] uncompress(byte[] input) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Inflater decompressor = new Inflater();
    try {
        decompressor.setInput(input);
        final byte[] buf = new byte[2048];
        while (!decompressor.finished()) {
            int count = 0;
            try {
                count = decompressor.inflate(buf);
            } catch (DataFormatException e) {
                e.printStackTrace();
            }
            bos.write(buf, 0, count);
        }
    } finally {
        decompressor.end();
    }
    return bos.toByteArray();
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:21,代码来源:LogUtils.java

示例12: deflate

import java.util.zip.Inflater; //导入依赖的package包/类
/** Descomprime un certificado contenido en el DNIe.
 * @param compressedCertificate Certificado comprimido en ZIP a partir del 9 byte.
 * @return Certificado codificado.
 * @throws IOException Cuando se produce un error en la descompresion del certificado. */
private static byte[] deflate(final byte[] compressedCertificate) throws IOException {
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    final Inflater decompressor = new Inflater();
    decompressor.setInput(compressedCertificate, 8, compressedCertificate.length - 8);
    final byte[] buf = new byte[1024];
    try {
        // Descomprimimos los datos
        while (!decompressor.finished()) {
            final int count = decompressor.inflate(buf);
            if (count == 0) {
                throw new DataFormatException();
            }
            buffer.write(buf, 0, count);
        }
        // Obtenemos los datos descomprimidos
        return buffer.toByteArray();
    }
    catch (final DataFormatException ex) {
        throw new IOException("Error al descomprimir el certificado: " + ex, ex); //$NON-NLS-1$
    }
}
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:26,代码来源:Dnie.java

示例13: createDecoder

import java.util.zip.Inflater; //导入依赖的package包/类
@Override
public OneWayCodec createDecoder() throws Exception {
    return new OneWayCodec() {
        private final Inflater inflater = new Inflater();

        @Override
        public byte[] code(final byte[] data) throws Exception {
            inflater.reset();
            final InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data), inflater);
            final ByteArrayOutputStream out = new ByteArrayOutputStream(data.length * 2);
            final byte[] b = new byte[512];
            for (;;) {
                final int i = in.read(b);
                if (i == -1) {
                    break;
                }
                out.write(b, 0, i);
            }
            return out.toByteArray();
        }
    };
}
 
开发者ID:szegedi,项目名称:spring-web-jsflow,代码行数:23,代码来源:CompressionCodec.java

示例14: decompress

import java.util.zip.Inflater; //导入依赖的package包/类
public static byte[] decompress(byte[] value) throws DataFormatException {

    ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);

    Inflater decompressor = new Inflater();

    try {
      decompressor.setInput(value);

      final byte[] buf = new byte[1024];
      while (!decompressor.finished()) {
        int count = decompressor.inflate(buf);
        bos.write(buf, 0, count);
      }
    } finally {
      decompressor.end();
    }

    return bos.toByteArray();
  }
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:21,代码来源:BiliDanmukuCompressionTools.java

示例15: decompress

import java.util.zip.Inflater; //导入依赖的package包/类
static byte[] decompress(byte[] bytesIn, int offset) throws Exception {
    Inflater inflater = new Inflater();
    inflater.setInput(bytesIn, offset, bytesIn.length - offset);
    ByteArrayOutputStream stream = new ByteArrayOutputStream(bytesIn.length - offset);
    byte[] buffer = new byte[1024];

    while (!inflater.finished()) {
        int count = inflater.inflate(buffer);
        stream.write(buffer, 0, count);
    }

    stream.close();

    byte[] bytesOut = stream.toByteArray();
    inflater.end();

    return bytesOut;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ZipDecompressor.java


注:本文中的java.util.zip.Inflater类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。