private static final String[] getNamesInternal(Map props) {
      String[] all = new String[] {
         Registry.SASL_SRP_MECHANISM,
         Registry.SASL_CRAM_MD5_MECHANISM,
         Registry.SASL_PLAIN_MECHANISM,
         Registry.SASL_ANONYMOUS_MECHANISM
      };

      List result = new ArrayList(4);
      int i;
      for (i = 0; i < all.length; ) {
         result.add(all[i++]);
      }

      if (props == null) {
        return (String[]) result.toArray(new String[0]); // all
      }
      if (hasPolicy(Sasl.POLICY_PASS_CREDENTIALS, props)) { // none
         return new String[0];
      }

      if (hasPolicy(Sasl.POLICY_NOPLAINTEXT, props)) {
         result.remove(Registry.SASL_PLAIN_MECHANISM);
      }
      if (hasPolicy(Sasl.POLICY_NOACTIVE, props)) {
         result.remove(Registry.SASL_CRAM_MD5_MECHANISM);
         result.remove(Registry.SASL_PLAIN_MECHANISM);
      }
      if (hasPolicy(Sasl.POLICY_NODICTIONARY, props)) {
         result.remove(Registry.SASL_CRAM_MD5_MECHANISM);
         result.remove(Registry.SASL_PLAIN_MECHANISM);
      }
      if (hasPolicy(Sasl.POLICY_NOANONYMOUS, props)) {
         result.remove(Registry.SASL_ANONYMOUS_MECHANISM);
      }
      if (hasPolicy(Sasl.POLICY_FORWARD_SECRECY, props)) {
         result.remove(Registry.SASL_CRAM_MD5_MECHANISM);
         result.remove(Registry.SASL_ANONYMOUS_MECHANISM);
         result.remove(Registry.SASL_PLAIN_MECHANISM);
      }
      return (String[]) result.toArray(new String[0]);
   }