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

📄 testjndibulkops.java

📁 JAVA开源LDAP浏览器jxplorer的源码!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		
		if (url==null)
		{
			System.out.println("Problem accessing the computer name from the property file 'BulkJndiTest.txt'."+
								"Please check that a valid name is supplied in the 'ComputerName' entry.");
		 	System.exit(-1);
		}		

		Thread[] threads = new Thread[] {new Thread(new Test(properties.getProperty("ThreadOneLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread ONE"),
										 new Thread(new Test(properties.getProperty("ThreadTwoLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread TWO"),	
										 new Thread(new Test(properties.getProperty("ThreadThreeLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread THREE"),
										 new Thread(new Test(properties.getProperty("ThreadFourLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread FOUR"),
										 new Thread(new Test(properties.getProperty("ThreadFiveLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread FIVE"),
										 new Thread(new Test(properties.getProperty("ThreadSixLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread SIX"), 
										 new Thread(new Test(properties.getProperty("ThreadSevenLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread SEVEN"), 
										 new Thread(new Test(properties.getProperty("ThreadEightLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread EIGHT"),
										 new Thread(new Test(properties.getProperty("ThreadNineLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread NINE"),
										 new Thread(new Test(properties.getProperty("ThreadTenLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread TEN"),
										 new Thread(new Test(properties.getProperty("ThreadElevenLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread ELEVEN"),
										 new Thread(new Test(properties.getProperty("ThreadTwelveLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread TWELVE"),	
										 new Thread(new Test(properties.getProperty("ThreadThreeteenLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread THIRTEEN"),
										 new Thread(new Test(properties.getProperty("ThreadFourteenLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread FOURTEEN"),
										 new Thread(new Test(properties.getProperty("ThreadFifteenLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread FIFTTEEN"),
										 new Thread(new Test(properties.getProperty("ThreadSixteenLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread SIXTEEN"), 
										 new Thread(new Test(properties.getProperty("ThreadSeventeenLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread SEVENTEEN"), 
										 new Thread(new Test(properties.getProperty("ThreadEighteenLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread EIGHTEEN"),
										 new Thread(new Test(properties.getProperty("ThreadNineteenLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread NINETEEN"),
										 new Thread(new Test(properties.getProperty("ThreadTwentyLDIFFileName").toString(), 	url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag, numberOfIterations), "Test Thread TWENTY")};		

		for(int i=0; i<numberOfThreads; i++)
		{
			try
			{
				threads[i].start();
				System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"+
						  		 "Starting Thread: " + threads[i].getName() +
						  		 "\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");			
			}
			catch(IllegalThreadStateException  e)
			{
				System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"+
						  		   "Error Starting Thread: " + threads[i].getName() +
						  		   "\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +e);
			}			
		}				
    }
	


   /**
    *	Class basically kicks off the jnditests, but instead of only running
	*	through an LDIF file once, this allows the user to specify (via BulkJndiTest)
	*	how many iterations to do.
	*	@author Trudi.
	*/
		
	class Test implements Runnable 
	{		
	    String 		fileName = null;
	    String 		url = null;
	    String 		user = null;
	    String 		pwd  = null;
	    String 		version = "3";
	    String 		referral = "follow";
	    boolean 	useSSL = false;
	    boolean 	tracing = false;
	    boolean 	debugFlag = false;
	    boolean 	terminateFlag = false;	
		boolean		printstackFlag = false;
		int 		numberOfIterations = -1; 	
			
	   /**
	    *	Constructor that assigns the following global variables.
	    *   @param fileName        		the name of an LDIF changes input file.
	    *   @param url             		a url of the form ldap://hostname:portnumber.
	    *   @param user            		a user to bind to the directory as.
	    *   @param pwd             		the user's password. 
	    *   @param tracing         		whether to set BER tracing on or not.
	    *   @param version         		the LDAP Version (2 or 3) being used.
		*	@param debugFlag			echo all system statement.
		*	@param terminateFlag		exit on error, returning -1.
		*	@param referral				the jndi referral type [follow|ignore|throw].
		*	@param useSSL				to use SSL.
		*	@param printstackFlag		whether to print a stack trace.
		*	@param numberOfIterations	the number of times the user wants the tests to run through the LDIF file.				
		*/
				
		public Test(String fileName, String url, String user, String pwd, boolean tracing, String version, boolean debugFlag, boolean terminateFlag, String referral, boolean useSSL, boolean printstackFlag, int numberOfIterations)
		{
		    this.fileName = fileName;
		    this.url = url;
		    this.user = user;
		    this.pwd  = pwd;
		    this.version = version;
		    this.referral = referral;
		    this.useSSL = useSSL;
		    this.tracing = tracing;
		    this.debugFlag = debugFlag;
		    this.terminateFlag = terminateFlag;
			this.printstackFlag = printstackFlag;
			this.numberOfIterations	= numberOfIterations; 	
		}
		
		

	   /**
	    *	Creates a new jnditest object for each time the user wants the jnditests to 
		*	test an LDIF file.
		*/
				
		public void run()
		{
			for(int i=1;i<=numberOfIterations;i++)
			{	
				myJndiTest tester = new myJndiTest(fileName, url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag);										
	        	tester.processInput();
	        
		        tester.out.println("\n*****************************************************************************************" +
								   "\n* FINISHED TESTING OF THREAD: '"+Thread.currentThread().toString()+ "' ITERATION: "+i+ 
								   "\n*****************************************************************************************");	
			}
		}
		
	}		
	
	
	
   /**
    *	Class extend jnditest to allow for custom url to be used on connection i.e so that 
	*	instead of grabbing the url from the LDIF file this will set it from the url supplied
	*	in the constructor.
	*	@author Trudi.
	*/
		
	class myJndiTest extends TestJNDIOps
	{
		String myUrl;
		
		public myJndiTest(String fileName, String url, String user, String pwd, boolean tracing, String version, boolean debugFlag, boolean terminateFlag, String referral, boolean useSSL, boolean printstackFlag)
		{
			super(fileName, url, user, pwd, tracing, version, debugFlag, terminateFlag, referral, useSSL, printstackFlag);
			this.myUrl = url;
		}
		
    
	   /**
	    *   Opens a connection in the same manner as jnditest.connect but uses a url supplied by
		*	the constructor.
	    *   @param entry a 'fake' entry with no dn, but a bunch of attributes.
	    */
	    
	    public void connect(DXEntry entry)
	    {
	        if (debug) System.out.println("connect: " + entry);
	        if (myOps != null)
	        {
	        	try
	        	{
					myOps.close();
				}
				catch (NamingException e) 
				{
					System.err.println("exception closing ops");
					e.printStackTrace();
				}
	        } 
	      
		  	String url = "";
			
		  	if(myUrl!=null)
	        	url = myUrl;
			else
				url = entry.getString("url");	
	        String user = entry.getString("user");
	        String pwd = entry.getString("pwd");
	        String tracing = entry.getString("tracing");
	        String version = entry.getString("ldapVersion");
	        String referral = entry.getString("referral");
	        String useSSL = entry.getString("useSSL");
	     
	        boolean trace = ((tracing != null) && (tracing.equalsIgnoreCase("true")));
	        boolean ssl = ((useSSL != null) && (useSSL.equalsIgnoreCase("true")));
	        openConnection(url, user, pwd, trace, version, referral, ssl);
	    }						
	}
}

⌨️ 快捷键说明

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