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 17 package com.google.polo.pairing.message; 18 19 import com.google.polo.pairing.PoloUtil; 20 21 import java.util.Arrays; 22 23 /** 24 * Object implementing the internal representation of the protocol message 25 * 'SECRET'. 26 */ 27 public class SecretMessage extends PoloMessage { 28 29 private byte[] mSecret; 30 SecretMessage(byte[] secret)31 public SecretMessage(byte[] secret) { 32 super(PoloMessage.PoloMessageType.SECRET); 33 mSecret = secret; 34 } 35 getSecret()36 public byte[] getSecret() { 37 return mSecret; 38 } 39 40 @Override toString()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 equals(Object obj)52 public boolean equals(Object obj) { 53 if (this == obj) { 54 return true; 55 } 56 57 if (!(obj instanceof SecretMessage)) { 58 return false; 59 } 60 61 SecretMessage other = (SecretMessage) obj; 62 return Arrays.equals(mSecret, other.mSecret); 63 } 64 65 } 66