public static PolicyConfigurationFactory getPolicyConfigurationFactory() throws ClassNotFoundException,
         PolicyContextException
   {
      // Validate the caller permission
      SecurityManager sm = System.getSecurityManager();
      if (sm != null)
         sm.checkPermission(new SecurityPermission("setPolicy"));

      synchronized (PolicyConfigurationFactory.class)
      {
    	  if (factory == null)
    	  {
    		  String factoryName = null;
    		  Class<?> clazz = null;
    		  try
    		  {
    			  LoadAction action = new LoadAction();
    			  try
    			  {
    				  clazz = AccessController.doPrivileged(action);
    				  factoryName = action.getName();
    			  }
    			  catch (PrivilegedActionException ex)
    			  {
    				  factoryName = action.getName();
    				  Exception e = ex.getException();
    				  if (e instanceof ClassNotFoundException)
    					  throw (ClassNotFoundException) e;
    				  else
    					  throw new PolicyContextException("Failure during load of class: " + factoryName, e);
    			  }
    			  factory = (PolicyConfigurationFactory) clazz.newInstance();
    		  }
    		  catch (ClassNotFoundException e)
    		  {
    			  String msg = "Failed to find PolicyConfigurationFactory : " + factoryName;
    			  throw new ClassNotFoundException(msg, e);
    		  }
    		  catch (IllegalAccessException e)
    		  {
    			  String msg = "Unable to access class : " + factoryName;
    			  throw new PolicyContextException(msg, e);
    		  }
    		  catch (InstantiationException e)
    		  {
    			  String msg = "Failed to create instance of: " + factoryName;
    			  throw new PolicyContextException(msg, e);
    		  }
    		  catch (ClassCastException e)
    		  {
    			  StringBuffer msg = new StringBuffer(factoryName + " Is not a PolicyConfigurationFactory, ");
    			  msg.append("PCF.class.CL: " + PolicyConfigurationFactory.class.getClassLoader());
    			  msg.append("\nPCF.class.CS: " + PolicyConfigurationFactory.class.getProtectionDomain().getCodeSource());
    			  msg.append("\nPCF.class.hash: " + System.identityHashCode(PolicyConfigurationFactory.class));
    			  msg.append("\nclazz.CL: " + clazz.getClassLoader());
    			  msg.append("\nclazz.CS: " + clazz.getProtectionDomain().getCodeSource());
    			  msg.append("\nclazz.super.CL: " + clazz.getSuperclass().getClassLoader());
    			  msg.append("\nclazz.super.CS: " + clazz.getSuperclass().getProtectionDomain().getCodeSource());
    			  msg.append("\nclazz.super.hash: " + System.identityHashCode(clazz.getSuperclass()));
    			  ClassCastException cce = new ClassCastException(msg.toString());
    			  cce.initCause(e);
    			  throw cce;
    		  }
    	  }
      }
      return factory;
   }