Debian Codegraph @

java/gov/nist/javax/sip/parser/ProxyAuthorizationParser.java

raw
1 /*
2 * Conditions Of Use
3 *
4 * This software was developed by employees of the National Institute of
5 * Standards and Technology (NIST), an agency of the Federal Government.
6 * Pursuant to title 15 Untied States Code Section 105, works of NIST
7 * employees are not subject to copyright protection in the United States
8 * and are considered to be in the public domain. As a result, a formal
9 * license is not needed to use the software.
10 *
11 * This software is provided by NIST as a service and is expressly
12 * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
15 * AND DATA ACCURACY. NIST does not warrant or make any representations
16 * regarding the use of the software or the results thereof, including but
17 * not limited to the correctness, accuracy, reliability or usefulness of
18 * the software.
19 *
20 * Permission to use this software is contingent upon your acceptance
21 * of the terms of this agreement
22 *
23 * .
24 *
25 */
26 package gov.nist.javax.sip.parser;
27
28 import gov.nist.javax.sip.header.*;
29 import java.text.ParseException;
30
31 /**
32 * Parser for ProxyAuthorization headers.
33 *
34 * @version 1.2 $Revision: 1.7 $ $Date: 2009/07/17 18:58:02 $
35 *
36 * @author M. Ranganathan <br/>
37 *
38 *
39 *
40 */
41 public class ProxyAuthorizationParser extends ChallengeParser {
42
43 /**
44 * Constructor
45 * @param proxyAuthorization -- header to parse
46 */
47 public ProxyAuthorizationParser(String proxyAuthorization) {
48 super(proxyAuthorization);
49 }
50
51 /**
52 * Cosntructor
53 * @param Lexer lexer to set
54 */
55 protected ProxyAuthorizationParser(Lexer lexer) {
56 super(lexer);
57 }
58
59 /**
60 * parse the String message
61 * @return SIPHeader (ProxyAuthenticate object)
62 * @throws ParseException if the message does not respect the spec.
63 */
64 public SIPHeader parse() throws ParseException {
65 headerName(TokenTypes.PROXY_AUTHORIZATION);
66 ProxyAuthorization proxyAuth = new ProxyAuthorization();
67 super.parse(proxyAuth);
68 return proxyAuth;
69 }
70
71 /**
72
73 public static void main(String args[]) throws ParseException {
74 String paAuth[] = {
75 "Proxy-Authorization: Digest realm=\"MCI WorldCom SIP\","+
76 "domain=\"sip:ss2.wcom.com\",nonce=\"ea9c8e88df84f1cec4341ae6cbe5a359\","+
77 "opaque=\"\",stale=FALSE,algorithm=MD5\n",
78
79 "Proxy-Authorization: Digest realm=\"MCI WorldCom SIP\","+
80 "qop=\"auth\" , nonce-value=\"oli\"\n"
81 };
82
83 for (int i = 0; i < paAuth.length; i++ ) {
84 ProxyAuthorizationParser pap =
85 new ProxyAuthorizationParser(paAuth[i]);
86 ProxyAuthorization pa= (ProxyAuthorization) pap.parse();
87 String encoded = pa.encode();
88 System.out.println ("original = \n" + paAuth[i]);
89 System.out.println("encoded = \n" + encoded);
90 pap = new ProxyAuthorizationParser(encoded.trim() + "\n");
91 pap.parse();
92 }
93
94 }
95 **/
96
97 }
98 /*
99 * $Log: ProxyAuthorizationParser.java,v $
100 * Revision 1.7 2009/07/17 18:58:02 emcho
101 * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
102 *
103 * Revision 1.6 2006/07/13 09:02:18 mranga
104 * Issue number:
105 * Obtained from:
106 * Submitted by: jeroen van bemmel
107 * Reviewed by: mranga
108 * Moved some changes from jain-sip-1.2 to java.net
109 *
110 * CVS: ----------------------------------------------------------------------
111 * CVS: Issue number:
112 * CVS: If this change addresses one or more issues,
113 * CVS: then enter the issue number(s) here.
114 * CVS: Obtained from:
115 * CVS: If this change has been taken from another system,
116 * CVS: then name the system in this line, otherwise delete it.
117 * CVS: Submitted by:
118 * CVS: If this code has been contributed to the project by someone else; i.e.,
119 * CVS: they sent us a patch or a set of diffs, then include their name/email
120 * CVS: address here. If this is your work then delete this line.
121 * CVS: Reviewed by:
122 * CVS: If we are doing pre-commit code reviews and someone else has
123 * CVS: reviewed your changes, include their name(s) here.
124 * CVS: If you have not had it reviewed then delete this line.
125 *
126 * Revision 1.3 2006/06/19 06:47:27 mranga
127 * javadoc fixups
128 *
129 * Revision 1.2 2006/06/16 15:26:28 mranga
130 * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
131 *
132 * Revision 1.1.1.1 2005/10/04 17:12:35 mranga
133 *
134 * Import
135 *
136 *
137 * Revision 1.4 2005/02/24 16:13:11 mranga
138 * Submitted by: mranga
139 * Reviewed by: mranga
140 * Just some additional testing on the parser.
141 *
142 * Revision 1.3 2004/01/22 13:26:31 sverker
143 * Issue number:
144 * Obtained from:
145 * Submitted by: sverker
146 * Reviewed by: mranga
147 *
148 * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
149 *
150 * CVS: ----------------------------------------------------------------------
151 * CVS: Issue number:
152 * CVS: If this change addresses one or more issues,
153 * CVS: then enter the issue number(s) here.
154 * CVS: Obtained from:
155 * CVS: If this change has been taken from another system,
156 * CVS: then name the system in this line, otherwise delete it.
157 * CVS: Submitted by:
158 * CVS: If this code has been contributed to the project by someone else; i.e.,
159 * CVS: they sent us a patch or a set of diffs, then include their name/email
160 * CVS: address here. If this is your work then delete this line.
161 * CVS: Reviewed by:
162 * CVS: If we are doing pre-commit code reviews and someone else has
163 * CVS: reviewed your changes, include their name(s) here.
164 * CVS: If you have not had it reviewed then delete this line.
165 *
166 */