/[classpath]/inetlib/source/gnu/inet/util/SaslLogin.java
ViewVC logotype

Diff of /inetlib/source/gnu/inet/util/SaslLogin.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dog, Thu Oct 21 15:21:55 2004 UTC revision 1.4 by dog, Thu Nov 25 22:15:05 2004 UTC
# Line 48  import javax.security.sasl.SaslException Line 48  import javax.security.sasl.SaslException
48   * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>   * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
49   */   */
50  public class SaslLogin  public class SaslLogin
51  implements SaslClient    implements SaslClient
52  {  {
53    
54    private static final int STATE_USERNAME = 0;    private static final int STATE_USERNAME = 0;
# Line 59  implements SaslClient Line 59  implements SaslClient
59    private String password;    private String password;
60    private int state;    private int state;
61    
62    public SaslLogin (String username, String password)    public SaslLogin(String username, String password)
63    {    {
64      this.username = username;      this.username = username;
65      this.password = password;      this.password = password;
66      state = STATE_USERNAME;      state = STATE_USERNAME;
67    }    }
68    
69    public String getMechanismName ()    public String getMechanismName()
70    {    {
71      return "LOGIN";      return "LOGIN";
72    }    }
73    
74    public boolean hasInitialResponse ()    public boolean hasInitialResponse()
75    {    {
76      return false;      return false;
77    }    }
78    
79    public byte[] evaluateChallenge (byte[] challenge)    public byte[] evaluateChallenge(byte[] challenge)
80      throws SaslException      throws SaslException
81    {    {
82      try      try
# Line 85  implements SaslClient Line 85  implements SaslClient
85            {            {
86            case STATE_USERNAME:            case STATE_USERNAME:
87              state = STATE_PASSWORD;              state = STATE_PASSWORD;
88              return username.getBytes ("UTF-8");              return username.getBytes("UTF-8");
89            case STATE_PASSWORD:            case STATE_PASSWORD:
90              state = STATE_COMPLETE;              state = STATE_COMPLETE;
91              return password.getBytes ("UTF-8");              return password.getBytes("UTF-8");
92            default:            default:
93              return new byte[0];              return new byte[0];
94            }            }
# Line 96  implements SaslClient Line 96  implements SaslClient
96      catch (UnsupportedEncodingException e)      catch (UnsupportedEncodingException e)
97        {        {
98          String msg = "The UTF-8 character set is not supported by the VM";          String msg = "The UTF-8 character set is not supported by the VM";
99          throw new SaslException (msg, e);          throw new SaslException(msg, e);
100        }        }
101    }    }
102    
103    public boolean isComplete ()    public boolean isComplete()
104    {    {
105      return (state == STATE_COMPLETE);      return (state == STATE_COMPLETE);
106    }    }
107    
108    public byte[] unwrap (byte[] incoming, int off, int len)    public byte[] unwrap(byte[] incoming, int off, int len)
109      throws SaslException      throws SaslException
110    {    {
111      byte[] ret = new byte[len - off];      byte[] ret = new byte[len - off];
112      System.arraycopy (incoming, off, ret, 0, len);      System.arraycopy(incoming, off, ret, 0, len);
113      return ret;      return ret;
114    }    }
115    
116    public byte[] wrap (byte[] outgoing, int off, int len)    public byte[] wrap(byte[] outgoing, int off, int len)
117      throws SaslException      throws SaslException
118    {    {
119      byte[] ret = new byte[len - off];      byte[] ret = new byte[len - off];
120      System.arraycopy (outgoing, off, ret, 0, len);      System.arraycopy(outgoing, off, ret, 0, len);
121      return ret;      return ret;
122    }    }
123    
124    public Object getNegotiatedProperty (String name)    public Object getNegotiatedProperty(String name)
125    {    {
126      return null;      return null;
127    }    }
128    
129    public void dispose ()    public void dispose()
130    {    {
131    }    }
132        
133  }  }
134    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26