Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. public void init() throws AxisFault{
  2. userName = HDConstants.USER_NAME;
  3. password = HDConstants.PASSWORD;
  4. backEndServerURL = HDConstants.SERVER_URL;
  5.  
  6. setKeyStore();
  7. configCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
  8. }
  9.  
  10. public void setKeyStore() {
  11. System.setProperty("javax.net.ssl.trustStore", HDConstants.TRUST_STORE_PATH);
  12. System.setProperty("javax.net.ssl.trustStorePassword", HDConstants.TRUST_STORE_PASSWORD);
  13. System.setProperty("javax.net.ssl.trustStoreType", HDConstants.TRUST_STORE_TYPE);
  14. }
  15.  
  16. public boolean authenticateUser(String userName, String password) throws Exception {
  17. String serviceURL = null;
  18. ServiceClient client = null;
  19. Options option = null;
  20. boolean isAuthenticated = false;
  21. AuthenticationAdminStub authStub = null;
  22.  
  23. serviceURL = backEndServerURL + "AuthenticationAdmin";
  24. authStub = new AuthenticationAdminStub(configCtx, serviceURL);
  25. client = authStub._getServiceClient();
  26. option = client.getOptions();
  27. option.setManageSession(true);
  28. option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, authCookie);
  29. isAuthenticated = authStub.login(userName, password, HDConstants.APP_ID);
  30. authCookie = (String) authStub._getServiceClient().getServiceContext()
  31. .getProperty(HTTPConstants.COOKIE_STRING);
  32. System.out.println(" Auth Cookie ==== " + authCookie);
  33. return isAuthenticated;
  34. }
  35. `
  36.  
  37. AuthenticationServiceClient authenticationServiceClient = new AuthenticationServiceClient();
  38. authenticationServiceClient.init();
  39. authenticationServiceClient.authenticateUser("admin", "admin");
  40.  
  41. at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:688)
  42. at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:124)
  43. at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:887)
  44. at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:116)
  45. at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
  46. at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:210)
  47. at com.home.hduser.wsois.AuthenticationServiceClient.init(AuthenticationServiceClient.java:29)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement