use of com.microsoft.azuretools.authmanage.srvpri.entities.Application in project azure-tools-for-java by Microsoft.
the class ApplicationStep method createAadApplication.
// helpers
// Create AAD Application
private ApplicationRet createAadApplication(String displayName, String homePage, String[] identifierUris, String password) throws IOException {
/*
POST https://graph.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/applications?api-version=1.6
{
"availableToOtherTenants": false,
"displayName": "ShchAadApp",
"homepage": "http://github.com/Microsoft/azure-tools-for-java",
"identifierUris": [
"http://github.com/Microsoft/azure-tools-for-java"
],
"passwordCredentials": [
{
"startDate": "2016-08-16T04:55:00.3381704Z",
"endDate": "2017-08-16T04:55:00.3381704Z",
"keyId": "61d97a80-147a-44d2-bccc-13ffda967071",
"value": "Zxcv1234"
}
]
}
*/
Application app = new Application();
app.displayName = displayName;
app.homepage = homePage;
app.identifierUris.addAll(Arrays.asList(identifierUris));
PasswordCredentials pc = new PasswordCredentials();
LocalDateTime dt = LocalDateTime.now(ZoneOffset.UTC);
//pc.startDate = dt.format( DateTimeFormatter.ISO_DATE_TIME );
pc.endDate = dt.plusYears(1).format(DateTimeFormatter.ISO_DATE_TIME);
;
pc.keyId = UUID.randomUUID();
pc.value = password;
app.passwordCredentials.add(pc);
ObjectMapper mapper = new ObjectMapper();
String applicationJson = mapper.writeValueAsString(app);
String resp = graphRestHelper.doPost("applications", null, applicationJson);
ApplicationRet applicationRet = mapper.readValue(resp, ApplicationRet.class);
return applicationRet;
}
Aggregations