Shuyi Chen | d7955ce | 2013-05-22 14:51:55 -0700 | [diff] [blame] | 1 | /**
|
| 2 | * $RCSfile$
|
| 3 | * $Revision$
|
| 4 | * $Date$
|
| 5 | *
|
| 6 | *
|
| 7 | * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 | * you may not use this file except in compliance with the License.
|
| 9 | * You may obtain a copy of the License at
|
| 10 | *
|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 12 | *
|
| 13 | * Unless required by applicable law or agreed to in writing, software
|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 | * See the License for the specific language governing permissions and
|
| 17 | * limitations under the License.
|
| 18 | */
|
| 19 |
|
| 20 | package org.jivesoftware.smack.sasl;
|
| 21 |
|
| 22 | import org.jivesoftware.smack.SASLAuthentication;
|
| 23 |
|
| 24 | import java.io.IOException;
|
| 25 | import org.apache.harmony.javax.security.auth.callback.CallbackHandler;
|
| 26 |
|
| 27 | /**
|
| 28 | * Implementation of the SASL ANONYMOUS mechanism
|
| 29 | *
|
| 30 | * @author Jay Kline
|
| 31 | */
|
| 32 | public class SASLAnonymous extends SASLMechanism {
|
| 33 |
|
| 34 | public SASLAnonymous(SASLAuthentication saslAuthentication) {
|
| 35 | super(saslAuthentication);
|
| 36 | }
|
| 37 |
|
| 38 | protected String getName() {
|
| 39 | return "ANONYMOUS";
|
| 40 | }
|
| 41 |
|
| 42 | public void authenticate(String username, String host, CallbackHandler cbh) throws IOException {
|
| 43 | authenticate();
|
| 44 | }
|
| 45 |
|
| 46 | public void authenticate(String username, String host, String password) throws IOException {
|
| 47 | authenticate();
|
| 48 | }
|
| 49 |
|
| 50 | protected void authenticate() throws IOException {
|
| 51 | // Send the authentication to the server
|
| 52 | getSASLAuthentication().send(new AuthMechanism(getName(), null));
|
| 53 | }
|
| 54 |
|
| 55 | public void challengeReceived(String challenge) throws IOException {
|
| 56 | // Build the challenge response stanza encoding the response text
|
| 57 | // and send the authentication to the server
|
| 58 | getSASLAuthentication().send(new Response());
|
| 59 | }
|
| 60 |
|
| 61 |
|
| 62 | }
|