Skip to content

Changing the Secret Token for a Cloud Name

Markus Sabadello edited this page Nov 21, 2013 · 3 revisions

Example Code:

package net.respectnetwork.sdk.csp.example;

import net.respectnetwork.sdk.csp.BasicCSP;
import net.respectnetwork.sdk.csp.BasicCSPInformation;
import net.respectnetwork.sdk.csp.CSP;
import net.respectnetwork.sdk.csp.CSPInformation;
import net.respectnetwork.sdk.csp.CloudNameRegistration;
import xdi2.client.exceptions.Xdi2ClientException;
import xdi2.core.xri3.XDI3Segment;

public class ExampleChangeSecretToken {

	/* CHOOSE THE INDIVIDUAL's CLOUD NAME HERE */
	private static XDI3Segment cloudName = XDI3Segment.create("=dev.test.531");

	/* CHOOSE THE INDIVIDUAL's SECRET TOKEN HERE */
	private static String secretToken = "mynewsecret";

	public static void main(String[] args) throws Xdi2ClientException {

		CloudNameRegistration cloudNameRegistration;

		// step 0: Set up CSP object

		CSPInformation cspInformation = /* ... */;

		CSP csp = new BasicCSP(cspInformation);

		// step 1: Look for registered Cloud Name

		cloudNameRegistration = csp.checkCloudNameAvailable(cloudName);
		if (cloudNameRegistration == null) throw new RuntimeException("Cloud Name " + cloudName + " does not exist.");

		// step 2: Change Secret Token

		csp.generateCloudSecretToken(cloudNameRegistration, secretToken);

		// done

		System.out.println("Done changing secret token for Cloud Name " + cloudName);
	}
}
Clone this wiki locally