Modify the security message event handling to accomodate the message severity levels, playing

alert sound at right places etc.
cusax-fix
Werner Dittmann 17 years ago
parent 07c4be6a8a
commit 67f15b3c17

Binary file not shown.

Before

Width:  |  Height:  |  Size: 481 B

@ -313,8 +313,8 @@ public void securityOff(CallParticipantSecurityOffEvent securityEvent)
break;
}
NotificationManager.fireNotification(
NotificationManager.CALL_SECURITY_OFF);
// NotificationManager.fireNotification(
// NotificationManager.CALL_SECURITY_OFF);
}
/**
@ -445,9 +445,25 @@ public CallParticipantPanel getParticipantPanel(CallParticipant participant)
public void securityMessageRecieved(
CallParticipantSecurityMessageEvent event)
{
int severity = event.getEventSeverity();
switch (severity) {
// Don't play alert sound for Info or warning.
case CallParticipantSecurityMessageEvent.INFORMATION:
case CallParticipantSecurityMessageEvent.WARNING:
break;
// Alert sound indicates: security cannot established
case CallParticipantSecurityMessageEvent.SEVERE:
case CallParticipantSecurityMessageEvent.ZRTP:
NotificationManager.fireNotification(
NotificationManager.ZRTP_ALERT);
}
NotificationManager.fireNotification(
NotificationManager.WARNING_MESSAGE,
"Security error",
NotificationManager.SECURITY_MESSAGE,
event.getType(),
event.getI18nMessage());
}

@ -23,11 +23,11 @@ public class NotificationManager
public static final String PROACTIVE_NOTIFICATION = "ProactiveNotification";
public static final String WARNING_MESSAGE = "WarningMessage";
public static final String SECURITY_MESSAGE = "SecurityMessage";
public static final String CALL_SECURITY_ON = "CallSecurityOn";
public static final String CALL_SECURITY_OFF = "CallSecurityOff";
public static final String ZRTP_ALERT = "ZrtpAlert";
public static void registerGuiNotifications()
{
@ -97,7 +97,7 @@ public static void registerGuiNotifications()
// Register warning message notifications.
notificationService.registerDefaultNotificationForEvent(
WARNING_MESSAGE,
SECURITY_MESSAGE,
NotificationService.ACTION_POPUP_MESSAGE,
null,
null);
@ -111,7 +111,7 @@ public static void registerGuiNotifications()
// Register sound notification for security state off during a call.
notificationService.registerDefaultNotificationForEvent(
CALL_SECURITY_OFF,
ZRTP_ALERT,
NotificationService.ACTION_SOUND,
SoundProperties.ZRTP_ALERT,
null);

@ -163,12 +163,25 @@ public void showMessage(ZrtpCodes.MessageSeverity sev,
Object msgCode = ii.next();
String messageType = null;
String message = null;
String i18nMessage = null;
int severity = 0;
boolean sendEvent = true;
if (msgCode instanceof ZrtpCodes.InfoCodes)
{
ZrtpCodes.InfoCodes inf = (ZrtpCodes.InfoCodes) msgCode;
/*
* Use the following fields if INFORMATION type messages shall be
* shown to the user via SecurityMessageEvent, i.e. if
* sendEvent is set to true
severity = CallParticipantSecurityMessageEvent.INFORMATION;
messageType = MediaActivator.getResources().getI18NString(
"impl.media.security.INFO");
*/
// Don't spam user with ino messages, only internal processing or logging
sendEvent = false;
// If the ZRTP Master session (DH mode) signals "security on"
// then start multi-stream sessions.
@ -197,66 +210,56 @@ else if (msgCode instanceof ZrtpCodes.WarningCodes)
// Warning codes usually do not affect encryption or security. Only
// in few cases inform the user and ask to verify SAS.
ZrtpCodes.WarningCodes warn = (ZrtpCodes.WarningCodes) msgCode;
severity = CallParticipantSecurityMessageEvent.WARNING;
messageType = MediaActivator.getResources().getI18NString(
"impl.media.security.WARNING");
if (warn == ZrtpCodes.WarningCodes.WarningNoRSMatch)
{
messageType = CallParticipantSecurityMessageEvent
.SECURITY_AUTHENTICATION_REQUIRED;
message = "No retained shared secret available.";
i18nMessage = WARNING_NO_RS_MATCH;
}
else if (warn == ZrtpCodes.WarningCodes.WarningNoExpectedRSMatch)
{
messageType = CallParticipantSecurityMessageEvent
.RETAINED_SECURITY_AUTHENTICATION_FAILED;
message = "An expected retained shared secret is missing.";
i18nMessage = WARNING_NO_EXPECTED_RS_MATCH;
}
else if (warn == ZrtpCodes.WarningCodes.WarningCRCmismatch)
{
messageType = CallParticipantSecurityMessageEvent
.CHECKSUM_MISMATCH;
message = "Internal ZRTP packet checksum mismatch.";
i18nMessage = MediaActivator.getResources().getI18NString(
"impl.media.security.CHECKSUM_MISMATCH");
}
else
{
// Other warnings are internal only, no user action requied
sendEvent = false;
}
}
else if (msgCode instanceof ZrtpCodes.SevereCodes)
{
ZrtpCodes.SevereCodes severe = (ZrtpCodes.SevereCodes) msgCode;
severity = CallParticipantSecurityMessageEvent.SEVERE;
messageType = MediaActivator.getResources().getI18NString(
"impl.media.security.SEVERE");
if (severe == ZrtpCodes.SevereCodes.SevereCannotSend)
{
messageType = CallParticipantSecurityMessageEvent
.DATA_SEND_FAILED;
message = "Failed to send data."
+ "Internet data connection or peer is down.";
i18nMessage = MediaActivator.getResources().getI18NString(
"impl.media.security.DATA_SEND_FAILED",
new String[]{msgCode.toString()});
}
else if (severe == ZrtpCodes.SevereCodes.SevereTooMuchRetries)
{
messageType = CallParticipantSecurityMessageEvent
.RETRY_RATE_EXCEEDED;
message = "Too much retries during ZRTP negotiation.";
i18nMessage = MediaActivator.getResources().getI18NString(
"impl.media.security.RETRY_RATE_EXCEEDED",
new String[]{msgCode.toString()});
}
else if (severe == ZrtpCodes.SevereCodes.SevereProtocolError)
{
messageType = CallParticipantSecurityMessageEvent
.INTERNAL_PROTOCOL_ERROR;
message = "Internal protocol error occured.";
i18nMessage = MediaActivator.getResources().getI18NString(
"impl.media.security.INTERNAL_PROTOCOL_ERROR",
new String[]{msgCode.toString()});
}
else
{
messageType = CallParticipantSecurityMessageEvent.GENERAL_ERROR;
message = "General error has occurred.";
i18nMessage = MediaActivator.getResources().getI18NString(
"impl.media.security.ZRTP_GENERIC_MSG",
new String[]{msgCode.toString()});
@ -264,18 +267,18 @@ else if (severe == ZrtpCodes.SevereCodes.SevereProtocolError)
}
else if (msgCode instanceof ZrtpCodes.ZrtpErrorCodes)
{
messageType = CallParticipantSecurityMessageEvent.NOT_COMPATIBLE;
message = "Indicates compatibility problems like for example:"
+ "unsupported protocol version, unsupported hash type,"
+ "cypher type, SAS scheme, etc.";
severity = CallParticipantSecurityMessageEvent.ZRTP;
messageType = MediaActivator.getResources().getI18NString(
"impl.media.security.ZRTP");
i18nMessage = MediaActivator.getResources().getI18NString(
"impl.media.security.ZRTP_GENERIC_MSG",
new String[]{msgCode.toString()});
}
if (messageType != null)
if (sendEvent)
((AbstractCallParticipant) callParticipant)
.setSecurityMessage(messageType, message, i18nMessage);
.setSecurityMessage(messageType, i18nMessage, severity);
if (logger.isInfoEnabled())
{

@ -310,14 +310,14 @@ protected void fireCallParticipantSecurityOffEvent(int sessionType)
*/
protected void fireCallParticipantSecurityMessageEvent(
String messageType,
String message,
String i18nMessage)
String i18nMessage,
int severity)
{
CallParticipantSecurityMessageEvent evt
= new CallParticipantSecurityMessageEvent( this,
messageType,
message,
i18nMessage);
i18nMessage,
severity);
logger.debug("Dispatching a CallParticipantSecurityFailedEvent event to "
+ callParticipantSecurityListeners.size()
@ -537,11 +537,11 @@ public void setSecurityOff(int sessionType)
* @param message the message
*/
public void setSecurityMessage( String messageType,
String message,
String i18nMessage)
String i18nMessage,
int severity)
{
fireCallParticipantSecurityMessageEvent(messageType,
message,
i18nMessage);
i18nMessage,
severity);
}
}

@ -85,7 +85,7 @@ public class CallParticipantSecurityMessageEvent
* Indicates compatibility problems like for example: unsupported protocol
* version, unsupported hash type, cypher type, SAS scheme, etc.
*/
public static final String NOT_COMPATIBLE = "NotCompatible";
public static final String ZRTP_ERROR = "ZRTPError";
/**
* Indicates that the other party doesn't support the encryption algorithm
@ -99,20 +99,39 @@ public class CallParticipantSecurityMessageEvent
public static final String GENERAL_ERROR = "GeneralError";
/**
* One of the event types defined in this class.
* This is a information message. Security will be established.
*/
private final String eventType;
public static final int INFORMATION = 0;
/**
* This is a warning message. Security will not be established.
*/
public static final int WARNING = 1;
/**
* This is a severe error. Security will not be established.
*/
public static final int SEVERE = 2;
/**
* The message associated with this event.
* This is a ZRTP error message. Security will not be established.
*/
public static final int ZRTP = 3;
/**
* One of the event types defined in this class.
*/
private final String eventMessage;
private final String eventType;
/**
* The internationalized message associated with this event.
*/
private final String eventI18nMessage;
/**
* The severity of the security message event.
*/
private final int eventSeverity;
/**
* Creates a <tt>CallParticipantSecurityFailedEvent</tt> by specifying the
* call participant, event type and message associated with this event.
@ -124,16 +143,16 @@ public class CallParticipantSecurityMessageEvent
* @param i18nMessage the internationalized message associated with this
* event that could be shown to the user.
*/
public CallParticipantSecurityMessageEvent( CallParticipant callParticipant,
public CallParticipantSecurityMessageEvent( CallParticipant callParticipant,
String eventType,
String eventMessage,
String i18nMessage)
String i18nMessage,
int eventSeverity)
{
super(callParticipant);
this.eventType = eventType;
this.eventMessage = eventMessage;
this.eventI18nMessage = i18nMessage;
this.eventSeverity = eventSeverity;
}
/**
@ -147,22 +166,21 @@ public String getType()
}
/**
* Returns the message associated with this event.
* Returns the internationalized message associated with this event.
*
* @return the message associated with this event.
* @return the internationalized message associated with this event.
*/
public String getMessage()
public String getI18nMessage()
{
return eventMessage;
return eventI18nMessage;
}
/**
* Returns the internationalized message associated with this event.
* Returns the event severity.
*
* @return the internationalized message associated with this event.
* @return the eventSeverity
*/
public String getI18nMessage()
{
return eventI18nMessage;
public int getEventSeverity() {
return eventSeverity;
}
}

Loading…
Cancel
Save