/** * Get auth plugin data. * * @return auth plugin data */ public byte[] getAuthPluginData() { return Bytes.concat(authPluginDataPart1, authPluginDataPart2); } }
/** * Get auth plugin data. * * @return auth plugin data */ public byte[] getAuthPluginData() { return Bytes.concat(authPluginDataPart1, authPluginDataPart2); } }
@Override public byte[] getCacheKey() { byte[] cacheKey = new byte[]{ExtractionCacheHelper.CACHE_TYPE_ID_CASCADE}; return Bytes.concat(cacheKey, chainedExtractionFn.getCacheKey()); }
public String buildCacheKey() { return UUID.nameUUIDFromBytes( Bytes.concat(kind.getBytes(), identifier, password)).toString(); }
/** * Generates a symmetric encryption key from the master secret * * @param masterSecret * @param clientRandom * @param serverRandom * @return */ public static SecretKeySpec generateSymmetricKey(byte[] masterSecret, byte[] clientRandom, byte[] serverRandom) { return new SecretKeySpec(SecretGenerator.generate(masterSecret, SecretGenerator.KEY_EXPANSION, Bytes.concat(clientRandom, serverRandom), IdentityConstants.SYMMETRIC_ENCRYPTION_KEY_LENGTH), IdentityConstants.SYMMETRIC_ENCRYPTION_ALGORITHM); }
/** * Generates the master secret, a common secret between the server and client used to generate a symmetric encryption key * * @param preMasterSecret * @param clientRandom * @param serverRandom * @return */ public static byte[] generateMasterSecret(byte[] preMasterSecret, byte[] clientRandom, byte[] serverRandom) { return SecretGenerator.generate(preMasterSecret, SecretGenerator.MASTER_SECRET_LABEL, Bytes.concat(clientRandom, serverRandom), SecretGenerator.MASTER_SECRET_LENGTH); }
public byte[] getCacheKey() { byte[] fnCacheKey = fn.getCacheKey(); return (child != null) ? Bytes.concat(fnCacheKey, child.getCacheKey()) : fnCacheKey; }
public void testConcat() { assertTrue(Arrays.equals(EMPTY, Bytes.concat())); assertTrue(Arrays.equals(EMPTY, Bytes.concat(EMPTY))); assertTrue(Arrays.equals(EMPTY, Bytes.concat(EMPTY, EMPTY, EMPTY))); assertTrue(Arrays.equals(ARRAY1, Bytes.concat(ARRAY1))); assertNotSame(ARRAY1, Bytes.concat(ARRAY1)); assertTrue(Arrays.equals(ARRAY1, Bytes.concat(EMPTY, ARRAY1, EMPTY))); assertTrue( Arrays.equals( new byte[] {(byte) 1, (byte) 1, (byte) 1}, Bytes.concat(ARRAY1, ARRAY1, ARRAY1))); assertTrue( Arrays.equals( new byte[] {(byte) 1, (byte) 2, (byte) 3, (byte) 4}, Bytes.concat(ARRAY1, ARRAY234))); }
/** * Get request body. * * @return Bytes with the request body contents. * @throws IOException In case stream reqding fails. */ public byte[] getRequestBody() throws IOException { final byte[] resultBytes; if (bufferFilled) { // 已经填入则直接返回 resultBytes = Arrays.copyOf(requestBody, requestBody.length); } else { // 未填入则进行处理 InputStream inputStream = super.getInputStream(); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { requestBody = Bytes.concat(this.requestBody, Arrays.copyOfRange(buffer, 0, bytesRead)); } // 置标志位 bufferFilled = true; resultBytes = Arrays.copyOf(requestBody, requestBody.length); } return resultBytes; }
/** * Create a set of data to sign to bu * * @param serverHello * @param clientHello * @return */ public static byte[] getSignatureData(NetData.HandshakeHello serverHello, NetData.HandshakeHello clientHello) { return Bytes.concat(serverHello.toByteArray(), clientHello.toByteArray()); } }
/** * Generates a client hello from clientRandom file, time, and the public client certificate. Sends the clients hello and certificate back to the server via network channel. * @param helloMessage Message from server to client. * @param ctx Channel Handler Context. */ private void sendCertificate(NetData.HandshakeHello helloMessage, ChannelHandlerContext ctx) { logger.info("Sending client certificate"); PublicIdentityCertificate pubClientCert = identity.getPlayerPublicCertificate(); clientHello = NetData.HandshakeHello.newBuilder() .setRandom(ByteString.copyFrom(clientRandom)) .setCertificate(NetMessageUtil.convert(pubClientCert)) .setTimestamp(System.currentTimeMillis()) .build(); byte[] dataToSign = Bytes.concat(helloMessage.toByteArray(), clientHello.toByteArray()); byte[] signature = identity.getPlayerPrivateCertificate().sign(dataToSign); ctx.getChannel().write(NetData.NetMessage.newBuilder() .setHandshakeHello(clientHello) .setHandshakeVerification(NetData.HandshakeVerification.newBuilder() .setSignature(ByteString.copyFrom(signature))) .build()); }
public static byte[] add(byte[] b1, byte[] b2, byte[] b3) { return Bytes.concat(b1, b2, b3); }
@Test public void grpcWeb() throws Exception { final HttpClient client = HttpClient.of(server.httpUri("/")); final AggregatedHttpMessage response = client.execute( HttpHeaders.of(HttpMethod.POST, UnitTestServiceGrpc.getStaticUnaryCallMethod().getFullMethodName()) .set(HttpHeaderNames.CONTENT_TYPE, "application/grpc-web"), GrpcTestUtil.uncompressedFrame(GrpcTestUtil.requestByteBuf())).aggregate().get(); final byte[] serializedStatusHeader = "grpc-status: 0\r\n".getBytes(StandardCharsets.US_ASCII); final byte[] serializedTrailers = Bytes.concat( new byte[] { ArmeriaServerCall.TRAILERS_FRAME_HEADER }, Ints.toByteArray(serializedStatusHeader.length), serializedStatusHeader); assertThat(response.content().array()).containsExactly( Bytes.concat( GrpcTestUtil.uncompressedFrame( GrpcTestUtil.protoByteBuf(RESPONSE_MESSAGE)), serializedTrailers)); checkRequestLog((rpcReq, rpcRes, grpcStatus) -> { assertThat(rpcReq.method()).isEqualTo("armeria.grpc.testing.UnitTestService/StaticUnaryCall"); assertThat(rpcReq.params()).containsExactly(REQUEST_MESSAGE); assertThat(rpcRes.get()).isEqualTo(RESPONSE_MESSAGE); }); }
@Override public List<byte[]> getPartitions(int numberRanges) { List<byte[]> ret = Lists.newArrayList(); for (byte[] bs : nextPartition.getPartitions(numberRanges)) { ret.add(Bytes.concat(prefix, bs)); } return ret; }
public static byte[] encodeSizedBytes(byte[] bytes) { byte[] len = encodeVarLong(bytes.length); return Bytes.concat(len, bytes); }
public static byte[] encodeVarLongAndFixedLong(long realmId, long v2) { byte[] b1 = encodeVarLong(realmId); byte[] b2 = PtBytes.toBytes(v2); return Bytes.concat(b1, b2); }
public static final byte[] getBytesForTableRef(TableReference tableRef) { byte[] nameSpace = EncodingUtils.encodeVarString(tableRef.getNamespace().getName()); byte[] table = PtBytes.toBytes(tableRef.getTablename()); return Bytes.concat(nameSpace, table); }
@Test public void testDeserializeRowFromJsonMap() throws Exception { JsonNode jsonNode = new ObjectMapper().readTree("{\"age\":68, \"name\":\"Smeagol\"}"); byte[] row = AtlasDeserializers.deserializeRow(NAME_METADATA_DESCRIPTION, jsonNode); byte[] expectedRow = Bytes.concat(ValueType.FIXED_LONG.convertFromString("68"), ValueType.STRING.convertFromString("Smeagol")); Assert.assertArrayEquals(expectedRow, row); } }
@Test public void testDeserializeRowFromJsonList() throws Exception { JsonNode jsonNode = new ObjectMapper().readTree("[68, \"Smeagol\"]"); byte[] row = AtlasDeserializers.deserializeRow(NAME_METADATA_DESCRIPTION, jsonNode); byte[] expectedRow = Bytes.concat(ValueType.FIXED_LONG.convertFromString("68"), ValueType.STRING.convertFromString("Smeagol")); Assert.assertArrayEquals(expectedRow, row); }