public void validate() throws MessageException {
  super.validate();
  AssociationSessionType type;
  try {
    type=getType();
    if (type.isVersion2() ^ isVersion2()) {
      throw new MessageException("Protocol verison mismatch between association " + "session type: " + type + " and AssociationResponse message type.",OpenIDException.ASSOC_ERROR);
    }
  }
 catch (  AssociationException e) {
    throw new MessageException("Error verifying association response validity.",OpenIDException.ASSOC_ERROR,e);
  }
  if (!isVersion2() && getAssociationType() == null) {
    throw new MessageException("assoc_type cannot be omitted in OpenID1 responses",OpenIDException.ASSOC_ERROR);
  }
  String macKey;
  if (type.getHAlgorithm() != null) {
    if (!hasParameter("dh_server_public") || !hasParameter("enc_mac_key")) {
      throw new MessageException("DH public key or encrypted MAC key missing.",OpenIDException.ASSOC_ERROR);
    }
 else     macKey=getParameterValue("enc_mac_key");
  }
 else {
    if (!hasParameter("mac_key")) {
      throw new MessageException("Missing MAC key.",OpenIDException.ASSOC_ERROR);
    }
 else     macKey=getParameterValue("mac_key");
  }
  int macSize=Base64.decodeBase64(macKey.getBytes()).length * 8;
  if (macSize != type.getKeySize()) {
    throw new MessageException("MAC key size: " + macSize + " doesn't match the association/session type: "+ type,OpenIDException.ASSOC_ERROR);
  }
}

public void validate ( ) throws MessageException { super . validate ( ) ; AssociationSessionType type ; try { type = getType ( ) ; if ( type . isVersion2 ( ) ^ isVersion2 ( ) ) { throw new MessageException ( "Protocol verison mismatch between association " + "session type: " + type + " and AssociationResponse message type." , OpenIDException . ASSOC_ERROR ) ; } } catch ( AssociationException e ) { throw new MessageException ( "Error verifying association response validity." , OpenIDException . ASSOC_ERROR , e ) ; } if ( ! isVersion2 ( ) && getAssociationType ( ) == null ) { throw new MessageException ( "assoc_type cannot be omitted in OpenID1 responses" , OpenIDException . ASSOC_ERROR ) ; } String macKey ; if ( type . getHAlgorithm ( ) != null ) { if ( ! hasParameter ( "dh_server_public" ) || ! hasParameter ( "enc_mac_key" ) ) { throw new MessageException ( "DH public key or encrypted MAC key missing." , OpenIDException . ASSOC_ERROR ) ; } else macKey = getParameterValue ( "enc_mac_key" ) ; } else { if ( ! hasParameter ( "mac_key" ) ) { throw new MessageException ( "Missing MAC key." , OpenIDException . ASSOC_ERROR ) ; } else macKey = getParameterValue ( "mac_key" ) ; } int macSize = Base64 . decodeBase64 ( macKey . getBytes ( ) ) . length * 8 ; if ( macSize != type . getKeySize ( ) ) { throw new MessageException ( "MAC key size: " + macSize + " doesn't match the association/session type: " + type , OpenIDException . ASSOC_ERROR ) ; } }
checks if the message is a valid openid association response . .
