Refine search
@Override public int read(byte[] buffer, long offset, int length) throws ProxyCacheException { if (offset >= data.length) { return -1; } if (offset > Integer.MAX_VALUE) { throw new IllegalArgumentException("Too long offset for memory cache " + offset); } return new ByteArrayInputStream(data).read(buffer, (int) offset, length); }
public void toObject(byte[] bytes) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(bytes); int len = in.read(); byte[] idBytes = new byte[len]; in.read(idBytes); this.id = new String(idBytes); len = in.read(); byte[] passBytes = new byte[len]; in.read(passBytes); this.password = new String(passBytes); len = in.read(); byte[] emailBytes = new byte[len]; in.read(emailBytes); this.email = new String(emailBytes); len = in.read(); byte[] groupBytes = new byte[len]; in.read(groupBytes); this.group = new String(groupBytes); in.close(); }
public void toObject(byte[] bytes) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(bytes); int len = in.read(); byte[] idBytes = new byte[len]; in.read(idBytes); this.id = new String(idBytes); len = in.read(); byte[] passBytes = new byte[len]; in.read(passBytes); this.password = new String(passBytes); len = in.read(); byte[] emailBytes = new byte[len]; in.read(emailBytes); this.email = new String(emailBytes); len = in.read(); byte[] groupBytes = new byte[len]; in.read(groupBytes); this.group = new String(groupBytes); in.close(); }
public void toObject(byte[] bytes) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(bytes); int len = in.read(); byte[] idBytes = new byte[len]; in.read(idBytes); this.id = new String(idBytes); len = in.read(); byte[] passBytes = new byte[len]; in.read(passBytes); this.password = new String(passBytes); len = in.read(); byte[] emailBytes = new byte[len]; in.read(emailBytes); this.email = new String(emailBytes); len = in.read(); byte[] groupBytes = new byte[len]; in.read(groupBytes); this.group = new String(groupBytes); in.close(); }
public void toObject(byte[] bytes) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(bytes); int len = in.read(); byte[] idBytes = new byte[len]; in.read(idBytes); this.id = new String(idBytes); len = in.read(); byte[] passBytes = new byte[len]; in.read(passBytes); this.password = new String(passBytes); len = in.read(); byte[] emailBytes = new byte[len]; in.read(emailBytes); this.email = new String(emailBytes); len = in.read(); byte[] groupBytes = new byte[len]; in.read(groupBytes); this.group = new String(groupBytes); in.close(); }
public void toObject(byte[] bytes) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(bytes); int len = in.read(); byte[] idBytes = new byte[len]; in.read(idBytes); this.id = new String(idBytes); len = in.read(); byte[] passBytes = new byte[len]; in.read(passBytes); this.password = new String(passBytes); len = in.read(); byte[] emailBytes = new byte[len]; in.read(emailBytes); this.email = new String(emailBytes); len = in.read(); byte[] groupBytes = new byte[len]; in.read(groupBytes); this.group = new String(groupBytes); in.close(); }
@Override public Integer answer(InvocationOnMock invocation) throws Throwable { byte[] bytes = (byte[]) invocation.getArguments()[0]; ByteArrayInputStream inputStream = new ByteArrayInputStream(TEXT.getBytes()); return inputStream.read(bytes); } });
private EncryptionMetadata extractEncryptionMetadata(byte[] encryptedRecord) throws EncryptionException, IOException, ClassNotFoundException { if (encryptedRecord == null || encryptedRecord.length < MIN_METADATA_LENGTH) { throw new EncryptionException("The encrypted record is too short to contain the metadata"); } // Skip the first byte (SENTINEL) and don't need to copy all the serialized record ByteArrayInputStream bais = new ByteArrayInputStream(encryptedRecord); bais.read(); try (ObjectInputStream ois = new ObjectInputStream(bais)) { return (EncryptionMetadata) ois.readObject(); } }
public static byte[] decrypt(BigInteger privKey, byte[] cipher, byte[] macData) throws IOException, InvalidCipherTextException { byte[] plaintext; ByteArrayInputStream is = new ByteArrayInputStream(cipher); byte[] ephemBytes = new byte[2*((CURVE.getCurve().getFieldSize()+7)/8) + 1]; is.read(ephemBytes); ECPoint ephem = CURVE.getCurve().decodePoint(ephemBytes); byte[] IV = new byte[KEY_SIZE /8]; is.read(IV); byte[] cipherBody = new byte[is.available()]; is.read(cipherBody); plaintext = decrypt(ephem, privKey, IV, cipherBody, macData); return plaintext; }
public byte[] decrypt(byte[] encrypt) throws EncryptionServiceException { try { byte[] myNonce = new byte[GCM_IV_NONCE_SIZE_BYTES]; byte[] mySalt = new byte[PBKDF2_SALT_SIZE_BYTES]; ByteArrayInputStream fileInputStream = new ByteArrayInputStream(encrypt); fileInputStream.read(myNonce); fileInputStream.read(mySalt); SecretKey key = new SecretKeySpec(generateKey(mySalt), CIPHER); Cipher myCipher = Cipher.getInstance(CIPHERSCHEME); GCMParameterSpec spec = new GCMParameterSpec(GCM_AUTHENTICATION_TAG_SIZE_BITS, myNonce); myCipher.init(Cipher.DECRYPT_MODE, key, spec); return myCipher.doFinal(Arrays.copyOfRange(encrypt, GCM_IV_NONCE_SIZE_BYTES + PBKDF2_SALT_SIZE_BYTES, encrypt.length)); } catch (Exception e) { logger.error("Decryption failed", e); throw new EncryptionServiceException(e); } }
@Override public int read() throws IOException { if (byteArrayInputStream == null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream stream = null; try { try { stream = requestContext.getWorkers().writeTo( entity, entity.getClass(), null, null, response.getMediaType(), response.getMetadata(), requestContext.getPropertiesDelegate(), baos, Collections.<WriterInterceptor>emptyList()); } finally { if (stream != null) { stream.close(); } } } catch (IOException e) { // ignore } byteArrayInputStream = new ByteArrayInputStream(baos.toByteArray()); } return byteArrayInputStream.read(); } };
input = new ByteArrayInputStream(cachedBytes.toByteArray()); return input.read();
@Override public int read() throws IOException { if (byteArrayInputStream == null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream stream = null; try { try { stream = requestContext.getWorkers().writeTo( entity, entity.getClass(), null, null, response.getMediaType(), response.getMetadata(), requestContext.getPropertiesDelegate(), baos, Collections.<WriterInterceptor>emptyList()); } finally { if (stream != null) { stream.close(); } } } catch (IOException e) { // ignore } byteArrayInputStream = new ByteArrayInputStream(baos.toByteArray()); } return byteArrayInputStream.read(); } };
try (ByteArrayInputStream in = new ByteArrayInputStream(content)) { try (OutputStream out = response.getOutputStream()) { while ((len = in.read(buf)) != -1) { out.write(buf, 0, len);
@Test public void getInputStreamReadBytePromotion() throws Exception { byte[] bytes = new byte[] { -1 }; this.os.write(bytes); InputStream inputStream = this.os.getInputStream(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); assertEquals(bais.read(), inputStream.read()); }
pending = new ByteArrayInputStream(buf, 0, recvLen); } else if (!retrieveUnconfirmedRead(true /*blocking*/)) { return pending.read(into, off, len);
@Override public int read() throws IOException { if (byteArrayInputStream == null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream stream = null; try { try { stream = requestContext.getWorkers().writeTo( entity, entity.getClass(), null, null, response.getMediaType(), response.getMetadata(), requestContext.getPropertiesDelegate(), baos, Collections.<WriterInterceptor>emptyList()); } finally { if (stream != null) { stream.close(); } } } catch (IOException e) { // ignore } byteArrayInputStream = new ByteArrayInputStream(baos.toByteArray()); } return byteArrayInputStream.read(); } };
public static byte[] decrypt(BigInteger prv, byte[] cipher) throws InvalidCipherTextException, IOException { ByteArrayInputStream is = new ByteArrayInputStream(cipher); byte[] ephemBytes = new byte[2*((curve.getCurve().getFieldSize()+7)/8) + 1]; is.read(ephemBytes); ECPoint ephem = curve.getCurve().decodePoint(ephemBytes); byte[] IV = new byte[KEY_SIZE /8]; is.read(IV); byte[] cipherBody = new byte[is.available()]; is.read(cipherBody); EthereumIESEngine iesEngine = makeIESEngine(false, ephem, prv, IV); byte[] message = iesEngine.processBlock(cipherBody, 0, cipherBody.length); return message; }
final ByteArrayInputStream bais = new ByteArrayInputStream(resultB); final int type = bais.read(); if (type == 0) { final int version = bais.read(); final byte sha[] = readBytes(bais, 64); final long now = readLong(bais); final int version = bais.read(); final byte sha[] = readBytes(bais, 64); final long now = readLong(bais);
private byte[] adjustDebugInfoItemSTM(byte[] infoSTM) { ByteArrayInputStream bais = new ByteArrayInputStream(infoSTM); final ByteArrayInputStream baisRef = bais; ByteInput inAdapter = new ByteInput() { int opcode = bais.read() & 0xFF; baos.write(opcode); switch (opcode) {