clientapilevelauthenticationimpl.java

来自「中兴公司在parlayx开发方面的培训文档」· Java 代码 · 共 64 行

JAVA
64
字号
package samples.fw;

public class ClientAPILevelAuthenticationImpl 
	extends org.csapi.fw.fw_access.trust_and_security.IpClientAPILevelAuthenticationPOA
{
    boolean authenticated = false;

	public ClientAPILevelAuthenticationImpl(){}

	byte[] clientChallenge = {(byte)111,(byte)21,(byte)214,(byte)65,(byte)196,(byte)22,(byte)222};
	public byte[] authenticate (byte[] challenge)
	{
        (new Thread() {
          public void run() {
              try {
              	Thread.sleep(1000); // let the fw challenge get back first
              	byte[] ret = 
              		AppFWImpl.ipAPILevelAuthentication.authenticate(clientChallenge);
              	// to check ret is valid		
                if (!validateChallenge(AppFWImpl.authMethodName,ret))
                {
                	System.out.println("Framework failed challenge");
                	System.exit(1);
                }
              }
              catch(Exception e) {}
          }
        }).start();
		return applyAuthMethod(AppFWImpl.authMethodName, challenge);
	}
	
	public void abortAuthentication ()
	{
    	System.out.println("Framework abort the authentication");
    	System.exit(1);
	}
	
	public void authenticationSucceeded ()
	{
        authenticated = true;
        final Object lock = AppFWImpl.getInstance();
        (new Thread() {
          public void run() {
              synchronized (lock) {
                      try {
                              lock.notify();
                      }
                      catch(Exception e) {}
              }
          }
        }).start();
	}
	
	byte[] applyAuthMethod(String authName, String challenge)
	{
		// just to return enpty array.
		// 
		return new byte[0]; 
	}
	boolean validateChallenge(String authName, String challengeRet)
	{
		return true;
	}
}

⌨️ 快捷键说明

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