// Check if the application has set Contact
if (request.isContactIndicated()) {
// Check if this request is initiated from this instance
Header contactHeader = request.getRawHeader(Header.CONTACT);
if (contactHeader != null) {
// There is a contact, we need to add the BE-KEY to it
try {
AddressImpl addressValue = (AddressImpl) contactHeader.getAddressValue();
if (addressValue != null) {
// Fetch current read-only status
boolean readOnly = addressValue.isReadOnly();
// Allow writes on Address object
addressValue.setReadOnly(false);
URIImpl uriImpl = (URIImpl) addressValue.getURI();
if(uriImpl != null){
uriImpl.encodeBeKey(hashkey);
}
// Reset read-only status
addressValue.setReadOnly(readOnly);
}
} catch (ServletParseException e) {
throw new SipRoutingException("Malformed Contact", e);
}
}
replaceTopVia(request, via);
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER,
"The request originates from this instance, altered request: " + request);
}
return null;
} else if (request.isRecordRouteIndicated()) {
// This request was proxied, save ID of incoming connection.
String encodedConnection;
if ((encodedConnection=getEncondedConnection(request)) == null) {
throw new SipRoutingException("Could not find connection information in a proxied request, shall never happen!");
} else {
via.setParameter(CLBConstants.CONNID_PARAM, encodedConnection);
}
Header rrHeader = request.getRawHeader(Header.RECORD_ROUTE);
AddressImpl rrAddr;
try {
rrAddr = (AddressImpl) rrHeader.getAddressValue();
} catch (ServletParseException e) {
throw new SipRoutingException("Malformed record-Route", e);
}
// The R-R was added by the application, thus we shall set 'bekey'