use of com.microsoft.azuretools.authmanage.srvpri.entities.ServicePrincipalRet in project azure-tools-for-java by Microsoft.
the class ServicePrincipalStep method execute.
@Override
public void execute(Map<String, Object> params) throws IOException, InterruptedException {
//System.out.println("ServicePrincipalStep execute...");
UUID appId = (UUID) params.get("appId");
//UUID tenantId = (UUID) params.get("tenantId");
String tenantId = CommonParams.getTenantId();
graphRestHelper = new GraphRestHelper(tenantId);
reporter = CommonParams.getReporter();
reporter.report("appId: " + appId);
ServicePrincipalRet sp = createAadServicePrincipal(appId);
params.put("spObjectId", sp.objectId);
Thread.sleep(1000);
params.put("status", "sp");
CommonParams.getStatusReporter().report(new Status(getName(), Status.Result.SUCCESSFUL, String.format("spObjectId: %s", sp.objectId)));
}
use of com.microsoft.azuretools.authmanage.srvpri.entities.ServicePrincipalRet in project azure-tools-for-java by Microsoft.
the class ServicePrincipalStep method createAadServicePrincipal.
// helpers
// Create Service Principals
private ServicePrincipalRet createAadServicePrincipal(UUID appId) throws IOException {
/*
POST https://graph.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/servicePrincipals?api-version=1.6-internal HTTP/1.1
{
"appId": "425817b6-1cd8-48ea-9cd7-1b9472912bee",
"accountEnabled": true
}
*/
ServicePrincipal sp = new ServicePrincipal();
sp.accountEnabled = true;
sp.appId = appId;
ObjectMapper mapper = new ObjectMapper();
String spJson = mapper.writeValueAsString(sp);
String resp = graphRestHelper.doPost("servicePrincipals", null, spJson);
ServicePrincipalRet spr = mapper.readValue(resp, ServicePrincipalRet.class);
return spr;
}
Aggregations