KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jivesoftware > smack > sasl > SASLPlainMechanism


1 /**
2  * $RCSfile$
3  * $Revision: $
4  * $Date: $
5  *
6  * Copyright 2003-2004 Jive Software.
7  *
8  * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */

20
21 package org.jivesoftware.smack.sasl;
22
23 import org.jivesoftware.smack.SASLAuthentication;
24
25 /**
26  * Implementation of the SASL PLAIN mechanisn as defined by the
27  * <a HREF="http://www.ietf.org/internet-drafts/draft-ietf-sasl-plain-08.txt">IETF draft
28  * document</a>.
29  *
30  * @author Gaston Dombiak
31  */

32 public class SASLPlainMechanism extends SASLMechanism {
33
34     public SASLPlainMechanism(SASLAuthentication saslAuthentication) {
35         super(saslAuthentication);
36     }
37
38     protected String JavaDoc getName() {
39         return "PLAIN";
40     }
41
42     protected String JavaDoc getAuthenticationText(String JavaDoc username, String JavaDoc host, String JavaDoc password) {
43         // Build the text containing the "authorization identity" + NUL char +
44
// "authentication identity" + NUL char + "clear-text password"
45
StringBuffer JavaDoc text = new StringBuffer JavaDoc();
46         text.append(username).append("@").append(host);
47         text.append('\0');
48         text.append(username);
49         text.append('\0');
50         text.append(password);
51         return text.toString();
52     }
53
54     protected String JavaDoc getChallengeResponse(byte[] bytes) {
55         // Return null since this mechanism will never get a challenge from the server
56
return null;
57     }
58 }
59
Popular Tags