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

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

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

revision 1.5 by dog, Thu Oct 21 15:21:55 2004 UTC revision 1.6 by dog, Thu Nov 25 22:15:05 2004 UTC
# Line 1  Line 1 
1  /*  /*
2   * $Id$   * SaslCallbackHandler.java
3   * Copyright (C) 2002 The Free Software Foundation   * Copyright (C) 2002 The Free Software Foundation
4   *   *
5   * This file is part of GNU inetlib, a library.   * This file is part of GNU inetlib, a library.
# Line 50  import javax.security.auth.callback.Unsu Line 50  import javax.security.auth.callback.Unsu
50   * A callback handler that can manage username and password callbacks.   * A callback handler that can manage username and password callbacks.
51   *   *
52   * @author <a href="mailto:dog@gnu.org">Chris Burdess</a>   * @author <a href="mailto:dog@gnu.org">Chris Burdess</a>
  * @version $Revision$ $Date$  
53   */   */
54  public final class SaslCallbackHandler implements CallbackHandler  public final class SaslCallbackHandler
55      implements CallbackHandler
56  {  {
57    
58    /*    /*
# Line 70  public final class SaslCallbackHandler i Line 70  public final class SaslCallbackHandler i
70     * @param username the value to respond to Name callbacks with     * @param username the value to respond to Name callbacks with
71     * @param password the value to respond to Password callbacks with     * @param password the value to respond to Password callbacks with
72     */     */
73    public SaslCallbackHandler (String username, String password)    public SaslCallbackHandler(String username, String password)
74      {    {
75        this.username = username;      this.username = username;
76        this.password = password;      this.password = password;
77      }    }
78    
79    /**    /**
80     * Handle callbacks.     * Handle callbacks.
81     */     */
82    public void handle (Callback[] callbacks)    public void handle(Callback[] callbacks)
83      throws IOException, UnsupportedCallbackException      throws IOException, UnsupportedCallbackException
84      {    {
85        for (int i = 0; i < callbacks.length; i++)      for (int i = 0; i < callbacks.length; i++)
86          {        {
87            if (callbacks[i] instanceof NameCallback)          if (callbacks[i] instanceof NameCallback)
88              {            {
89                NameCallback nc = (NameCallback) callbacks[i];              NameCallback nc = (NameCallback) callbacks[i];
90                nc.setName (username);              nc.setName(username);
91              }            }
92            else if (callbacks[i] instanceof PasswordCallback)          else if (callbacks[i] instanceof PasswordCallback)
93              {            {
94                PasswordCallback pc = (PasswordCallback) callbacks[i];              PasswordCallback pc = (PasswordCallback) callbacks[i];
95                pc.setPassword (password.toCharArray ());              pc.setPassword(password.toCharArray ());
96              }            }
97            else          else
98              throw new UnsupportedCallbackException (callbacks[i]);            {
99          }              throw new UnsupportedCallbackException(callbacks[i]);
100      }            }
101          }
102      }
103        
104  }  }
105    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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