package bssoft.stack.sip; public class SIPAUTHENTICATEHeader { public String header = null; public String headerValue = null; public String realmValue = null; public String nonceValue = null; public String qopValue = null; public String strStale = null; public String strAlgorithm = null; public int headerType = SIPStack.SIP_HEADERTYPE_NONE; public boolean flag = false; public SIPAUTHENTICATEHeader(String header, int headerType) { if (header != null) { String keyWord; if (headerType == SIPStack.SIP_HEADERTYPE_WWWAUTHENTICATE) { keyWord = "WWW-Authenticate: "; } else if (headerType == SIPStack.SIP_HEADERTYPE_WwwAUTHENTICATE) { keyWord = "Www-Authenticate: "; } else if (headerType == SIPStack.SIP_HEADERTYPE_PROXYAUTHENTICATE) { keyWord = "Proxy-Authenticate: "; } else { keyWord = null; } if (keyWord != null) if (header.startsWith(keyWord)) { this.headerType = headerType; this.header = header; this.flag = true; int iS = 0; int iE = 0; String strRealm = null; iS = header.indexOf("realm="); iE = 0; if (iS >= 0) { iE = header.indexOf(",", iS); if (iE > 0) { strRealm = header.substring(iS, iE); } else if (iE < 0) { strRealm = header.substring(iS); } if (strRealm.length() > 0) { iS = strRealm.indexOf("="); String strValue = strRealm.substring(iS + 1); strValue = strValue.trim(); if (strValue.indexOf("\"") == 0) iS = 1; if (iS > 0) iE = strValue.indexOf("\"", iS); this.realmValue = strValue.substring(iS, iE); } } else { this.realmValue = ""; } String strQop = null; iS = header.indexOf("qop="); iE = 0; if (iS >= 0) { iE = header.indexOf(",", iS); if (iE > 0) { strQop = header.substring(iS, iE); } else if (iE < 0) { strQop = header.substring(iS); } this.qopValue = ""; if (strQop.length() > 0) { iS = strQop.indexOf("="); String strValue = strQop.substring(iS + 1); strValue = strValue.trim(); if (strValue.indexOf("\"") == 0) iS = 1; if (iS > 0) iE = strValue.indexOf("\"", iS); this.qopValue = strValue.substring(iS, iE); } } else { this.qopValue = ""; } String strNonce = null; iS = header.indexOf("nonce="); iE = 0; if (iS >= 0) { iE = header.indexOf(",", iS); if (iE > 0) { strNonce = header.substring(iS, iE); } else if (iE < 0) { strNonce = header.substring(iS); } if (strNonce.length() > 0) { iS = strNonce.indexOf("="); String strValue = strNonce.substring(iS + 1); strValue = strValue.trim(); if (strValue.indexOf("\"") == 0) iS = 1; if (iS > 0) iE = strValue.indexOf("\"", iS); this.nonceValue = strValue.substring(iS, iE); } } else { this.nonceValue = ""; } iS = header.indexOf("stale="); iE = 0; if (iS >= 0) { iE = header.indexOf(",", iS); if (iE > 0) { this.strStale = header.substring(iS + 6, iE); } else if (iE < 0) { this.strStale = header.substring(iS + 6); } } else { this.strStale = ""; } iS = header.indexOf("algorithm="); iE = 0; if (iS >= 0) { iE = header.indexOf(",", iS); if (iE > 0) { this.strAlgorithm = header.substring(iS + 10, iE); } else if (iE < 0) { this.strAlgorithm = header.substring(iS + 10); } } else { this.strAlgorithm = ""; } } } } }