| 1 | package com.jsql.view.swing.panel.preferences; | |
| 2 | ||
| 3 | import com.jsql.view.swing.panel.PanelPreferences; | |
| 4 | import com.jsql.view.swing.text.JPopupTextField; | |
| 5 | import com.jsql.view.swing.text.listener.DocumentListenerEditing; | |
| 6 | import com.jsql.view.swing.util.MediatorHelper; | |
| 7 | ||
| 8 | import javax.swing.*; | |
| 9 | import javax.swing.event.DocumentListener; | |
| 10 | import java.awt.*; | |
| 11 | import java.util.stream.Stream; | |
| 12 | ||
| 13 | public class PanelAuthentication extends JPanel { | |
| 14 | ||
| 15 | private final JCheckBox checkboxUseDigestAuthentication = new JCheckBox("<html>Enable <b>Basic</b> and <b>NTLM</b> (for <b>Digest</b>: do not enable but just set the user and password):</html>", MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().isAuthentEnabled()); | |
| 16 | private final JCheckBox checkboxUseKerberos = new JCheckBox("Enable Kerberos:", MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().isKerberos()); | |
| 17 | ||
| 18 | private final JTextField textDigestAuthenticationUsername = new JPopupTextField("Host system user", MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().getUsernameAuthentication()).getProxy(); | |
| 19 | private final JTextField textDigestAuthenticationPassword = new JPopupTextField("Host system password", MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().getPasswordAuthentication()).getProxy(); | |
| 20 | private final JTextField textKerberosLoginConf = new JPopupTextField("Path to login.conf", MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().getPathKerberosLogin()).getProxy(); | |
| 21 | private final JTextField textKerberosKrb5Conf = new JPopupTextField("Path to krb5.conf", MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().getPathKerberosKrb5()).getProxy(); | |
| 22 | ||
| 23 | private static final String TAG_HTML_ON = "<html>"; | |
| 24 | private static final String TAG_HTML_OFF = "</html>"; | |
| 25 | | |
| 26 | public PanelAuthentication(PanelPreferences panelPreferences) { | |
| 27 |
1
1. <init> : removed call to javax/swing/JCheckBox::setToolTipText → NO_COVERAGE |
this.checkboxUseDigestAuthentication.setToolTipText( |
| 28 | PanelAuthentication.TAG_HTML_ON | |
| 29 | + "Enable <b>Basic</b>, <b>Digest</b>, <b>NTLM</b> authentication (e.g. WWW-Authenticate).<br>" | |
| 30 | + "Then define username and password for the host.<br>" | |
| 31 | + "<i><b>Negotiate</b> authentication is defined in URL.</i>" | |
| 32 | + PanelAuthentication.TAG_HTML_OFF | |
| 33 | ); | |
| 34 | ||
| 35 | var panelUsername = new JPanel(); | |
| 36 |
1
1. <init> : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE |
panelUsername.setLayout(new BoxLayout(panelUsername, BoxLayout.X_AXIS)); |
| 37 | panelUsername.add(new JLabel("Username ")); | |
| 38 | panelUsername.add(this.textDigestAuthenticationUsername); | |
| 39 |
1
1. <init> : removed call to javax/swing/JPanel::setMaximumSize → NO_COVERAGE |
panelUsername.setMaximumSize(new Dimension(325, this.textDigestAuthenticationUsername.getPreferredSize().height)); |
| 40 | ||
| 41 | var panelPassword = new JPanel(); | |
| 42 |
1
1. <init> : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE |
panelPassword.setLayout(new BoxLayout(panelPassword, BoxLayout.X_AXIS)); |
| 43 | panelPassword.add(new JLabel("Password ")); | |
| 44 | panelPassword.add(this.textDigestAuthenticationPassword); | |
| 45 |
1
1. <init> : removed call to javax/swing/JPanel::setMaximumSize → NO_COVERAGE |
panelPassword.setMaximumSize(new Dimension(325, this.textDigestAuthenticationPassword.getPreferredSize().height)); |
| 46 |
1
1. <init> : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelPassword.setBorder(BorderFactory.createEmptyBorder(0,0,10,0)); |
| 47 | ||
| 48 | String tooltipUseKerberos = PanelAuthentication.TAG_HTML_ON | |
| 49 | + "Enable Kerberos authentication, then define path to <b>login.conf</b> and <b>krb5.conf</b>.<br>" | |
| 50 | + "Path to <b>.keytab</b> file is defined in login.conf ; name of <b>principal</b> must be correct.<br>" | |
| 51 | + "<b>Realm</b> and <b>kdc</b> are defined in krb5.conf.<br>" | |
| 52 | + "Finally use the <b>correct hostname</b> in URL, e.g. http://servicename.corp.test/[..]" | |
| 53 | + PanelAuthentication.TAG_HTML_OFF; | |
| 54 | ||
| 55 |
1
1. <init> : removed call to javax/swing/JTextField::setToolTipText → NO_COVERAGE |
this.textKerberosLoginConf.setToolTipText( |
| 56 | PanelAuthentication.TAG_HTML_ON | |
| 57 | + "Define the path to <b>login.conf</b>. Sample:<br>" | |
| 58 | + " <b>entry-name</b> {<br>" | |
| 59 | + "  com.sun.security.auth.module.Krb5LoginModule<br>" | |
| 60 | + "  required<br>" | |
| 61 | + "  useKeyTab=true<br>" | |
| 62 | + "  keyTab=\"<b>/path/to/my.keytab</b>\"<br>" | |
| 63 | + "  principal=\"<b>HTTP/SERVICENAME.CORP.TEST@CORP.TEST</b>\"<br>" | |
| 64 | + "  debug=false;<br>" | |
| 65 | + " }<br>" | |
| 66 | + "<i>Principal name is case sensitive ; entry-name is read automatically.</i>" | |
| 67 | + PanelAuthentication.TAG_HTML_OFF); | |
| 68 |
1
1. <init> : removed call to javax/swing/JTextField::setToolTipText → NO_COVERAGE |
this.textKerberosKrb5Conf.setToolTipText( |
| 69 | PanelAuthentication.TAG_HTML_ON | |
| 70 | + "Define the path to <b>krb5.conf</b>. Sample:<br>" | |
| 71 | + " [libdefaults]<br>" | |
| 72 | + "  default_realm = <b>CORP.TEST</b><br>" | |
| 73 | + "  udp_preference_limit = 1<br>" | |
| 74 | + " [realms]<br>" | |
| 75 | + "  <b>CORP.TEST</b> = {<br>" | |
| 76 | + "   kdc = <b>127.0.0.1:88</b><br>" | |
| 77 | + "  }<br>" | |
| 78 | + "<i>Realm and kdc are case sensitives.</i>" | |
| 79 | + PanelAuthentication.TAG_HTML_OFF); | |
| 80 |
1
1. <init> : removed call to javax/swing/JCheckBox::setToolTipText → NO_COVERAGE |
this.checkboxUseKerberos.setToolTipText(tooltipUseKerberos); |
| 81 | ||
| 82 | var panelLoginConf = new JPanel(); | |
| 83 |
1
1. <init> : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE |
panelLoginConf.setLayout(new BoxLayout(panelLoginConf, BoxLayout.X_AXIS)); |
| 84 | panelLoginConf.add(new JLabel("login.conf ")); | |
| 85 | panelLoginConf.add(this.textKerberosLoginConf); | |
| 86 |
1
1. <init> : removed call to javax/swing/JPanel::setMaximumSize → NO_COVERAGE |
panelLoginConf.setMaximumSize(new Dimension(325, this.textKerberosLoginConf.getPreferredSize().height)); |
| 87 | ||
| 88 | var panelKrb5Conf = new JPanel(); | |
| 89 |
1
1. <init> : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE |
panelKrb5Conf.setLayout(new BoxLayout(panelKrb5Conf, BoxLayout.X_AXIS)); |
| 90 | panelKrb5Conf.add(new JLabel("krb5.conf ")); | |
| 91 | panelKrb5Conf.add(this.textKerberosKrb5Conf); | |
| 92 |
1
1. <init> : removed call to javax/swing/JPanel::setMaximumSize → NO_COVERAGE |
panelKrb5Conf.setMaximumSize(new Dimension(325, this.textKerberosKrb5Conf.getPreferredSize().height)); |
| 93 | | |
| 94 | Stream.of( | |
| 95 | this.checkboxUseDigestAuthentication, | |
| 96 | this.checkboxUseKerberos | |
| 97 | ) | |
| 98 |
2
1. lambda$new$0 : removed call to javax/swing/JCheckBox::addActionListener → NO_COVERAGE 2. <init> : removed call to java/util/stream/Stream::forEach → NO_COVERAGE |
.forEach(button -> button.addActionListener(panelPreferences.getActionListenerSave())); |
| 99 | | |
| 100 | DocumentListener documentListenerSave = new DocumentListenerEditing() { | |
| 101 | @Override | |
| 102 | public void process() { | |
| 103 |
1
1. process : removed call to java/awt/event/ActionListener::actionPerformed → NO_COVERAGE |
panelPreferences.getActionListenerSave().actionPerformed(null); |
| 104 | } | |
| 105 | }; | |
| 106 | ||
| 107 | Stream.of( | |
| 108 | this.textDigestAuthenticationPassword, | |
| 109 | this.textDigestAuthenticationUsername, | |
| 110 | this.textKerberosKrb5Conf, | |
| 111 | this.textKerberosLoginConf | |
| 112 | ) | |
| 113 |
2
1. lambda$new$1 : removed call to javax/swing/text/Document::addDocumentListener → NO_COVERAGE 2. <init> : removed call to java/util/stream/Stream::forEach → NO_COVERAGE |
.forEach(textField -> textField.getDocument().addDocumentListener(documentListenerSave)); |
| 114 | ||
| 115 | var labelOrigin = new JLabel("<html><b>Network secured connection</b></html>"); | |
| 116 |
1
1. <init> : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE |
labelOrigin.setBorder(PanelGeneral.MARGIN); |
| 117 | ||
| 118 | var groupLayout = new GroupLayout(this); | |
| 119 |
1
1. <init> : removed call to com/jsql/view/swing/panel/preferences/PanelAuthentication::setLayout → NO_COVERAGE |
this.setLayout(groupLayout); |
| 120 | ||
| 121 |
1
1. <init> : removed call to javax/swing/GroupLayout::setHorizontalGroup → NO_COVERAGE |
groupLayout.setHorizontalGroup( |
| 122 | groupLayout | |
| 123 | .createSequentialGroup() | |
| 124 | .addGroup( | |
| 125 | groupLayout | |
| 126 | .createParallelGroup(GroupLayout.Alignment.LEADING, false) | |
| 127 | .addComponent(labelOrigin) | |
| 128 | .addComponent(this.checkboxUseDigestAuthentication) | |
| 129 | .addComponent(panelUsername) | |
| 130 | .addComponent(panelPassword) | |
| 131 | .addComponent(this.checkboxUseKerberos) | |
| 132 | .addComponent(panelLoginConf) | |
| 133 | .addComponent(panelKrb5Conf) | |
| 134 | ) | |
| 135 | ); | |
| 136 | | |
| 137 |
1
1. <init> : removed call to javax/swing/GroupLayout::setVerticalGroup → NO_COVERAGE |
groupLayout.setVerticalGroup( |
| 138 | groupLayout | |
| 139 | .createSequentialGroup() | |
| 140 | .addGroup( | |
| 141 | groupLayout | |
| 142 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
| 143 | .addComponent(labelOrigin) | |
| 144 | ) | |
| 145 | .addGroup( | |
| 146 | groupLayout | |
| 147 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
| 148 | .addComponent(this.checkboxUseDigestAuthentication) | |
| 149 | ) | |
| 150 | .addGroup( | |
| 151 | groupLayout | |
| 152 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
| 153 | .addComponent(panelUsername) | |
| 154 | ) | |
| 155 | .addGroup( | |
| 156 | groupLayout | |
| 157 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
| 158 | .addComponent(panelPassword) | |
| 159 | ) | |
| 160 | .addGroup( | |
| 161 | groupLayout | |
| 162 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
| 163 | .addComponent(this.checkboxUseKerberos) | |
| 164 | ) | |
| 165 | .addGroup( | |
| 166 | groupLayout | |
| 167 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
| 168 | .addComponent(panelLoginConf) | |
| 169 | ) | |
| 170 | .addGroup( | |
| 171 | groupLayout | |
| 172 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
| 173 | .addComponent(panelKrb5Conf) | |
| 174 | ) | |
| 175 | ); | |
| 176 | } | |
| 177 | | |
| 178 | | |
| 179 | // Getter and setter | |
| 180 | | |
| 181 | public JCheckBox getCheckboxUseDigestAuthentication() { | |
| 182 |
1
1. getCheckboxUseDigestAuthentication : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuthentication::getCheckboxUseDigestAuthentication → NO_COVERAGE |
return this.checkboxUseDigestAuthentication; |
| 183 | } | |
| 184 | ||
| 185 | public JTextField getTextDigestAuthenticationUsername() { | |
| 186 |
1
1. getTextDigestAuthenticationUsername : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuthentication::getTextDigestAuthenticationUsername → NO_COVERAGE |
return this.textDigestAuthenticationUsername; |
| 187 | } | |
| 188 | ||
| 189 | public JTextField getTextDigestAuthenticationPassword() { | |
| 190 |
1
1. getTextDigestAuthenticationPassword : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuthentication::getTextDigestAuthenticationPassword → NO_COVERAGE |
return this.textDigestAuthenticationPassword; |
| 191 | } | |
| 192 | ||
| 193 | public JCheckBox getCheckboxUseKerberos() { | |
| 194 |
1
1. getCheckboxUseKerberos : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuthentication::getCheckboxUseKerberos → NO_COVERAGE |
return this.checkboxUseKerberos; |
| 195 | } | |
| 196 | ||
| 197 | public JTextField getTextKerberosKrb5Conf() { | |
| 198 |
1
1. getTextKerberosKrb5Conf : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuthentication::getTextKerberosKrb5Conf → NO_COVERAGE |
return this.textKerberosKrb5Conf; |
| 199 | } | |
| 200 | ||
| 201 | public JTextField getTextKerberosLoginConf() { | |
| 202 |
1
1. getTextKerberosLoginConf : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuthentication::getTextKerberosLoginConf → NO_COVERAGE |
return this.textKerberosLoginConf; |
| 203 | } | |
| 204 | } | |
Mutations | ||
| 27 |
1.1 |
|
| 36 |
1.1 |
|
| 39 |
1.1 |
|
| 42 |
1.1 |
|
| 45 |
1.1 |
|
| 46 |
1.1 |
|
| 55 |
1.1 |
|
| 68 |
1.1 |
|
| 80 |
1.1 |
|
| 83 |
1.1 |
|
| 86 |
1.1 |
|
| 89 |
1.1 |
|
| 92 |
1.1 |
|
| 98 |
1.1 2.2 |
|
| 103 |
1.1 |
|
| 113 |
1.1 2.2 |
|
| 116 |
1.1 |
|
| 119 |
1.1 |
|
| 121 |
1.1 |
|
| 137 |
1.1 |
|
| 182 |
1.1 |
|
| 186 |
1.1 |
|
| 190 |
1.1 |
|
| 194 |
1.1 |
|
| 198 |
1.1 |
|
| 202 |
1.1 |