1/* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.google.polo.pairing.message; 18 19import com.google.polo.pairing.PoloUtil; 20 21import java.util.Arrays; 22 23/** 24 * Object implementing the internal representation of the protocol message 25 * 'SECRET_ACK'. 26 */ 27public class SecretAckMessage extends PoloMessage { 28 29 private byte[] mSecret; 30 31 public SecretAckMessage(byte[] secret) { 32 super(PoloMessage.PoloMessageType.SECRET_ACK); 33 mSecret = secret; 34 } 35 36 public byte[] getSecret() { 37 return mSecret; 38 } 39 40 @Override 41 public String toString() { 42 StringBuilder ret = new StringBuilder(); 43 ret.append("["); 44 ret.append(getType()); 45 ret.append(" secret="); 46 ret.append(PoloUtil.bytesToHexString(mSecret)); 47 ret.append("]"); 48 return ret.toString(); 49 } 50 51 @Override 52 public boolean equals(Object obj) { 53 if (this == obj) { 54 return true; 55 } 56 57 if (!(obj instanceof SecretAckMessage)) { 58 return false; 59 } 60 61 SecretAckMessage other = (SecretAckMessage) obj; 62 return Arrays.equals(mSecret, other.mSecret); 63 } 64 65} 66