* @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);