Community articlegetCertificateList method
Added by IBM contributorIBM on May 2, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

This method locates all available certificates that can be used by a particular signature button. The certificates are filtered according to the signature engine defined in the signformat option of the button, and according to the filters defined in the signdetails option of the button.



This method locates all available certificates that can be used by a particular signature button. The certificates are filtered according to the signature engine defined in the signformat option of the button, and according to the filters defined in the signdetails option of the button.
This method returns the valid certificates in an undetermined order. This means that you cannot rely on the certificates being listed in the same order each time you call this method.

Method

   public Certificate  [ ] getCertificateList(
      String theFilters,
      IntHolder theStatus,
   ) throws UWIException;


Parameters

Table 1. Method parameters
ExpressionTypeDescription
theFiltersStringA string that is used to filter the subject attribute of the certificate. If the subject attribute include this substring, then that certificate will be listed.
For example, you might filter against a name, such as "John Doe", or an e-mail address, such as "jdoe@ibm.com".
Note that this filter is in addition to the other filters defined in the signdetails option of the button.
If null is passed, then only the filters in the signdetails option are used.
theStatusIntHolderThis is a status flag that reports whether the operation was successful. Possible values are:
SecurityUserStatusType.SUSTATUS_OK — the operation was successful.
SecurityUserStatusType.SUSTATUS_ CANCELLED — the operation was cancelled by the user.
SecurityUserStatusType.SUSTATUS_INPUT_ REQUIRED — the operation required user input, but could not receive it (for example, it was run on a server with no user).


Returns

An array containing the list of certificates objects.

Example

In the following example, dereferenceEx is used to locate a specific signature button node. getCertificateList is then used to get a list of valid certificates for that button. Next, getDataByPath is used to search the certificate list for the IBM® Forms Server certificate, which signForm then uses to sign the button.
   private static void createSignature(FormNodeP theForm)throws Exception
   {
   FormNodeP buttonNode;
   IntHolder theStatus;
   Signature theSignature;
   Certificate  [] certList;
   String signerCommonName;
   boolean encodedResult;
   int correctCert = -1;
 
      if ((buttonNode = theForm.dereferenceEx(null, "PAGE1.SIGBUTTON1", 
         0, FormNodeP.UFL_ITEM_REFERENCE, null)) == null)
      {
         throw new UWIException("Could not locate SIGBUTTON1 node.");
      }
 
      theStatus = new IntHolder();
 
      certList = buttonNode.getCertificateList(null, theStatus);
      if (theStatus.value == securityUserStatusType.SUSTATUS_INPUT_REQUIRED)
      {
         throw new UWIException("User input required to sign form.");
      }
 
      certCount = certList.length;
      encodedResult = new BooleanHolder;
 
      for (i=0; i<certCount; i++)
      {
         signerCommonName = certList [i].getDataByPath(
            "SigningCert: Subject: CN", false, encodedResult);
         if (signerCommonName.equals("IBM Forms Server"))
         {
            correctCert = i;
            break;
         }
      }
 
      if (correctCert == -1)
      {
        for (i=0; i<certCount; i++)
        {
          certList [i].release();
        }
        throw new UWIException("Could not locate required certificate");
      }
 
      theSignature = buttonNode.signForm(certList [correctCert],null,theStatus);
      theSignature.release();
            
      /* release each certificate */
      for (i=0; i<certCount; i++)
      {
        certList [i].release();
      }
 
      if (theStatus.value == SUSTATUS_INPUT_REQUIRED)
      {
         throw new UWIException("User input required to sign form.");
      }
   }


Parent topic:
FormNodeP class