Package com.google.dataconnector.util

Examples of com.google.dataconnector.util.SdcKeysManager


      .setId("requestId").setStrategy("HttpClient")
      .setResource("http://www.google.com").build();
   
      String sessionId = UUID.randomUUID().toString();

      SdcKeysManager sm = new SdcKeysManager();
      sm.storeSessionKey(sessionId,
          SessionEncryption.JCE_ALGO, SessionEncryption.newKeyBytes());
   
    FrameInfo frameInfo = FrameInfo.newBuilder()
      .setSessionId(sessionId)
      .setPayload(sm.getSessionEncryption().encrypt(request.toByteString())).build();

    FetchRequestHandler handler = new FetchRequestHandler(
        sm,
        EasyMock.createMock(ThreadPoolExecutor.class),
        EasyMock.createMock(Injector.class),
        EasyMock.createMock(ClockUtil.class));

    FetchRequest parsed = sm.getSessionEncryption().getFrom(frameInfo,
        new SessionEncryption.Parse<FetchRequest>() {
      public FetchRequest parse(ByteString s) throws InvalidProtocolBufferException {
        return FetchRequest.parseFrom(s);
      }
    });
    assertEquals(request, parsed);

      FrameInfo frameInfo2 = FrameInfo.newBuilder()
        .setSessionId(UUID.randomUUID().toString())
        .setPayload(sm.getSessionEncryption().encrypt(request.toByteString())).build();

      FetchRequest parsed2 = sm.getSessionEncryption().getFrom(frameInfo2,
          new SessionEncryption.Parse<FetchRequest>() {
        public FetchRequest parse(ByteString s) throws InvalidProtocolBufferException {
          return FetchRequest.parseFrom(s);
        }
      });
View Full Code Here


  }

    public void testSendReply() throws Exception {
      String sessionId = UUID.randomUUID().toString();

      SdcKeysManager sm = new SdcKeysManager();
      sm.storeSessionKey(sessionId,
          SessionEncryption.JCE_ALGO, SessionEncryption.newKeyBytes());

      FetchReply reply = FetchReply.newBuilder()
        .setId(UUID.randomUUID().toString())
        .setStatus(0).build();
     
      FetchRequestHandler handler = new FetchRequestHandler(
          sm,
          EasyMock.createMock(ThreadPoolExecutor.class),
          EasyMock.createMock(Injector.class),
          EasyMock.createMock(ClockUtil.class));
     
      FrameInfo frame = sm.getSessionEncryption().toFrameInfo(
          FrameInfo.Type.FETCH_REQUEST, reply);
     
      assertTrue(frame.hasSessionId());
      assertEquals(reply.toByteString(), sm.getSessionEncryption().decrypt(frame.getPayload()));
    }
View Full Code Here

TOP

Related Classes of com.google.dataconnector.util.SdcKeysManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.