public void execute() throws TestException { // Step 0: Set up CSP BasicCSPInformation cspInformation = super.getCspInformation(); CSP csp = new BasicCSP(cspInformation); // Step 1: Check if the phone number and e-mail address are available try { if (verifiedEmail == null || verifiedPhone == null) { throw new TestException("Tester Data not set up: verifiedEmail: verifiedPhone "); } CloudNumber[] existingCloudNumbers = csp.checkPhoneAndEmailAvailableInRN(verifiedPhone, verifiedEmail); System.out.println( "For verified phone number " + verifiedPhone + " and verified e-mail address " + verifiedEmail + " found Cloud Numbers: " + Arrays.asList(existingCloudNumbers)); } catch (Xdi2ClientException e) { throw new TestException(e.getMessage()); } }
public void changePassword( String env, String cspName, String cspPassword, String cloudNameString, String currentPassword, String newPassword) { // Step 0: Set up CSP CloudNumber cspCloudNumber = null; String cspRegistryURL = ""; String cspUserURL = ""; XDIDiscoveryClient discoveryClient = null; String registrationSvcURL = ""; if (env.equalsIgnoreCase("prod")) { discoveryClient = XDIDiscoveryClient.NEUSTAR_PROD_DISCOVERY_CLIENT; cspRegistryURL = "https://mycloud.neustar.biz/" + cspName + "-registry"; cspUserURL = "https://mycloud.neustar.biz/" + cspName + "-users/"; registrationSvcURL = "https://registration.respectnetwork.net/registration"; } else if (env.equalsIgnoreCase("ote")) { discoveryClient = XDIDiscoveryClient.NEUSTAR_OTE_DISCOVERY_CLIENT; cspRegistryURL = "https://mycloud-ote.neustar.biz/" + cspName + "-registry"; cspUserURL = "https://mycloud-ote.neustar.biz/" + cspName + "-users/"; registrationSvcURL = "https://registration-stage.respectnetwork.net/registration"; } else if (env.equalsIgnoreCase("prod-au")) { discoveryClient = XDIDiscoveryClient.NEUSTAR_PROD_DISCOVERY_CLIENT; cspRegistryURL = "https://mycloud-au.neustar.biz/" + cspName + "-registry"; ; cspUserURL = "https://mycloud-au.neustar.biz/" + cspName + "-users/"; registrationSvcURL = "https://registration.respectnetwork.net/registration"; } System.out.println("CSP Resistry URL:" + cspRegistryURL); System.out.println("CSP User URL:" + cspUserURL); System.out.println("Regn. svc. URL:" + registrationSvcURL); System.out.println("Discovery info:" + discoveryClient.toString()); try { XDIDiscoveryResult discResult = discoveryClient.discover(XDIAddress.create("+" + cspName)); cspCloudNumber = discResult.getCloudNumber(); System.out.println("CSP Cloud Number : " + cspCloudNumber.toString()); } catch (Xdi2ClientException e) { System.out.println("Xdi2ClientException: " + e.getMessage()); e.printStackTrace(); } BasicCSPInformation cspInformation = new BasicCSPInformation( cspCloudNumber, cspRegistryURL, cspUserURL, cspPassword, null, CloudNumber.create("[+]!:uuid:ca51aeb9-e09e-4305-89d7-87a944a1e1fa"), registrationSvcURL, XDIAddress.create("([+]!:uuid:ca51aeb9-e09e-4305-89d7-87a944a1e1fa/#registrar)$do"), null, discoveryClient); System.out.println("CSP Information:\n" + cspInformation.toString()); cspInformation.setRnCspSecretToken(null); try { cspInformation.retrieveCspSignaturePrivateKey(); } catch (Xdi2ClientException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } catch (GeneralSecurityException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } if (cspInformation.getCspSignaturePrivateKey() == null) { System.err.println("Invalid CSP Information."); System.exit(0); } cloudName = CloudName.create(cloudNameString); if (cloudName == null || !cloudNameString.startsWith("=")) { System.err.println("Invalid Cloud Name."); System.exit(0); } try { XDIDiscoveryResult discResult = discoveryClient.discover(XDIAddress.create(cloudNameString)); cloudNumber = discResult.getCloudNumber(); System.out.println("Cloud Number : " + cloudNumber.toString()); } catch (Xdi2ClientException e) { System.out.println("Xdi2ClientException: " + e.getMessage()); e.printStackTrace(); } try { CSP csp = new BasicCSP(cspInformation); // Step 1: authenticate user try { csp.authenticateInCloud(cloudNumber, currentPassword); } catch (Xdi2ClientException badpass) { System.out.println("Cannot authenticate. Exiting ..."); System.exit(0); } // Step 2: Change Secret Token csp.setCloudSecretTokenInCSP(cloudNumber, newPassword); // done System.out.println("Done Changing password for cloudname " + cloudNameString); } catch (RuntimeException ex1) { ex1.printStackTrace(); } catch (Xdi2ClientException ex2) { ex2.printStackTrace(); } }