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/************************************************************************************************
27 * PRODUCT OF PT INOVACAO - EST DEPARTMENT and Telecommunications Institute (Aveiro, Portugal)  *
28 ************************************************************************************************/
29
30
31package gov.nist.javax.sip.parser.ims;
32
33/**
34 * Security-Server header parser.
35 *
36 * @author Miguel Freitas (IT) PT-Inovacao
37 */
38
39
40import gov.nist.javax.sip.header.SIPHeader;
41import gov.nist.javax.sip.parser.Lexer;
42import gov.nist.javax.sip.parser.TokenTypes;
43import java.text.ParseException;
44
45import gov.nist.javax.sip.header.ims.SecurityServerList;
46import gov.nist.javax.sip.header.ims.SecurityServer;
47
48
49public class SecurityServerParser extends SecurityAgreeParser
50{
51
52    public SecurityServerParser(String security)
53    {
54        super(security);
55    }
56
57    protected SecurityServerParser(Lexer lexer)
58    {
59        super(lexer);
60    }
61
62
63    public SIPHeader parse() throws ParseException
64    {
65        dbg_enter("SecuriryServer parse");
66        try {
67
68            headerName(TokenTypes.SECURITY_SERVER);
69            SecurityServer secServer = new SecurityServer();
70            SecurityServerList secServerList =
71                (SecurityServerList) super.parse(secServer);
72            return secServerList;
73
74        } finally {
75            dbg_leave("SecuriryServer parse");
76        }
77    }
78
79
80
81    /** Test program
82
83    public static void main(String args[]) throws ParseException {
84        String r[] = {
85                "Security-Server: ipsec-3gpp; ealg=aes-cbc; " +
86                                "alg=hmac-md5-96; port-c=5062; port-s=5063; " +
87                                "q=0.1\n"
88                };
89
90        String r2[] = {
91                "Security-Server: ipsec-3gpp; ealg=aes-cbc; " +
92                                "alg=hmac-md5-96; port-c=5062; port-s=5063; " +
93                                "q=0.1, " +
94                                "digest; d-alg=md5; " +
95                                "d-qop=auth-int; d-ver=AEF1D222; " +
96                                "q=0.01\n"
97                };
98
99
100        for (int i = 0; i < r.length; i++ )
101        {
102
103            SecurityServerParser parser =
104              new SecurityServerParser(r[i]);
105
106            SecurityServer secServer= (SecurityServer) parser.parse();
107            System.out.println("encoded = " + secServer.encode());
108        }
109
110
111        for (int i = 0; i < r2.length; i++ ) {
112            SecurityServerParser parser =
113              new SecurityServerParser(r2[i]);
114
115            java.util.ListIterator list;
116            SecurityServerList secList = (SecurityServerList) parser.parse();
117            System.out.println("encoded = " + secList.encode());
118        }
119
120
121    }
122    */
123
124
125
126}
127
128
129