* ++++++++++++++++++++++++++++++++++++++++++++
*/
// work-around for IMS headers
//HeaderFactoryImpl headerFactoryImpl = new HeaderFactoryImpl();
HeaderFactoryImpl headerFactoryImpl = (HeaderFactoryImpl)headerFactory;
// check headers Allow, Require and Supported
// Allow header
ListIterator li = null;
AllowHeader allow = null;
String allowMethods = new String(); // all the methods in Allow Header
li = request.getHeaders(AllowHeader.NAME); // get all the allow methods
// creates an Allow header for each method
try {
while(li.hasNext()) // concatenate the method of each Allow header in one string
{
allow = (AllowHeader) li.next();
allowMethods = allowMethods.concat(allow.getMethod()).concat(" ");
}
}catch (Exception ex)
{
System.out.println("\n(!) Exception getting Allow header! - " + ex);
}
/*
// Allow: PRACK ??
if (allowMethods.indexOf(Request.PRACK) != -1)
System.out.println("\n*** UAC allows PRACK method ");
else
System.out.println("\n*** UAC does NOT allow PRACK method ");
*/
// Require header
RequireHeader require = null;
String requireOptionTags = new String();
li = null;
li = request.getHeaders(RequireHeader.NAME);
try {
while(li.hasNext())
{
require = (RequireHeader) li.next();
requireOptionTags = requireOptionTags
.concat( require.getOptionTag())
.concat(" ");
}
}
catch (Exception ex)
{
System.out.println("\n(!) Exception getting Require header! - " + ex);
}
/*
// Require: 100rel ??
if (requireOptionTags.indexOf("100rel") != -1)
System.out.println("\n*** UAC requires \"100rel\"");
else
System.out.println("\n*** UAC does NOT require \"100rel\"");
// Require: precondition ??
if (requireOptionTags.indexOf("precondition") != -1)
System.out.println("\n*** UAC requires \"precondition\"");
else
System.out.println("\n*** UAC does NOT require \"precondition\"");
// Require: sec-agree ??
if (requireOptionTags.indexOf("sec-agree") != -1)
System.out.println("\n*** UAC requires \"sec-agree\"");
else
System.out.println("\n*** UAC does NOT require \"sec-agree\"");
*/
// Supported header
SupportedHeader supported = null;
String supportedOptionTags = new String();
li = request.getHeaders(SupportedHeader.NAME);
try {
while(li.hasNext())
{
supported = (SupportedHeader) li.next();
supportedOptionTags = supportedOptionTags
.concat( supported.getOptionTag())
.concat(" ");
}
}
catch (NullPointerException ex)
{
System.out.println("\n(!) Exception getting Supported header! - " + ex);
}
/*
// Supported: 100rel ??
if (supportedOptionTags.indexOf("100rel") != -1)
System.out.println("\n*** UAC supports \"100rel\"");
else
System.out.println("\n*** UAC does NOT support \"100rel\"");
// Supported: precondition ??
if (supportedOptionTags.indexOf("precondition") != -1)
System.out.println("\n*** UAC supports \"precondition\"");
else
System.out.println("\n*** UAC does NOT support \"precondition\"");
*/
// check P-Headers
// check P-Called-Party-ID
PCalledPartyIDHeader calledParty;
try {
calledParty = (PCalledPartyIDHeader)
request.getHeader(PCalledPartyIDHeader.NAME);
if (calledParty != null)
{
System.out.println(".: P-Called-Party-ID = "
+ calledParty.getAddress().toString());
}
else
System.out.println(".: NOT received P-Called-Party-ID ! ");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting P-Called-Party-ID header! - " + ex);
}
// check P-Associated-URI
ListIterator associatedURIList;
try {
associatedURIList = request.getHeaders(PAssociatedURIHeader.NAME);
if (associatedURIList != null)
{
System.out.print(".: P-Associated-URI = ");
while (associatedURIList.hasNext())
{
PAssociatedURIHeader associatedURI = (PAssociatedURIHeader) associatedURIList.next();
System.out.print(associatedURI.getAssociatedURI().toString());
if (associatedURIList.hasNext())
System.out.print(", ");
}
}
else
System.out.println(".: NOT received P-Associated-URI ! ");
System.out.print("\n");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting P-Associated-URI header! - " + ex);
}
// check P-Access-Network-Info
PAccessNetworkInfoHeader accessInfo = null;
try {
accessInfo = (PAccessNetworkInfoHeader)
request.getHeader(PAccessNetworkInfoHeader.NAME);
if (accessInfo != null)
{
System.out.print(".: P-Access-Network-Info: Access Type = "
+ accessInfo.getAccessType());
if (accessInfo.getAccessType()
.equalsIgnoreCase(
PAccessNetworkInfoHeader.GGGPP_UTRAN_TDD)) // 3GPP-UTRAN-TDD
System.out.print(" - Cell ID = "
+ accessInfo.getUtranCellID3GPP());
}
else
System.out.println(".: NOT received P-Access-Network-Info ! ");
System.out.println("");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting P-Access-Network-Info header! - " + ex);
}
// check if .clone() and .equals() is working
if (accessInfo != null)
{
PAccessNetworkInfo accessInfoClone =
(PAccessNetworkInfo) accessInfo.clone();
System.out.println("--> clone = " + accessInfoClone.toString());
System.out.println("--> equals? " + accessInfoClone.equals(accessInfo));
}
// check P-Visited-Network-ID
ListIterator visitedNetList;
try {
visitedNetList = request.getHeaders(PVisitedNetworkIDHeader.NAME);
if (visitedNetList != null)
{
System.out.print(".: P-Visited-Network-ID = ");
while (visitedNetList.hasNext())
{
PVisitedNetworkIDHeader visitedID =
(PVisitedNetworkIDHeader) visitedNetList.next();
System.out.print(visitedID.getVisitedNetworkID());
if (visitedNetList.hasNext())
System.out.print(", ");
}
System.out.print("\n");
}
else
System.out.print(".: NOT received P-Visited-Network-ID ! ");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting P-Visited-Network-ID header! - " + ex);
}
// check Privacy
ListIterator privacyList;
try {
privacyList = request.getHeaders(PrivacyHeader.NAME);
if (privacyList != null && privacyList.hasNext())
{
System.out.print(".: Privacy = ");
while (privacyList.hasNext())
{
PrivacyHeader privacy =
(PrivacyHeader) privacyList.next();
System.out.print(privacy.getPrivacy());
if (privacyList.hasNext())
System.out.print("; ");
}
System.out.println("");
}
else
System.out.println(".: NOT received Privacy ! ");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting Privacy header! - " + ex);
}
// check P-Preferred-Identity
PPreferredIdentityHeader preferredID;
try {
preferredID = (PPreferredIdentityHeader)
request.getHeader(PPreferredIdentityHeader.NAME);
if (preferredID != null)
{
System.out.println(".: P-Preferred-Identity = " + preferredID.getAddress().toString());
}
else
System.out.println(".: NOT received P-Preferred-Identity ! ");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting P-Preferred-Identity header! - " + ex);
}
/*
* TEST
*/
// this is only to illustrate the usage of this headers
// P-Asserted-Identity
ListIterator assertedIDList;
try {
assertedIDList =
request.getHeaders(PAssertedIdentityHeader.NAME);
if (assertedIDList != null && assertedIDList.hasNext())
{
System.out.print(".: P-Asserted-Identity = ");
while (assertedIDList.hasNext())
{
PAssertedIdentityHeader assertedID =
(PAssertedIdentityHeader) assertedIDList.next();
System.out.print(assertedID.getAddress().toString());
if (assertedIDList.hasNext())
System.out.print(", ");
}
System.out.println("");
}
else
System.out.println(".: NOT received P-Asserted-Identity... ");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting P-Asserted-Identity header! - " + ex);
}
// P-Charging-Function-Addresses
PChargingFunctionAddressesHeader chargAddr;
try {
chargAddr = (PChargingFunctionAddressesHeader)
request.getHeader(PChargingFunctionAddressesHeader.NAME);
if (chargAddr != null)
{
Iterator param = chargAddr.getParameterNames();
System.out.print(".: P-Charging-Function-Addresses = ");
if (param != null) {
while (param.hasNext()) {
String paramName = (String)param.next();
System.out.print( paramName + "=" + chargAddr.getParameter(paramName));
if (param.hasNext())
System.out.print(", ");
}
}
System.out.println("");
}
else
System.out.println(".: NOT containing P-Charging-Function-Addresses... ");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting P-Charging-Function-Addresses header! - " + ex);
}
// P-Charging-Vector
PChargingVectorHeader chargVect;
try {
chargVect = (PChargingVectorHeader)
request.getHeader(PChargingVectorHeader.NAME);
if (chargVect != null)
{
Iterator param = chargVect.getParameterNames();
System.out.print(".: P-Charging-Vector = ");
if (param != null && param.hasNext()) {
while (param.hasNext()) {
String paramName = (String)param.next();
System.out.print( paramName + "="
+ chargVect.getParameter(paramName));
if (param.hasNext())
System.out.print(", ");
}
}
System.out.println("");
}
else
System.out.println(".: NOT containing P-Charging-Vector... ");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting P-Charging-Vector header! - " + ex);
}
// P-Media-Authorization
ListIterator mediaAuthList;
try {
mediaAuthList = request.getHeaders(PMediaAuthorizationHeader.NAME);
if (mediaAuthList != null)
{
System.out.print(".: P-Media-Authorization = ");
while (mediaAuthList.hasNext())
{
PMediaAuthorizationHeader mediaAuth =
(PMediaAuthorizationHeader) mediaAuthList.next();
System.out.print(mediaAuth.getToken());
if (mediaAuthList.hasNext())
System.out.print(", ");
}
System.out.println("");
}
else
System.out.println(".: NOT containing P-Media-Authorization... ");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting P-Media-Authorization header! - " + ex);
}
// Security-Client header
ListIterator secClientList;
try {
secClientList = request.getHeaders(SecurityClientHeader.NAME);
if (secClientList != null)
{
while (secClientList.hasNext())
{
System.out.println(".: "
+ ((SecurityClientHeader)secClientList.next()).toString());
}
}
else
System.out.println(".: NOT containing Security-Client header... ");
}
catch (Exception ex)
{
System.out.println("(!) Exception getting Security-Client header! - " + ex);
}
// this is only to illustrate the usage of this headers
// send Security-Server if Require: sec-agree
SecurityServerList secServerList = null;
if (requireOptionTags.indexOf("sec-agree") != -1)
{
secServerList = new SecurityServerList();
try {
SecurityServerHeader secServer1 =
headerFactoryImpl.createSecurityClientHeader();
secServer1.setSecurityMechanism("ipsec-3gpp");
secServer1.setAlgorithm("hmac-md5-96");
secServer1.setEncryptionAlgorithm("des-cbc");
secServer1.setSPIClient(10000);
secServer1.setSPIServer(10001);
secServer1.setPortClient(5063);
secServer1.setPortServer(4166);
secServer1.setPreference(0.1f);
SecurityServerHeader secServer2 =
headerFactoryImpl.createSecurityClientHeader();
secServer2.setSecurityMechanism("ipsec-3gpp");
secServer2.setAlgorithm("hmac-md5-96");
secServer2.setEncryptionAlgorithm("des-cbc");
secServer2.setSPIClient(20000);
secServer2.setSPIServer(20001);