1 36 package org.columba.ristretto.auth.mechanism; 37 38 import java.io.IOException ; 39 40 import org.columba.ristretto.auth.AuthenticationException; 41 import org.columba.ristretto.auth.AuthenticationMechanism; 42 import org.columba.ristretto.auth.AuthenticationServer; 43 44 49 public class PlainMechanism implements AuthenticationMechanism { 50 51 54 public void authenticate( 55 AuthenticationServer server, 56 String user, 57 char[] password) 58 throws IOException , AuthenticationException { 59 server.authReceive(); 60 61 byte[] userBytes = user.getBytes("UTF-8"); 62 byte[] passwordBytes = new String (password).getBytes("UTF-8"); 63 byte[] command = new byte[userBytes.length + passwordBytes.length + 2]; 64 65 command[0] = 0; 66 System.arraycopy(userBytes, 0, command, 1, userBytes.length); 67 command[userBytes.length+1] = 0; 68 System.arraycopy(passwordBytes, 0, command, userBytes.length+2, passwordBytes.length); 69 70 server.authSend(command); 71 } 72 } 73 | Popular Tags |