use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class SelectSubscriptionsAction method onShowSubscriptions.
public static void onShowSubscriptions(Project project) {
JFrame frame = WindowManager.getInstance().getFrame(project);
try {
//Project project = ProjectManager.getInstance().getDefaultProject();();
AzureManager manager = AuthMethodManager.getInstance().getAzureManager();
if (manager == null) {
return;
}
final SubscriptionManager subscriptionManager = manager.getSubscriptionManager();
updateSubscriptionWithProgressDialog(subscriptionManager, project);
List<SubscriptionDetail> sdl = subscriptionManager.getSubscriptionDetails();
for (SubscriptionDetail sd : sdl) {
System.out.println(sd.getSubscriptionName());
}
//System.out.println("onShowSubscriptions: calling getSubscriptionDetails()");
SubscriptionsDialog d = SubscriptionsDialog.go(subscriptionManager.getSubscriptionDetails(), project);
List<SubscriptionDetail> subscriptionDetailsUpdated;
if (d != null) {
subscriptionDetailsUpdated = d.getSubscriptionDetails();
subscriptionManager.setSubscriptionDetails(subscriptionDetailsUpdated);
}
} catch (Exception ex) {
ex.printStackTrace();
//LOGGER.error("onShowSubscriptions", ex);
ErrorWindow.show(project, ex.getMessage(), "Select Subscriptions Action Error");
}
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class AppServiceCreateDialog method doFillSubscriptions.
protected void doFillSubscriptions() {
try {
// reset model
Set<SubscriptionDetail> sdl = AzureModel.getInstance().getSubscriptionToResourceGroupMap().keySet();
DefaultComboBoxModel<SubscriptionDetail> cbModel = new DefaultComboBoxModel<SubscriptionDetail>();
if (sdl == null) {
System.out.println("sdl is null");
return;
}
for (SubscriptionDetail sd : sdl) {
if (!sd.isSelected())
continue;
cbModel.addElement(sd);
}
comboBoxSubscription.setModel(cbModel);
} catch (Exception ex) {
ex.printStackTrace();
LOGGER.error("doFillSubscriptions@AppServiceCreateDialog", ex);
}
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class AppServiceCreateDialog method fillResourceGroups.
protected void fillResourceGroups() {
DefaultComboBoxModel<SubscriptionDetail> cbModelSub = (DefaultComboBoxModel<SubscriptionDetail>) comboBoxSubscription.getModel();
SubscriptionDetail sd = (SubscriptionDetail) cbModelSub.getSelectedItem();
if (sd == null) {
// empty
System.out.println("No subscription is selected");
return;
}
DefaultComboBoxModel<ResourceGroupAdapter> cbModel = new DefaultComboBoxModel<ResourceGroupAdapter>();
List<ResourceGroup> rgl = AzureModel.getInstance().getSubscriptionToResourceGroupMap().get(sd);
if (rgl == null) {
System.out.println("rgl is null");
return;
}
for (ResourceGroup rg : rgl) {
cbModel.addElement(new ResourceGroupAdapter(rg));
}
comboBoxResourceGroup.setModel(cbModel);
if (cbModel.getSize() == 1)
comboBoxResourceGroup.setSelectedItem(null);
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class Program method main.
@SuppressWarnings("unused")
public static void main(String[] args) {
LogManager.getLogManager().reset();
try {
try {
if (CommonSettings.getUiFactory() == null)
CommonSettings.setUiFactory(new UIFactory());
String wd = "AuthManageWorkingDir";
Path dirPath = Paths.get(System.getProperty("user.home"), wd);
if (!Files.exists(dirPath)) {
Files.createDirectory(dirPath);
}
CommonSettings.settingsBaseDir = dirPath.toString();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("--- Service Principals section ---");
// create with sp
//final File credFile = new File(System.getProperty("user.home") + "/ServicePrincipals/srv-pri.azureauth-778");
String path = "C:\\Users\\shch\\_ServicePrincipalsTest\\sp5\\sp-9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef_20161202161437.azureauth";
final File credFile = new File("C:\\Users\\shch\\_ServicePrincipalsTest\\sp5\\sp-9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef_20161202161437.azureauth");
AuthMethodDetails amd = new AuthMethodDetails();
amd.setAuthMethod(AuthMethod.SP);
amd.setCredFilePath(path);
AuthMethodManager amm = AuthMethodManager.getInstance();
amm.setAuthMethodDetails(amd);
AzureManager am = amm.getAzureManager();
SubscriptionManager subscriptionManager = am.getSubscriptionManager();
List<SubscriptionDetail> sdl = subscriptionManager.getSubscriptionDetails();
//AzureManager spManager = new ServicePrincipalAzureManager(credFile);
//printResourceGroups(spManager);
//printSubscriptions(spManager);
// create with token
//AzureManager atManager = new AccessTokenAzureManager(Constants.tenant);
//AzureManager atManager = new AccessTokenAzureManager();
//SubscriptionManager.getInstance().showSubscriptionDialog();
// AdAuthManager adAuthManager = AdAuthManager.getInstance();
System.out.println("=== Access token section ---");
// AuthenticationResult res = AdAuthManager.getInstance().signIn();
// UserInfo ui = res.getUserInfo();
// Setup working dir
String wd = "AuthManageWorkingDir";
Path dirPath = Paths.get(System.getProperty("user.home"), wd);
if (!Files.exists(dirPath)) {
Files.createDirectory(dirPath);
}
CommonSettings.settingsBaseDir = dirPath.toString();
// Setup uiFactory
if (CommonSettings.getUiFactory() == null)
CommonSettings.setUiFactory(new UIFactory());
//testReporter(dirPath.toString());
//graphApiAction();
//createSp();
// AzureManager am = AuthMethodManager.getInstance().getAzureManager(AuthMethod.AD);
// if (am == null) {
// return;
// }
//
// System.out.println("-- Subscription list ---");
// printSubscriptions(am);
// sidList = AdAuthManager.getInstance().getAccountSidList();
// for (String sid : AdAuthManager.getInstance().getAccountSidList()) {
// System.out.println(" - " + sid);
// }
//printResourceGroups(am);
//printTenants(atManager);
} catch (Exception e) {
e.printStackTrace();
} finally {
System.exit(1);
}
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class SubscriptionManager method updateSidToTidMap.
private void updateSidToTidMap() {
System.out.println(Thread.currentThread().getId() + " SubscriptionManager.updateSidToTidMap()");
sidToTid.clear();
for (SubscriptionDetail sd : subscriptionDetails) {
if (sd.isSelected())
sidToTid.put(sd.getSubscriptionId(), sd.getTenantId());
}
}
Aggregations