/**
  * Revoking a certificate with a given name and a given reason
  *
  * @param serialNo serial number of revoking certificate
  * @param reason revoke reason
  * @throws AxisFault
  */
 public void revokeCert(String serialNo, int reason) throws AxisFault {
   try {
     stub.revokeCert(serialNo, reason);
   } catch (Exception e) {
     String message = e.getMessage();
     handleException(e.getMessage(), e);
   }
 }
 /**
  * Instantiates CAAdminServiceClient
  *
  * @param cookie For session management
  * @param backendServerURL URL of the back end server where CAAdminService is running.
  * @param configCtx ConfigurationContext
  * @throws org.apache.axis2.AxisFault
  */
 public CAAdminServiceClient(
     String cookie, String backendServerURL, ConfigurationContext configCtx) throws AxisFault {
   String serviceURL = backendServerURL + "CAAdminService";
   stub = new CAAdminServiceStub(configCtx, serviceURL);
   ServiceClient client = stub._getServiceClient();
   Options option = client.getOptions();
   option.setManageSession(true);
   option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
 }
 /**
  * Get the list of certificates queried from a given status
  *
  * @param status status of the certificate
  * @return list of certificates with a given status
  * @throws AxisFault
  */
 public CertificateMetaInfo[] getCertificatesFromStatus(String status) throws AxisFault {
   try {
     return stub.getCerts(status);
   } catch (Exception e) {
     String message = e.getMessage();
     handleException(e.getMessage(), e);
   }
   return null;
 }
 /**
  * Returns CSR Files queried by a given common name
  *
  * @param commonName common name of the CSR file
  * @return CSR File with a given common name
  * @throws AxisFault
  */
 public CsrMetaInfo[] getCSRsFromCommonName(String commonName) throws AxisFault {
   try {
     return stub.getCsrfromCN(commonName);
   } catch (Exception e) {
     String message = e.getMessage();
     handleException(e.getMessage(), e);
   }
   return null;
 }
 /**
  * Returns the list of CSR Files queried from a given status
  *
  * @param status
  * @return CSR File list with a given status
  * @throws AxisFault
  */
 public CsrMetaInfo[] getCSRsFromType(String status) throws AxisFault {
   try {
     return stub.getCsrListWithStatus(status);
   } catch (Exception e) {
     String message = e.getMessage();
     handleException(e.getMessage(), e);
   }
   return null;
 }
 /**
  * Returns the revoke reason of a ceritificate with a given serial number
  *
  * @param serialNo serial number of certificate
  * @return revoke reason
  * @throws AxisFault
  */
 public int getRevokeReason(String serialNo) throws AxisFault {
   try {
     return stub.getRevokedReason(serialNo);
   } catch (Exception e) {
     String message = e.getMessage();
     handleException(e.getMessage(), e);
   }
   return 0;
 }
 /**
  * Returns the list of keyAliases
  *
  * @return keyAlias list
  * @throws AxisFault
  */
 public String[] getListKeyAliases() throws AxisFault {
   try {
     return stub.listKeyAliases();
   } catch (Exception e) {
     String message = e.getMessage();
     handleException(e.getMessage(), e);
   }
   return null;
 }
 /**
  * Returns a certificate from a given serial number
  *
  * @param serialNo serial number of certificate
  * @return certificate
  * @throws AxisFault
  */
 public CertificateDTO getCertificateBySerialNo(String serialNo) throws AxisFault {
   try {
     return stub.getCertificate(serialNo);
   } catch (Exception e) {
     String message = e.getMessage();
     handleException(e.getMessage(), e);
   }
   return null;
 }
 /**
  * Returns the list of keystores
  *
  * @return keystore list
  * @throws AxisFault
  */
 public String[] getKeyStoreList() throws AxisFault {
   try {
     return stub.listKeyAliases();
   } catch (RemoteException e) {
     handleException(e.getMessage(), e);
   } catch (CAAdminServiceCaException e) {
     handleException(e.getMessage(), e);
   }
   return new String[0];
 }
  /**
   * Returns the list of CSR Files belongs to the tenant
   *
   * @return list of CSR Files
   * @throws AxisFault
   */
  public CsrMetaInfo[] getCSRFileList() throws AxisFault {

    try {
      return stub.getAllCsrs();
    } catch (Exception e) {
      String message = e.getMessage();
      handleException(e.getMessage(), e);
    }
    return null;
  }
 public void changeKeyStore(String keyPath) throws AxisFault {
   String[] keyStoreAndAlias = keyPath.split("/");
   if (keyStoreAndAlias.length == 2) {
     try {
       stub.setKeyStoreAndAlias(keyStoreAndAlias[0], keyStoreAndAlias[1]);
     } catch (Exception e) {
       handleException(e.getMessage(), e);
     }
   }
 }
  /**
   * Returns CSR File with a given serial number
   *
   * @return CSR File Serial Number
   * @throws AxisFault
   */
  public CsrDTO getCSRFromSerialNo(String serialNo) throws AxisFault {

    try {
      return stub.getCsr(serialNo);
    } catch (Exception e) {
      String message = e.getMessage();
      handleException(e.getMessage(), e);
    }
    return null;
  }
 /**
  * Reject the CSR file with a given serial number
  *
  * @param serialNo serial number of rejecting CSR
  */
 public void rejectCSR(String serialNo) {
   try {
     stub.rejectCSR(serialNo);
   } catch (RemoteException e) {
     // todo: exception handling
     e.printStackTrace();
   } catch (CAAdminServiceCaException e) {
     e.printStackTrace();
   }
 }
 /**
  * Sign the CSR file with a given serial number and validity period
  *
  * @param serial serial number of signing CSR
  * @param validity validity period
  */
 public void sign(String serial, int validity) {
   try {
     stub.signCSR(serial, validity);
   } catch (RemoteException e) {
     // todo: exception handling
     e.printStackTrace();
   } catch (CAAdminServiceCaException e) {
     e.printStackTrace();
   }
 }
  /**
   * Returns the list of Certificates issued
   *
   * @return Certificate File List
   * @throws AxisFault
   */
  public CertificateMetaInfo[] getPubCertList() throws AxisFault {

    try {
      return stub.getAllCerts();

    } catch (Exception e) {
      String message = e.getMessage();
      handleException(e.getMessage(), e);
    }
    return null;
  }