Skip to content

Commit

Permalink
WIP for O365 MFA. issue #2724
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Dec 6, 2024
1 parent c715631 commit bf448d1
Show file tree
Hide file tree
Showing 20 changed files with 4,438 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1558,37 +1558,56 @@ private void tblMailboxesKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:e

private void cmdTestMailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdTestMailActionPerformed

ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true);
pi.setShowCancelButton(false);


String authToken = null;
if (this.chkMsExchange.isSelected()) {
try {
authToken = MsExchangeUtils.getAuthToken(this.txtTenantId.getText(), this.txtClientId.getText(), this.txtClientSecret.getText(), this.txtInUser.getText(), new String(this.pwdInPassword.getPassword()));
} catch (MissingConsentException ex) {
log.error("Consent required for client id " + this.txtClientId.getText(), ex);
// get consent and then proceed to test action
OAuthUserConsentDialog oDlg=new OAuthUserConsentDialog(this, true, this.txtTenantId.getText(), this.txtClientId.getText());
FrameUtils.centerDialog(oDlg, EditorsRegistry.getInstance().getMainWindow());
oDlg.setTitle("Zustimmung zum Postfachzugriff");
oDlg.setVisible(true);

// retry getting an auth token
try {
authToken = MsExchangeUtils.getAuthToken(this.txtTenantId.getText(), this.txtClientId.getText(), this.txtClientSecret.getText(), this.txtInUser.getText(), new String(this.pwdInPassword.getPassword()));
} catch (Exception exc) {
log.error("Unable to acquire auth token for client id " + this.txtClientId.getText(), exc);
JOptionPane.showMessageDialog(this, "Autorisierungstoken für Microsoft Exchange kann nicht ermittelt werden: " + exc.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
// no sense in executing the test
return;
}
} catch (Exception ex) {
log.error("Unable to acquire auth token for client id " + this.txtClientId.getText(), ex);
JOptionPane.showMessageDialog(this, "Autorisierungstoken für Microsoft Exchange kann nicht ermittelt werden: " +ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
// no sense in executing the test
return;
}

this.cmdSaveActionPerformed(evt);

int row = this.tblMailboxes.getSelectedRow();
MailboxSetup ms=null;
if (row >= 0) {
ms = (MailboxSetup) this.tblMailboxes.getValueAt(row, 0);
} else {
return;
}


O365OAuthCouplingDialog dlg=new O365OAuthCouplingDialog(this, ms);
FrameUtils.centerDialog(dlg, this);
dlg.setVisible(true);

// try {
// authToken = MsExchangeUtils.getAuthToken(this.txtTenantId.getText(), this.txtClientId.getText(), this.txtClientSecret.getText(), this.txtInUser.getText(), new String(this.pwdInPassword.getPassword()));
// } catch (MissingConsentException ex) {
// log.error("Consent required for client id " + this.txtClientId.getText(), ex);
// // get consent and then proceed to test action
// OAuthUserConsentDialog oDlg=new OAuthUserConsentDialog(this, true, this.txtTenantId.getText(), this.txtClientId.getText());
// FrameUtils.centerDialog(oDlg, EditorsRegistry.getInstance().getMainWindow());
// oDlg.setTitle("Zustimmung zum Postfachzugriff");
// oDlg.setVisible(true);
//
// // retry getting an auth token
// try {
// authToken = MsExchangeUtils.getAuthToken(this.txtTenantId.getText(), this.txtClientId.getText(), this.txtClientSecret.getText(), this.txtInUser.getText(), new String(this.pwdInPassword.getPassword()));
// } catch (Exception exc) {
// log.error("Unable to acquire auth token for client id " + this.txtClientId.getText(), exc);
// JOptionPane.showMessageDialog(this, "Autorisierungstoken für Microsoft Exchange kann nicht ermittelt werden: " + exc.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
// // no sense in executing the test
// return;
// }
// } catch (Exception ex) {
// log.error("Unable to acquire auth token for client id " + this.txtClientId.getText(), ex);
// JOptionPane.showMessageDialog(this, "Autorisierungstoken für Microsoft Exchange kann nicht ermittelt werden: " +ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE);
// // no sense in executing the test
// return;
// }
}

ProgressIndicator pi = new ProgressIndicator(EditorsRegistry.getInstance().getMainWindow(), true);
pi.setShowCancelButton(false);

MailSettingsTestAction a = new MailSettingsTestAction(pi, this, this.cmdTestMail, this.txtEmailAddress.getText(), this.txtOutServer.getText(), this.txtOutPort.getText(), this.txtOutUsername.getText(), new String(this.pwdOutPassword.getPassword()), this.chkEmailOutSsl.isSelected(), this.chkEmailStartTls.isSelected(), this.txtInServer.getText(), this.txtInUser.getText(), new String(this.pwdInPassword.getPassword()), this.chkEmailInSsl.isSelected(), this.cmbAccountType.getSelectedItem().toString(), this.chkMsExchange.isSelected(), this.txtClientId.getText(), this.txtClientSecret.getText(), authToken);

a.start();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="progress" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtUrl" max="32767" attributes="0"/>
<Component id="txtCode" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="cmdCopy" max="32767" attributes="0"/>
<Component id="cmdUrl" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cmdCancelPolling" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="cmdOk" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtUrl" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cmdUrl" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtCode" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cmdCopy" alignment="3" min="-2" pref="28" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="progress" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cmdCancelPolling" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="cmdOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextField" name="txtUrl">
</Component>
<Component class="javax.swing.JButton" name="cmdUrl">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons16/web.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Link im Browser &#xf6;ffnen"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdUrlActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="txtCode">
</Component>
<Component class="javax.swing.JButton" name="cmdCopy">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons16/editpaste.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Code in Zwischenablage kopieren"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdCopyActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JProgressBar" name="progress">
<Properties>
<Property name="string" type="java.lang.String" value=" "/>
<Property name="stringPainted" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="cmdCancelPolling">
<Properties>
<Property name="text" type="java.lang.String" value="Abbrechen"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="cmdOk">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/agt_action_success.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Schliessen"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdOkActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="&#xd6;ffnen Sie den untenstehenden Link und geben Sie den Code ein."/>
</Properties>
</Component>
</SubComponents>
</Form>
Loading

0 comments on commit bf448d1

Please sign in to comment.