Filtering the list of published applications on a XenApp Web Site is something we've done for many years now. Recently we had a request to set up a XenApp Services Site where the list of displayed applications is controlled by an "allowed" list.

There is a Citrix Knowledge Center that helpfully tells you how to achieve exactly that:

http://support.citrix.com/article/CTX123969

This approach involves putting a "#" as the first character in the Application Description field on a published application that you wish to hide. It works perfectly, but it was not suitable in our environment for two main reasons:

  • We have already used the Application Description field for something else (involves NetScaler policies - long story)
  • We have over 400 published applications split across multiple farms so amending pretty much all of them was going to be rather painful

We wanted to list just a small, specific list of apps to users connected to that Services site. So a few people pitched in and we came up with some modified Java code.

This was tested on Web Interface version 5.4 but should work on all 5.x variants (but we have not tested on anything other than v5.4).

Edit: Tested successfully on CWI v5.3 as well.

Steps

Create a new XenApp Services Site (or use one you already have). On our server, we created the website in the path C:\inetpub\FilteredPN.

Locate the file Enumeration.java in the path C:\inetpub\FilteredPN\Citrix\PNAgent\app_code\PagesJava\com\citrix\wi\pna. You might want to take a backup of this file before you start messing with it.

Locate the line import java.io.IOException; at the beginning of the file and alter it.

Before: import java.io.IOException;
After: import java.io.*;

Next, locate the following line in the same file (nearly at the very end of the file):

ResourceInfo[] resources = enumRequest.getAllResources();

Just below that line, insert the following block of code:

java.util.ArrayList listofapps = new java.util.ArrayList();
java.util.ArrayList filteredapps = new java.util.ArrayList();

FileInputStream in = new FileInputStream("C:\\inetpub\\FilteredPN\\AllowedApps.txt");
BufferedReader br = new BufferedReader ( new InputStreamReader(in));
String line;
while ((line = br.readLine()) != null)
	listofapps.add(line);
		for (int i=0; i<resources.length; i++) {
			for (int j=0; j<listofapps.size(); j++){
				String checkapp = (String)listofapps.get(j);
				checkapp = checkapp.trim();
				if(resources[i].getDisplayName().equals (checkapp)){
					filteredapps.add(resources[i]);
				}
			}
		}
resources = (ResourceInfo[]) filteredapps.toArray( new ResourceInfo[0] );

Create a text file called C:\inetpub\FilteredPN\AllowedApps.txt.

Edit the text file and add the apps you want displayed, one per line.
For example, something like this:

Notepad
Microsoft Word
My Corporate App
Helpdesk App

That's pretty much it! You should now have a working Services site that only displays an explicitly defined list of applications.

If you want to hide specific apps and display everything else, use this block of code instead.

java.util.ArrayList listofapps = new java.util.ArrayList();
java.util.ArrayList filteredapps = new java.util.ArrayList();

FileInputStream in = new FileInputStream("C:\\inetpub\\FilteredPN\\HiddenApps.txt");
BufferedReader br = new BufferedReader ( new InputStreamReader(in));
String line;
while ((line = br.readLine()) != null)
		listofapps.add(line);

		for (int i=0; i<resources.length; i++) {
					boolean inlist = false;
					for (int j=0; j<listofapps.size(); j++){
								String checkapp = (String)listofapps.get(j);
								checkapp = checkapp.trim();
								if(resources[i].getDisplayName().equals (checkapp)){
											inlist = true;
								}
					}
		  if (!inlist) {
				filteredapps.add(resources[i]);
		 }           
		}
		resources = (ResourceInfo[]) filteredapps.toArray( new ResourceInfo[0] );

Create a text file called C:\inetpub\FilteredPN\HiddenApps.txt.

Edit the text file and add the apps you want hidden, one per line.
For example, something like this:

Notepad
Microsoft Word
My Corporate App
Helpdesk App

That's it. Hope that was useful.