⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spsmainbasepanel.java

📁 打印管理程序,测试完全通过.windows开发环境.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	protected int checkUSB(Net net, String msgConnection) throws NoUSBException, NetworkException, NotRegisterSPKeyException, InvaliditySPKeyException {
		if (keyKind == KEY_FELICA || keyKind == KEY_NET_FELICA) {
			return CHECKUSER_RET_CHECK_SKIP;
		}
		 
		try {
			Util.debugPrint("USB Check");
			spKeyInfo = SPSJNI.getUSBUserInfo();
			if (spKeyInfo.getSerial().equals("")) {
				preError = false;
				ignoreUserServerCheck = false;
				throw new NoUSBException();
			}
		} catch (NoUSBException e) {
			preError = false;
			ignoreUserServerCheck = false;
			throw new NoUSBException(e.getMessage());
		}
		
		keyKind = KEY_USB;
		
		Util.debugPrint("ignoreUserServerCheck = " + ignoreUserServerCheck);
		
		return checkUserAtServer(msgConnection);
	}
	
	protected int checkNetFelica(Net net, String msgConnection) throws FelicaException, NetworkException, NotRegisterSPKeyException, InvaliditySPKeyException {
		if (keyKind == KEY_NET_FELICA || keyKind == KEY_FELICA) {
			return CHECKUSER_RET_CHECK_SKIP;
		}
		
		try {
			Util.debugPrint("Net Felica Check");
			spKeyInfo = SPSJNI.getNetFelicaUserInfo(Util.getPreferenceInfo().getCardRWAddr(), Util.getPreferenceInfo().getFelicaSysCode());
//			spKeyInfo = SPSJNI.getNetFelicaUserInfo(Util.getPreferenceInfo().getCardRWAddr(), Util.getPreferenceInfo().getFelicaSysCode());
		} catch (FelicaException e) {
			preError = false;
			ignoreUserServerCheck = false;
			throw new FelicaException(e.getMessage());
		}
		
		keyKind = KEY_FELICA;
		Util.debugPrint("IDm = " + spKeyInfo.getSerial());
		Util.debugPrint("ignoreUserServerCheck = " + ignoreUserServerCheck);
		
		return checkUserAtServer(msgConnection);
	}
/*
	protected int checkFelica(Net net, String msgConnection) throws FelicaException, NetworkException, NotRegisterSPKeyException, InvaliditySPKeyException {
		if (keyKind == KEY_NET_FELICA || keyKind == KEY_USB) {
			return CHECKUSER_RET_CHECK_SKIP;
		}
		
		try {
			Util.debugPrint("Felica Check");
			spKeyInfo = SPSJNI.getFelicaUserInfo();
			if (spKeyInfo.getSerial().equals("")) {
				preError = false;
				ignoreUserServerCheck = false;
				throw new FelicaException();
			}
		} catch (FelicaException e) {
			preError = false;
			ignoreUserServerCheck = false;
			throw new FelicaException(e.getMessage());
		}
		
		keyKind = KEY_FELICA;
		Util.debugPrint("ignoreUserServerCheck = " + ignoreUserServerCheck);
		
		return checkUserAtServer(msgConnection);
	}
*/	
	protected int checkUserAtServer(String msgConnection) throws NetworkException, NotRegisterSPKeyException, InvaliditySPKeyException {
		int	ret = CHECKUSER_RET_NORMAL;
		
		if (ignoreUserServerCheck) {
			return ret;
		}
		
		// 捠怣拞偺偲偒僗僉僢僾
		if (net.isConnected()) {
			Util.debugPrint("User Server check skip");
			preError = false;
			return CHECKUSER_RET_CONNECTION_SKIP;
		}
		
		if (getCheckPanel() != null && !preError) {
			((CheckSPKeyPanel)getCheckPanel()).setMessage(msgConnection);
		}
		
		preError = true;
		
		Vector	vcSPKeyInfo = new Vector();
		try {
			Util.debugPrint("User Server Check");
			vcSPKeyInfo = invoker.getSPKeyInfo();
			
/*			Util.debugPrint("Key_id = " + spKeyInfo.getSerial());
			Util.debugPrint("KeyKind = " + spKeyInfo.getKeyKind());
			Util.debugPrint("Validity = " + spKeyInfo.getValidity());*/
			
			int	i = 0;
			for (i = 0; i < vcSPKeyInfo.size(); i++) {
				SPKeyInfo	spKeyInfoSrv = (SPKeyInfo)vcSPKeyInfo.elementAt(i);
				
/*				Util.debugPrint("reg Key_id = " + spKeyInfoSrv.getSerial());
				Util.debugPrint("reg KeyKind = " + spKeyInfoSrv.getKeyKind());
				Util.debugPrint("reg Validity = " + spKeyInfoSrv.getValidity());*/
				
				if (spKeyInfoSrv.getSerial().equals(spKeyInfo.getSerial()) &&
						spKeyInfoSrv.getKeyKind() == spKeyInfo.getKeyKind()) {
					spKeyInfo = spKeyInfoSrv;
					if (spKeyInfoSrv.getValidity() == SPKeyInfo.VALIDITY_INVALIDITY) {
						ignoreUserServerCheck = false;
						Util.debugPrint("Invalidity SP Key");
						throw new InvaliditySPKeyException();
					} else {
						preError = false;
						ignoreUserServerCheck = true;
						ret = CHECKUSER_RET_NORMAL;
					}
					break;
				}
			}
			if (i == vcSPKeyInfo.size()) {
				Util.debugPrint("Not Register SP Key");
				throw new NotRegisterSPKeyException();
			}
		} catch (NetworkException e) {
			ignoreUserServerCheck = false;
			throw new NetworkException(e.getMessage());
		} catch (ServerException e) {
			ignoreUserServerCheck = false;
			throw new NetworkException(e.getMessage());
		} catch (TimeOutException e) {
			ignoreUserServerCheck = false;
			throw new NetworkException(e.getMessage());
		}
		
		return ret;
	}
	
	public void checkUser(String userName, String password, boolean bAdminCheck, Net net, String msgConnection) throws NetworkException, NotRegisteredUserException, InvalidUserException, WrongPasswordException {
		try {
			Object[]	result = userInvoker.isRegisteredUser(userName, Util.makePassword(password), bAdminCheck);
			int			res = ((Integer)result[0]).intValue();

			switch (res) {
			case 1:		// 枹搊榐儐乕僓
				preError = true;
				throw new NotRegisteredUserException();
			case 2:		// 娗棟幰儐乕僓偱側偄
				preError = true;
				throw new InvalidUserException();
			case 3:		// 僷僗儚乕僪晄堦抳
				preError = true;
				throw new WrongPasswordException();
			}
			
			preError = false;
			userInfo = ((UserInfo2)result[1]);
			
		} catch (NetworkException e) {
			preError = true;
			throw new NetworkException(e.getMessage());
		} catch (ServerException e) {
			preError = true;
			throw new NetworkException(e.getMessage());
		} catch (TimeOutException e) {
			preError = true;
			throw new NetworkException(e.getMessage());
		}
	}
	
	protected class AuthenticateUserThread extends Thread {
		
		String	password;
		
		public AuthenticateUserThread() {
			
		}
		
		public void run() {
			String		msg = "";
			char[]		password;
			String		stPass;
			
			try {
				try {
					// 儐乕僓擣徹
					if (checkLoginUserPanel.getUserName().equals("")) {	// 儐乕僓柤枹擖椡
						msg = Resource.getString(Resource.STATUS_NOT_INPUT_USERID);
						return;
					}
				
					preError = false;
					userInfo.setUserName(checkLoginUserPanel.getUserName());
					password = checkLoginUserPanel.getPassword();
					stPass = new String(password);
					userInfo.setPassword(stPass);
					checkUser(
						userInfo.getUserName(),
						userInfo.getPassword(),
						kind == ADMIN ? true : false,
						net,
						Resource.getString(Resource.CONNECT_SERVER_MESSAGE));
				
					goMainPanel(userInfo);
				} catch (NetworkException e) {							// 捠怣僄儔乕
					msg = Resource.getString(Resource.STATUS_NETWORK_ERROR);
				} catch (NotRegisteredUserException e) {				// 枹搊榐儐乕僓
					msg = Resource.getString(Resource.STATUS_NOT_REGISTERED_USER);
				} catch (InvalidUserException e) {						// 娗棟幰埲奜偺儐乕僓
					msg = Resource.getString(Resource.STATUS_NOT_ADMIN_USER);
				} catch (WrongPasswordException e) {
					msg = Resource.getString(Resource.STATUS_WRONG_PASSWORD);
				}
			} finally {
				checkLoginUserPanel.setState(true);
				
				if (!msg.equals("")) {
					preError = true;
					checkLoginUserPanel.setMessage(msg);
				}
				
				if (frame != null) {
					frame.requestFocus();
				}
			}
		}
	}
	
	private class CheckSPKeyTimerTask extends TimerTask {
		private Net	net;
		private String	msgConnection;
		public CheckSPKeyTimerTask(Net net, String msgConnection) {
			this.net = net;
			this.msgConnection = msgConnection;
		}
		
		public void run() {
			checkSPKey(net, msgConnection);
		}
	}
	
	protected abstract void goMainPanel(Object info);
	protected abstract void goCheckPanel();
	protected abstract void goRegPanel(Object info);
	protected abstract BasePanel getMainPanel();
	protected abstract BasePanel getCheckPanel();
	protected abstract BasePanel getRegPanel();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -