Ejemplo n.º 1
0
  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;
    }
  }
Ejemplo n.º 2
0
 public ApplicationKeysDTO getApplicationAccessKey(
     String userId, String applicationName, String keyType) throws Exception {
   return subscriberServiceStub.getApplicationAccessToken(userId, applicationName, keyType);
 }
Ejemplo n.º 3
0
 public String getAccessKey(
     String userId, APIInfoDTO apiInfoDTO, String applicationName, String keyType)
     throws Exception {
   return subscriberServiceStub.getAccessToken(userId, apiInfoDTO, applicationName, keyType);
 }