
// --- EXISTING CODE ---
...
URI uri =
((ToHeader)request.getHeader(ToHeader.NAME)).getAddress().getURI();
String sipAddressOfRecord = getCanonicalAddress(uri);
// --- NEW CODE STARTS HERE ---
// Get myDomain env-entry from JNDI
String myDomain = (String) new
javax.naming.InitialContext().lookup("java:comp/env/myDomain");
String requestDomain = ((SipURI)uri).getHost();
// Check if domain in request matches myDomain
if (requestDomain.equalsIgnoreCase(myDomain)) {
if (isTraceable(Level.FINE))
fine("request domain " + requestDomain + " is OK, accepting request");
}
else {
if (isTraceable(Level.FINE))
fine("request domain " + requestDomain + " is forbidden, rejecting request");
sendFinalResponse(st, Response.FORBIDDEN, null, false);
return;
}
// --- END OF NEW CODE ---
The new code that has just been added gets the
myDomain env-entry
from JNDI and compares it with the domain in the
To
header of the received request. If the domain does not match
myDomain
, then a
FORBIDDEN
response is sent and this
code returns. Some trace messages are also included so that it can be seen whether the request was accepted or rejected.
7. To rebuild the service code and its deployable unit jar, run the command:
ant build
This rebuilds all the example SIP services, including the registrar.
To deploy the registrar service again, run:
ant deployregistrar
Note that the "deployregistrar" target will automatically run the "build" target if any source files have changed, so rebuild
and redeploy the service in one step if it is preferred.
8. As before, set the trace level of the Registrar SBB to Finest, to see that the SBB accepts or rejects the request using the
new code.
rhino-console setTraceLevel sbb "RegistrarSbb 1.5, Open Cloud" Finest
9. Configure the SIP client to use the correct Domain Name and then register. The following output should appear: Rhino
SLEE.
Sbb[RegistrarSbb 1.5, Open Cloud] request domain opencloud.com is OK, accepting request
10. Re-configure the SIP client to use a different Domain Name than the one configured for the SIP Registrar. Try to register.
The output should be similar to the following:
Sbb[RegistrarSbb 1.5, Open Cloud] request domain other.com is forbidden, rejecting request
11. To undeploy the registrar service, run:
ant undeployregistrar
Open Cloud Rhino 1.4.3 Administration Manual v1.1 171
Komentarze do niniejszej Instrukcji