Package com.google.dataconnector.protocol.proto.SdcFrame

Examples of com.google.dataconnector.protocol.proto.SdcFrame.AuthorizationInfo


            // Authorization step
            FrameInfo frameInfo = getFrameReceiver().readOneFrame();

            if (frameInfo.getType() == FrameInfo.Type.AUTHORIZATION) {
                AuthorizationInfo authorizationRequest = AuthorizationInfo
                        .parseFrom(frameInfo.getPayload());
                setKey(authorizationRequest.getEmail() + ":"
                        + authorizationRequest.getPassword());

                AuthorizationInfo authorizationResponse = AuthorizationInfo
                        .newBuilder().setResult(ResultCode.OK).build();

                getFrameSender().sendFrame(FrameInfo.Type.AUTHORIZATION,
                        authorizationResponse.toByteString());

                // Register frame dispatchers
                getFrameReceiver().registerDispatcher(Type.FETCH_REQUEST, this);
                getFrameReceiver().registerDispatcher(Type.REGISTRATION, this);
                getFrameReceiver().registerDispatcher(Type.HEALTH_CHECK, this);
View Full Code Here


    super.tearDown();
  }

  public void testAuthorizeSuccess() throws Exception {

    AuthorizationInfo authInfoResponse = AuthorizationInfo.newBuilder()
        .setResult(AuthorizationInfo.ResultCode.OK)
        .build();
    FrameInfo frameInfoResponse = FrameInfo.newBuilder()
        .setType(FrameInfo.Type.AUTHORIZATION)
        .setPayload(authInfoResponse.toByteString())
        .build();

    mockFrameReceiver = EasyMock.createMock(FrameReceiver.class);
    mockFrameReceiver.readOneFrame();
    EasyMock.expectLastCall().andReturn(frameInfoResponse);
View Full Code Here

    EasyMock.verify(mockFrameReceiver, mockFrameSender);
  }

  public void testAuthorizeFail() throws Exception {

    AuthorizationInfo authInfoResponse = AuthorizationInfo.newBuilder()
        .setResult(AuthorizationInfo.ResultCode.ACCESS_DENIED)
        .build();
    FrameInfo frameInfoResponse = FrameInfo.newBuilder()
        .setType(FrameInfo.Type.AUTHORIZATION)
        .setPayload(authInfoResponse.toByteString())
        .build();

    mockFrameReceiver = EasyMock.createMock(FrameReceiver.class);
    mockFrameReceiver.readOneFrame();
    EasyMock.expectLastCall().andReturn(frameInfoResponse);
View Full Code Here

      FrameInfo actualFrameInfo = (FrameInfo) actual;
      if (expectedType != actualFrameInfo.getType()) {
        return false;
      }
      try {
        AuthorizationInfo actualAuthInfo = AuthorizationInfo.parseFrom(
            actualFrameInfo.getPayload());
        if (!actualAuthInfo.getEmail().equals(expectedEmail)) {
          return false;
        } else if (!actualAuthInfo.getPassword().equals(expectedPassword)) {
          return false;
        }
        // Everything matches.
        return true;
      } catch (InvalidProtocolBufferException e) {
View Full Code Here

   * @returns true if successfully logged on or false otherwise.
   */
  boolean authorize() {
    try {
      // Authenticate
      final AuthorizationInfo authInfoRequest = AuthorizationInfo.newBuilder()
          .setEmail(localConf.getUser() + "@" + localConf.getDomain())
          .setPassword(localConf.getPassword())
          .build();
      final FrameInfo authReqRawFrame = FrameInfo.newBuilder()
          .setPayload(authInfoRequest.toByteString())
          .setType(FrameInfo.Type.AUTHORIZATION)
          .build();
      frameSender.sendFrame(authReqRawFrame);
      final FrameInfo authRespRawFrame = frameReceiver.readOneFrame();
      final AuthorizationInfo authInfoResponse = AuthorizationInfo.parseFrom(
          authRespRawFrame.getPayload());
      if (authInfoResponse.getResult() != AuthorizationInfo.ResultCode.OK) {
        LOG.error("Auth Result: " + authInfoResponse.getResult().toString());
        LOG.error("Auth Error Message: " + authInfoResponse.getStatusMessage().toString());
        return false;
      }
      return true;
    } catch (FramingException e) {
      LOG.warn("Frame error", e);
View Full Code Here

TOP

Related Classes of com.google.dataconnector.protocol.proto.SdcFrame.AuthorizationInfo

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.