• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* **************************************************************************
2  * $OpenLDAP: /com/novell/sasl/client/ResponseAuth.java,v 1.3 2005/01/17 15:00:54 sunilk Exp $
3  *
4  * Copyright (C) 2002 Novell, Inc. All Rights Reserved.
5  *
6  * THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
7  * TREATIES. USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT
8  * TO VERSION 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS
9  * AVAILABLE AT HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE"
10  * IN THE TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION
11  * OF THIS WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP
12  * PUBLIC LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT
13  * THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
14  ******************************************************************************/
15 package com.novell.sasl.client;
16 
17 import java.util.*;
18 import org.apache.harmony.javax.security.sasl.*;
19 
20 /**
21  * Implements the ResponseAuth class used by the DigestMD5SaslClient mechanism
22  */
23 class ResponseAuth
24 {
25 
26     private String m_responseValue;
27 
ResponseAuth( byte[] responseAuth)28     ResponseAuth(
29         byte[] responseAuth)
30             throws SaslException
31     {
32         m_responseValue = null;
33 
34         DirectiveList dirList = new DirectiveList(responseAuth);
35         try
36         {
37             dirList.parseDirectives();
38             checkSemantics(dirList);
39         }
40         catch (SaslException e)
41         {
42         }
43     }
44 
45     /**
46      * Checks the semantics of the directives in the directive list as parsed
47      * from the digest challenge byte array.
48      *
49      * @param dirList  the list of directives parsed from the digest challenge
50      *
51      * @exception SaslException   If a semantic error occurs
52      */
checkSemantics( DirectiveList dirList)53     void checkSemantics(
54         DirectiveList dirList) throws SaslException
55     {
56         Iterator        directives = dirList.getIterator();
57         ParsedDirective directive;
58         String          name;
59 
60         while (directives.hasNext())
61         {
62             directive = (ParsedDirective)directives.next();
63             name = directive.getName();
64             if (name.equals("rspauth"))
65                 m_responseValue = directive.getValue();
66         }
67 
68         /* post semantic check */
69         if (m_responseValue == null)
70             throw new SaslException("Missing response-auth directive.");
71     }
72 
73     /**
74      * returns the ResponseValue
75      *
76      * @return the ResponseValue as a String.
77      */
getResponseValue()78     public String getResponseValue()
79     {
80         return m_responseValue;
81     }
82 }
83 
84