diff --git a/briar-core/src/main/java/org/briarproject/briar/introduction/IntroduceeEngine.java b/briar-core/src/main/java/org/briarproject/briar/introduction/IntroduceeEngine.java index e7c213d9998b97e2427231af7ea1ff759394873c..f93fb0aa4164320e717e9b24f8569cd418acad52 100644 --- a/briar-core/src/main/java/org/briarproject/briar/introduction/IntroduceeEngine.java +++ b/briar-core/src/main/java/org/briarproject/briar/introduction/IntroduceeEngine.java @@ -266,14 +266,6 @@ class IntroduceeEngine m.put(SESSION_ID, localState.getRaw(SESSION_ID)); m.put(MAC, localState.getRaw(OUR_MAC)); m.put(SIGNATURE, localState.getRaw(OUR_SIGNATURE)); - - if (LOG.isLoggable(INFO)) { - LOG.info("Sending ACK " + " to " + - localState.getString(INTRODUCER) + " for " + - localState.getString(NAME) + " with session ID " + - Arrays.hashCode(m.getRaw(SESSION_ID)) + " in group " + - Arrays.hashCode(m.getRaw(GROUP_ID))); - } return m; } @@ -285,14 +277,9 @@ class IntroduceeEngine try { LOG.info("Sending " + (localState.getBoolean(ACCEPT) ? "accept " : "decline ") + - "response in state " + state.name() + - " to " + localState.getString(INTRODUCER) + - " for " + localState.getString(NAME) + " with session ID " + - Arrays.hashCode(msg.getRaw(SESSION_ID)) + " in group " + - Arrays.hashCode(msg.getRaw(GROUP_ID)) + ". " + - "Moving on to state " + - getState(localState.getLong(STATE)).name() - ); + "response in state " + state.name()); + LOG.info("Moving on to state " + + getState(localState.getLong(STATE)).name()); } catch (FormatException e) { if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); } @@ -304,25 +291,14 @@ class IntroduceeEngine if (!LOG.isLoggable(INFO)) return; - try { - String t = "unknown"; - if (type == TYPE_REQUEST) t = "Introduction"; - else if (type == TYPE_RESPONSE) t = "Response"; - else if (type == TYPE_ACK) t = "ACK"; - else if (type == TYPE_ABORT) t = "Abort"; - - LOG.info("Received " + t + " in state " + currentState.name() + - " from " + localState.getString(INTRODUCER) + - (localState.containsKey(NAME) ? - " related to " + localState.getString(NAME) : "") + - " with session ID " + - Arrays.hashCode(msg.getRaw(SESSION_ID)) + " in group " + - Arrays.hashCode(msg.getRaw(GROUP_ID)) + ". " + - "Moving on to state " + nextState.name() - ); - } catch (FormatException e) { - if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); - } + String t = "unknown"; + if (type == TYPE_REQUEST) t = "Introduction"; + else if (type == TYPE_RESPONSE) t = "Response"; + else if (type == TYPE_ACK) t = "ACK"; + else if (type == TYPE_ABORT) t = "Abort"; + + LOG.info("Received " + t + " in state " + currentState.name()); + LOG.info("Moving on to state " + nextState.name()); } @Override @@ -368,11 +344,9 @@ class IntroduceeEngine IntroduceeProtocolState currentState, BdfDictionary localState) throws FormatException { - if (LOG.isLoggable(WARNING)) { - LOG.warning("Aborting protocol session " + - Arrays.hashCode(localState.getRaw(SESSION_ID)) + - " in state " + currentState.name()); - } + if (LOG.isLoggable(WARNING)) + LOG.warning("Aborting protocol session in state " + + currentState.name()); localState.put(STATE, ERROR.getValue()); localState.put(TASK, TASK_ABORT); diff --git a/briar-core/src/main/java/org/briarproject/briar/introduction/IntroducerEngine.java b/briar-core/src/main/java/org/briarproject/briar/introduction/IntroducerEngine.java index ea08aebd77271de3748ac9410a1c7d87b15b659e..b0cffd95ba3596378b4b7fa32892be21554b14e2 100644 --- a/briar-core/src/main/java/org/briarproject/briar/introduction/IntroducerEngine.java +++ b/briar-core/src/main/java/org/briarproject/briar/introduction/IntroducerEngine.java @@ -114,7 +114,7 @@ class IntroducerEngine } msg1.put(MESSAGE_TIME, localAction.getLong(MESSAGE_TIME)); messages.add(msg1); - logLocalAction(currentState, localState, msg1); + logLocalAction(currentState, localState); BdfDictionary msg2 = new BdfDictionary(); msg2.put(TYPE, TYPE_REQUEST); msg2.put(SESSION_ID, localState.getRaw(SESSION_ID)); @@ -126,7 +126,7 @@ class IntroducerEngine } msg2.put(MESSAGE_TIME, localAction.getLong(MESSAGE_TIME)); messages.add(msg2); - logLocalAction(currentState, localState, msg2); + logLocalAction(currentState, localState); List<Event> events = Collections.emptyList(); return new StateUpdate<BdfDictionary, BdfDictionary>(false, @@ -214,19 +214,13 @@ class IntroducerEngine } private void logLocalAction(IntroducerProtocolState state, - BdfDictionary localState, BdfDictionary msg) { + BdfDictionary localState) { if (!LOG.isLoggable(INFO)) return; - try { - String to = getMessagePartner(localState, msg); - LOG.info("Sending introduction request in state " + state.name() + - " to " + to + " with session ID " + - Arrays.hashCode(msg.getRaw(SESSION_ID)) + " in group " + - Arrays.hashCode(msg.getRaw(GROUP_ID)) + ". " + - "Moving on to state " + - getState(localState.getLong(STATE)).name() - ); + LOG.info("Sending introduction request in state " + state.name()); + LOG.info("Moving on to state " + + getState(localState.getLong(STATE)).name()); } catch (FormatException e) { if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); } @@ -235,28 +229,17 @@ class IntroducerEngine private void logMessageReceived(IntroducerProtocolState currentState, IntroducerProtocolState nextState, BdfDictionary localState, int type, BdfDictionary msg) { + if (!LOG.isLoggable(INFO)) return; - try { - String t = "unknown"; - if (type == TYPE_REQUEST) t = "Introduction"; - else if (type == TYPE_RESPONSE) t = "Response"; - else if (type == TYPE_ACK) t = "ACK"; - else if (type == TYPE_ABORT) t = "Abort"; - - String from = getMessagePartner(localState, msg); - String to = getOtherContact(localState, msg); - - LOG.info("Received " + t + " in state " + currentState.name() + - " from " + - from + " to " + to + " with session ID " + - Arrays.hashCode(msg.getRaw(SESSION_ID)) + " in group " + - Arrays.hashCode(msg.getRaw(GROUP_ID)) + ". " + - "Moving on to state " + nextState.name() - ); - } catch (FormatException e) { - if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); - } + String t = "unknown"; + if (type == TYPE_REQUEST) t = "Introduction"; + else if (type == TYPE_RESPONSE) t = "Response"; + else if (type == TYPE_ACK) t = "ACK"; + else if (type == TYPE_ABORT) t = "Abort"; + + LOG.info("Received " + t + " in state " + currentState.name()); + LOG.info("Moving on to state " + nextState.name()); } private List<BdfDictionary> forwardMessage(BdfDictionary localState, @@ -270,11 +253,6 @@ class IntroducerEngine msg.put(GROUP_ID, localState.getRaw(GROUP_ID_1)); } - if (LOG.isLoggable(INFO)) { - LOG.info("Forwarding message to group " + - Arrays.hashCode(msg.getRaw(GROUP_ID))); - } - return Collections.singletonList(msg); } @@ -336,17 +314,6 @@ class IntroducerEngine } } - private String getMessagePartner(BdfDictionary localState, - BdfDictionary msg) throws FormatException { - - String from = localState.getString(CONTACT_1); - if (Arrays - .equals(msg.getRaw(GROUP_ID), localState.getRaw(GROUP_ID_2))) { - from = localState.getString(CONTACT_2); - } - return from; - } - private String getOtherContact(BdfDictionary localState, BdfDictionary msg) throws FormatException { @@ -362,11 +329,9 @@ class IntroducerEngine IntroducerProtocolState currentState, BdfDictionary localState) throws FormatException { - if (LOG.isLoggable(WARNING)) { - LOG.warning("Aborting protocol session " + - Arrays.hashCode(localState.getRaw(SESSION_ID)) + - " in state " + currentState.name()); - } + if (LOG.isLoggable(WARNING)) + LOG.warning("Aborting protocol session in state " + + currentState.name()); localState.put(STATE, ERROR.getValue()); List<BdfDictionary> messages = new ArrayList<BdfDictionary>(2); diff --git a/briar-core/src/main/java/org/briarproject/briar/introduction/IntroducerManager.java b/briar-core/src/main/java/org/briarproject/briar/introduction/IntroducerManager.java index 07e031c6325d173a17e7afd4c8fce242e15be060..09b6975adb02edebe9e843ab94a77444e46d2506 100644 --- a/briar-core/src/main/java/org/briarproject/briar/introduction/IntroducerManager.java +++ b/briar-core/src/main/java/org/briarproject/briar/introduction/IntroducerManager.java @@ -167,7 +167,6 @@ class IntroducerManager { } public void abort(Transaction txn, BdfDictionary state) { - IntroducerEngine engine = new IntroducerEngine(); BdfDictionary localAction = new BdfDictionary(); localAction.put(TYPE, TYPE_ABORT); diff --git a/briar-core/src/main/java/org/briarproject/briar/introduction/IntroductionManagerImpl.java b/briar-core/src/main/java/org/briarproject/briar/introduction/IntroductionManagerImpl.java index 6b3884138f459db5791314084d865e3ffe1bb694..6ed619249ce6d9845b7328b54a16cf348a0c65f1 100644 --- a/briar-core/src/main/java/org/briarproject/briar/introduction/IntroductionManagerImpl.java +++ b/briar-core/src/main/java/org/briarproject/briar/introduction/IntroductionManagerImpl.java @@ -436,7 +436,8 @@ class IntroductionManagerImpl extends ConversationClientImpl list.add(ir); } } catch (FormatException e) { - if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); + if (LOG.isLoggable(WARNING)) + LOG.log(WARNING, e.toString(), e); } } db.commitTransaction(txn); @@ -455,7 +456,8 @@ class IntroductionManagerImpl extends ConversationClientImpl return state.getString(CONTACT_2); if (contactId.getInt() == state.getLong(CONTACT_ID_2).intValue()) return state.getString(CONTACT_1); - throw new RuntimeException("Contact not part of this introduction session"); + throw new RuntimeException( + "Contact not part of this introduction session"); } private AuthorId getAuthorIdForIntroducer(ContactId contactId, @@ -465,7 +467,8 @@ class IntroductionManagerImpl extends ConversationClientImpl return new AuthorId(state.getRaw(AUTHOR_ID_2)); if (contactId.getInt() == state.getLong(CONTACT_ID_2).intValue()) return new AuthorId(state.getRaw(AUTHOR_ID_1)); - throw new RuntimeException("Contact not part of this introduction session"); + throw new RuntimeException( + "Contact not part of this introduction session"); } private boolean concernsThisContact(ContactId contactId, MessageId messageId, @@ -508,11 +511,8 @@ class IntroductionManagerImpl extends ConversationClientImpl if (g.equals(groupId)) return state; } } - if (warn && LOG.isLoggable(WARNING)) { - LOG.warning( - "No session state found for message with session ID " + - Arrays.hashCode(sessionId)); - } + if (warn && LOG.isLoggable(WARNING)) + LOG.warning("No session state found"); throw new FormatException(); } }