QuickServer的学习研究(十)

  在QuickServer中权限设置,如下:

package com.easway.quickserver.advance;
import org.quickserver.net.server.*;
import java.io.*;
public class EchoServerQuickAuthenticator extends QuickAuthenticator {

	public boolean askAuthorisation(ClientHandler clientHandler) 
			throws IOException {		
		String username = askStringInput(clientHandler, "User Name :");
		if(username!=null && username.equalsIgnoreCase("QUIT")) {
			sendString(clientHandler, "Logged out.");
			//close the connection
			clientHandler.closeConnection();
			return false;
		}

		String password = askStringInput(clientHandler, "Password :");

		if(username==null || password ==null)
			return false;
		
		if(username.equals(password)) {
			sendString(clientHandler, "Auth OK");
			//store the username in ClientData
			EchoServerData data = (EchoServerData) clientHandler.getClientData();
			data.setUserName(username);
			return true;
		} else {
			sendString(clientHandler, "Auth Failed");
			return false;
		}
	}
}

 

配置如下:

	<authenticator>
		com.easway.quickserver.advance.EchoServerQuickAuthenticator
	</authenticator>

 

你可能感兴趣的:(.net)