亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? simulatorpduprocessor.java

?? Short Message Peer to Peer
?? JAVA
字號:
/*
 * Copyright (c) 1996-2001
 * Logica Mobile Networks Limited
 * All rights reserved.
 *
 * This software is distributed under Logica Open Source License Version 1.0
 * ("Licence Agreement"). You shall use it and distribute only in accordance
 * with the terms of the License Agreement.
 *
 */
package org.smpp.smscsim;

import java.io.IOException;
import org.smpp.*;
import org.smpp.SmppObject;
import org.smpp.debug.Debug;
import org.smpp.debug.Event;
import org.smpp.debug.FileLog;
import org.smpp.pdu.*;
import org.smpp.smscsim.util.Record;
import org.smpp.smscsim.util.Table;

/**
 * Class <code>SimulatorPDUProcessor</code> gets the <code>Request</code>
 * from the client and creates the proper
 * <code>Response</code> and sends it. At the beginning it authenticates
 * the client using information in the bind request and list of users provided
 * during construction of the processor. It also stores messages
 * sent from client and allows cancellation and replacement of the messages.
 *
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.2 $
 * @see PDUProcessor
 * @see SimulatorPDUProcessorFactory
 * @see SMSCSession
 * @see ShortMessageStore
 * @see Table
 */
public class SimulatorPDUProcessor extends PDUProcessor {
	/**
	 * The session this processor uses for sending of PDUs.
	 */
	private SMSCSession session = null;

	/**
	 * The container for received messages.
	 */
	private ShortMessageStore messageStore = null;

	/**
	 * The thread which sends delivery information for messages
	 * which require delivery information.
	 */
	private DeliveryInfoSender deliveryInfoSender = null;

	/**
	 * The table with system id's and passwords for authenticating
	 * of the bounding ESMEs.
	 */
	private Table users = null;

	/**
	 * Indicates if the bound has passed.
	 */
	private boolean bound = false;

	/**
	 * The system id of the bounded ESME.
	 */
	private String systemId = null;

	/**
	 * If the information about processing has to be printed
	 * to the standard output.
	 */
	private boolean displayInfo = false;

	/**
	 * The message id assigned by simulator to submitted messages.
	 */
	private static int intMessageId = 2000;

	/**
	 * System id of this simulator sent to the ESME in bind response.
	 */
	private static final String SYSTEM_ID = "Smsc Simulator";

	/**
	 * The name of attribute which contains the system id of ESME.
	 */
	private static final String SYSTEM_ID_ATTR = "name";

	/**
	 * The name of attribute which conatins password of ESME.
	 */
	private static final String PASSWORD_ATTR = "password";

	private Debug debug = SmppObject.getDebug();
	private Event event = SmppObject.getEvent();

	/**
	 * Constructs the PDU processor with given session,
	 * message store for storing of the messages and a table of
	 * users for authentication.
	 * @param session the sessin this PDU processor works for
	 * @param messageStore the store for messages received from the client
	 * @param users the list of users used for authenticating of the client
	 */
	public SimulatorPDUProcessor(SMSCSession session, ShortMessageStore messageStore, Table users) {
		this.session = session;
		this.messageStore = messageStore;
		this.users = users;
	}

	public void stop() {
	}

	/**
	 * Depending on the <code>commandId</code>
	 * of the <code>request</code> creates the proper response.
	 * The first request must be a <code>BindRequest</code> with the correct
	 * parameters.
	 * @param request the request from client
	 */
	public void clientRequest(Request request) {
		debug.write("SimulatorPDUProcessor.clientRequest() " + request.debugString());
		Response response;
		int commandStatus;
		int commandId = request.getCommandId();
		try {
			display("client request: " + request.debugString());
			if (!bound) { // the first PDU must be bound request
				if (commandId == Data.BIND_TRANSMITTER
					|| commandId == Data.BIND_RECEIVER
					|| commandId == Data.BIND_TRANSCEIVER) {
					commandStatus = checkIdentity((BindRequest) request);
					if (commandStatus == 0) { // authenticated
						// firstly generate proper bind response
						BindResponse bindResponse = (BindResponse) request.getResponse();
						bindResponse.setSystemId(SYSTEM_ID);
						// and send it to the client via serverResponse
						serverResponse(bindResponse);
						// success => bound
						bound = true;
					} else { // system id not authenticated
						// get the response
						response = request.getResponse();
						// set it the error command status
						response.setCommandStatus(commandStatus);
						// and send it to the client via serverResponse
						serverResponse(response);
						// bind failed, stopping the session
						session.stop();
					}
				} else {
					// the request isn't a bound req and this is wrong: if not
					// bound, then the server expects bound PDU
					if (request.canResponse()) {
						// get the response
						response = request.getResponse();
						response.setCommandStatus(Data.ESME_RINVBNDSTS);
						// and send it to the client via serverResponse
						serverResponse(response);
					} else {
						// cannot respond to a request which doesn't have
						// a response :-(
					}
					// bind failed, stopping the session
					session.stop();
				}
			} else { // already bound, can receive other PDUs
				if (request.canResponse()) {
					response = request.getResponse();
					switch (commandId) { // for selected PDUs do extra steps
						case Data.SUBMIT_SM :
							SubmitSMResp submitResponse = (SubmitSMResp) response;
							submitResponse.setMessageId(assignMessageId());
							display("putting message into message store");
							messageStore.submit((SubmitSM) request, submitResponse.getMessageId(), systemId);
							byte registeredDelivery =
								(byte) (((SubmitSM) request).getRegisteredDelivery() & Data.SM_SMSC_RECEIPT_MASK);
							if (registeredDelivery == Data.SM_SMSC_RECEIPT_REQUESTED) {
								deliveryInfoSender.submit(this, (SubmitSM) request, submitResponse.getMessageId());
							}
							break;

						case Data.SUBMIT_MULTI :
							SubmitMultiSMResp submitMultiResponse = (SubmitMultiSMResp) response;
							submitMultiResponse.setMessageId(assignMessageId());
							break;

						case Data.DELIVER_SM :
							DeliverSMResp deliverResponse = (DeliverSMResp) response;
							deliverResponse.setMessageId(assignMessageId());
							break;

						case Data.DATA_SM :
							DataSMResp dataResponse = (DataSMResp) response;
							dataResponse.setMessageId(assignMessageId());
							break;

						case Data.QUERY_SM :
							QuerySM queryRequest = (QuerySM) request;
							QuerySMResp queryResponse = (QuerySMResp) response;
							display("querying message in message store");
							queryResponse.setMessageId(queryRequest.getMessageId());
							break;

						case Data.CANCEL_SM :
							CancelSM cancelRequest = (CancelSM) request;
							display("cancelling message in message store");
							messageStore.cancel(cancelRequest.getMessageId());
							break;

						case Data.REPLACE_SM :
							ReplaceSM replaceRequest = (ReplaceSM) request;
							display("replacing message in message store");
							messageStore.replace(replaceRequest.getMessageId(), replaceRequest.getShortMessage());
							break;

						case Data.UNBIND :
							// do nothing, just respond and after sending
							// the response stop the session
							break;
					}
					// send the prepared response
					serverResponse(response);
					if (commandId == Data.UNBIND) {
						// unbind causes stopping of the session
						session.stop();
					}
				} else {
					// can't respond => nothing to do :-)
				}
			}
		} catch (WrongLengthOfStringException e) {
			event.write(e, "");
		} catch (Exception e) {
			event.write(e, "");
		}
	}

	/**
	 * Processes the response received from the client.
	 * @param response the response from client
	 */
	public void clientResponse(Response response) {
		debug.write("SimulatorPDUProcessor.clientResponse() " + response.debugString());
		display("client response: " + response.debugString());
	}

	/**
	 * Sends a request to a client. For example, it can be used to send
	 * delivery info to the client.
	 * @param request the request to be sent to the client
	 */
	public void serverRequest(Request request) throws IOException, PDUException {
		debug.write("SimulatorPDUProcessor.serverRequest() " + request.debugString());
		display("server request: " + request.debugString());
		session.send(request);
	}

	/**
	 * Send the response created by <code>clientRequest</code> to the client.
	 * @param response the response to send to client
	 */
	public void serverResponse(Response response) throws IOException, PDUException {
		synchronized(this) {
			try {
				// Sleep for 300 ms sending reply to more accuratly simulate smsc
				this.wait(300);
			} catch( Exception e ) { e.printStackTrace(); }
		}

		debug.write("SimulatorPDUProcessor.serverResponse() " + response.debugString());
		display("server response: " + response.debugString());
		session.send(response);
	}

	/**
	 * Checks if the bind request contains valid system id and password.
	 * For this uses the table of users provided in the constructor of the
	 * <code>SimulatorPDUProcessor</code>. If the authentication fails,
	 * i.e. if either the user isn't found or the password is incorrect,
	 * the function returns proper status code.
	 * @param request the bind request as received from the client
	 * @return status code of the authentication; ESME_ROK if authentication
	 *         passed
	 */
	private int checkIdentity(BindRequest request) {
		int commandStatus = Data.ESME_ROK;
		Record user = users.find(SYSTEM_ID_ATTR, request.getSystemId());
		if (user != null) {
			String password = user.getValue(PASSWORD_ATTR);
			if (password != null) {
				if (!request.getPassword().equals(password)) {
					commandStatus = Data.ESME_RINVPASWD;
					debug.write("system id " + request.getSystemId() + " not authenticated. Invalid password.");
					display("not authenticated " + request.getSystemId() + " -- invalid password");
				} else {
					systemId = request.getSystemId();
					debug.write("system id " + systemId + " authenticated");
					display("authenticated " + systemId);
				}
			} else {
				commandStatus = Data.ESME_RINVPASWD;
				debug.write(
					"system id " + systemId + " not authenticated. " + "Password attribute not found in users file");
				display("not authenticated " + systemId + " -- no password for user.");
			}
		} else {
			commandStatus = Data.ESME_RINVSYSID;
			debug.write("system id " + request.getSystemId() + " not authenticated -- not found");
			display("not authenticated " + request.getSystemId() + " -- user not found");
		}
		return commandStatus;
	}

	/**
	 * Creates a unique message_id for each sms sent by a client to the smsc.
	 * @return unique message id
	 */
	private String assignMessageId() {
		String messageId = "Smsc";
		intMessageId++;
		messageId += intMessageId;
		return messageId;
	}

	/**
	 * Returns the session this PDU processor works for.
	 * @return the session of this PDU processor
	 */
	public SMSCSession getSession() {
		return session;
	}

	/**
	 * Returns the system id of the client for whose is this PDU processor
	 * processing PDUs.
	 * @return system id of client
	 */
	public String getSystemId() {
		return systemId;
	}

	/**
	 * Sets if the info about processing has to be printed on
	 * the standard output.
	 */
	public void setDisplayInfo(boolean on) {
		displayInfo = on;
	}

	/**
	 * Returns status of printing of processing info on the standard output.
	 */
	public boolean getDisplayInfo() {
		return displayInfo;
	}

	/**
	 * Sets the delivery info sender object which is used to generate and send
	 * delivery pdus for messages which require the delivery info as the outcome
	 * of their sending.
	 */
	public void setDeliveryInfoSender(DeliveryInfoSender deliveryInfoSender) {
		this.deliveryInfoSender = deliveryInfoSender;
	}

	private void display(String info) {
		if (getDisplayInfo()) {
			String sysId = getSystemId();
			if (sysId == null) {
				sysId = "";
			}
			System.out.println(FileLog.getLineTimeStamp() + " [" + sysId + "] " + info);
		}
	}
}
/*
 * $Log: SimulatorPDUProcessor.java,v $
 * Revision 1.2  2003/09/30 09:17:49  sverkera
 * Created an interface for SMSCListener and SMSCSession and implementations of them  so that it is possible to provide other implementations of these classes.
 *
 * Revision 1.1  2003/07/23 00:28:39  sverkera
 * Imported
 *
 * 
 * Old changelog:
 * 20-09-01 ticp@logica.com added reference to the DeliveryInfoSender to support
 *                          automatic sending of delivery info PDUs
 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧洲亚洲精品在线| 亚洲宅男天堂在线观看无病毒| 一区二区在线观看av| 不卡视频在线观看| 国产精品视频一二三区 | 国产精品77777| 日韩精品一区二区三区中文不卡| 国产精品天干天干在线综合| 欧美主播一区二区三区| 国产一区二区伦理| 亚洲免费在线视频| 一区二区三区久久| 久久综合九色综合97_久久久 | 亚洲激情男女视频| 日韩一级免费观看| 在线免费观看视频一区| 国产揄拍国内精品对白| 麻豆精品视频在线观看| 93久久精品日日躁夜夜躁欧美| 日本欧美大码aⅴ在线播放| 亚洲综合色丁香婷婷六月图片| 久久久久久久久久久黄色 | 欧美日韩1区2区| 色综合网站在线| 在线观看不卡一区| 亚洲一区二区成人在线观看| 亚洲日本电影在线| 亚洲精品视频免费观看| 怡红院av一区二区三区| 久久久久久一二三区| 五月婷婷久久综合| 久久精品国产网站| 粉嫩av亚洲一区二区图片| av日韩在线网站| 99久久99久久综合| 欧美一级久久久| 中日韩免费视频中文字幕| 久久精品一区二区三区av| 在线中文字幕一区| 久久看人人爽人人| 免费高清在线一区| 在线精品视频免费观看| 欧美成人精精品一区二区频| 国产精品美女久久久久aⅴ国产馆| 久久婷婷国产综合精品青草| 精品国产污网站| 国产一区二区三区美女| 久久午夜电影网| 99视频国产精品| 午夜精品久久久久久久久| 这里只有精品99re| 国产乱码精品一区二区三| 精品国精品自拍自在线| 成人午夜av在线| 亚洲一区二区三区四区在线观看 | 成人av集中营| 精品国产乱码久久久久久图片| 亚洲精品视频在线| 欧美日韩视频在线第一区| 日韩不卡免费视频| 欧美国产精品专区| 在线观看亚洲精品视频| 久久成人久久爱| 亚洲成人www| 国产精品电影一区二区| 91精品福利在线一区二区三区| 色综合av在线| 国产精品久久免费看| 欧美男男青年gay1069videost| 国产精品一品二品| 日本成人在线电影网| 自拍偷在线精品自拍偷无码专区| 精品电影一区二区三区| 欧美日韩视频不卡| 欧美在线观看18| 色婷婷综合视频在线观看| 国产白丝网站精品污在线入口| 五月婷婷欧美视频| 亚洲成av人片在线观看无码| 国产精品久久久久精k8| 精品久久一区二区三区| 久久久www成人免费毛片麻豆| 欧美一区二视频| 日韩免费视频一区二区| 精品国产露脸精彩对白| 91精品国产欧美一区二区成人| 波多野结衣视频一区| 色哟哟亚洲精品| 欧美日韩国产精选| 久久亚洲春色中文字幕久久久| 欧美精品丝袜久久久中文字幕| 欧美精品视频www在线观看| 欧美做爰猛烈大尺度电影无法无天| 欧美日韩一区二区在线视频| 555夜色666亚洲国产免| 欧美日韩国产精品自在自线| 欧美视频在线观看一区| 欧美一级生活片| 最好看的中文字幕久久| 免费在线观看日韩欧美| 成人av在线网| 国产欧美日韩精品在线| 日韩成人免费在线| 色老汉av一区二区三区| 欧美成人a视频| 亚洲成在线观看| 欧美一区二区在线播放| 国产精品久久久久桃色tv| 午夜一区二区三区在线观看| 国产乱子轮精品视频| 日韩网站在线看片你懂的| 综合激情成人伊人| youjizz久久| 国产精品美女久久福利网站| 亚洲视频资源在线| 国产中文字幕一区| 欧美大片免费久久精品三p| 国产欧美一区二区在线| 六月婷婷色综合| 国产日韩av一区二区| www.欧美.com| 青青草国产成人99久久| 日韩三级.com| 丁香婷婷综合色啪| 一区二区三区日韩精品| 欧美日韩一区二区不卡| 日日摸夜夜添夜夜添精品视频| 日韩欧美黄色影院| 国产99精品在线观看| 亚洲国产成人精品视频| 久久精品在线观看| 91成人在线精品| 日韩不卡手机在线v区| 日韩视频免费直播| av电影在线观看不卡| 日韩精品欧美精品| 久久精品视频在线看| 欧美性猛交一区二区三区精品| 青草av.久久免费一区| 中文字幕精品在线不卡| 日韩一区二区精品葵司在线| jizzjizzjizz欧美| 蜜臀久久99精品久久久画质超高清 | 丁香婷婷综合激情五月色| 亚洲精品欧美激情| 国产精品久久免费看| 久久久久久97三级| 欧美一卡二卡三卡| 777午夜精品视频在线播放| www.色综合.com| eeuss影院一区二区三区| 成人视屏免费看| www.久久精品| 色偷偷88欧美精品久久久| 黄一区二区三区| 国产成a人亚洲精品| 成人av网站在线| 99久久久久免费精品国产 | 欧美激情中文不卡| 中文乱码免费一区二区| 亚洲日穴在线视频| 中文字幕av资源一区| 国产亚洲精品bt天堂精选| 欧美亚洲愉拍一区二区| 精品视频123区在线观看| 日韩无一区二区| 欧美国产日韩亚洲一区| 亚洲老司机在线| 久久爱www久久做| 色94色欧美sute亚洲线路一ni| 69堂亚洲精品首页| 久久久久久久性| 石原莉奈在线亚洲三区| 成人app网站| 欧美zozozo| 五月天国产精品| 成人毛片在线观看| 久久综合久色欧美综合狠狠| 亚洲美女视频在线观看| 国产九九视频一区二区三区| 91成人免费在线视频| 欧美国产禁国产网站cc| 蜜臀va亚洲va欧美va天堂| av网站免费线看精品| 久久精品视频一区二区| 美女国产一区二区三区| 91精品国模一区二区三区| 亚洲图片自拍偷拍| 欧美丝袜丝nylons| 一区二区三区在线高清| 欧美色手机在线观看| 亚洲精品视频自拍| 91免费观看国产| 一区二区不卡在线视频 午夜欧美不卡在| 国产一区91精品张津瑜| 国产精品丝袜一区| 91传媒视频在线播放| 免费在线观看不卡| 国产精品乱人伦| 欧美三级电影网站|