public SubscriberKeyMgtClient(String backendServerURL, String username, String password)
      throws Exception {
    try {
      AuthenticationAdminStub authenticationAdminStub =
          new AuthenticationAdminStub(null, backendServerURL + "AuthenticationAdmin");
      ServiceClient authAdminServiceClient = authenticationAdminStub._getServiceClient();
      authAdminServiceClient.getOptions().setManageSession(true);
      authenticationAdminStub.login(username, password, new URL(backendServerURL).getHost());
      ServiceContext serviceContext =
          authenticationAdminStub._getServiceClient().getLastOperationContext().getServiceContext();
      String authenticatedCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING);

      if (log.isDebugEnabled()) {
        log.debug(
            "Authentication Successful with AuthenticationAdmin. "
                + "Authenticated Cookie ID : "
                + authenticatedCookie);
      }

      subscriberServiceStub =
          new APIKeyMgtSubscriberServiceStub(null, backendServerURL + "APIKeyMgtSubscriberService");
      ServiceClient client = subscriberServiceStub._getServiceClient();
      Options options = client.getOptions();
      options.setManageSession(true);
      options.setProperty(
          org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, authenticatedCookie);
    } catch (Exception e) {
      String errorMsg = "Error when instantiating SubscriberKeyMgtClient.";
      log.error(errorMsg, e);
      throw e;
    }
  }
 public ApplicationKeysDTO getApplicationAccessKey(
     String userId, String applicationName, String keyType) throws Exception {
   return subscriberServiceStub.getApplicationAccessToken(userId, applicationName, keyType);
 }
 public String getAccessKey(
     String userId, APIInfoDTO apiInfoDTO, String applicationName, String keyType)
     throws Exception {
   return subscriberServiceStub.getAccessToken(userId, apiInfoDTO, applicationName, keyType);
 }