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 | import com.jsql.view.swing.util.UiUtil; | |
8 | import org.apache.commons.lang3.StringUtils; | |
9 | ||
10 | import javax.swing.*; | |
11 | import javax.swing.event.DocumentListener; | |
12 | import java.awt.*; | |
13 | import java.util.stream.Stream; | |
14 | ||
15 | public class PanelAuth extends JPanel { | |
16 | ||
17 | private final JCheckBox checkboxUseDigestAuthentication = new JCheckBox(StringUtils.EMPTY, MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().isAuthentEnabled()); | |
18 | private final JCheckBox checkboxUseKerberos = new JCheckBox(StringUtils.EMPTY, MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().isKerberos()); | |
19 | ||
20 | private final JTextField textDigestAuthenticationUsername = new JPopupTextField("Host system user", MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().getUsernameAuthentication()).getProxy(); | |
21 | private final JTextField textDigestAuthenticationPassword = new JPopupTextField("Host system password", MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().getPasswordAuthentication()).getProxy(); | |
22 | private final JTextField textKerberosLoginConf = new JPopupTextField("Path to login.conf", MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().getPathKerberosLogin()).getProxy(); | |
23 | private final JTextField textKerberosKrb5Conf = new JPopupTextField("Path to krb5.conf", MediatorHelper.model().getMediatorUtils().getAuthenticationUtil().getPathKerberosKrb5()).getProxy(); | |
24 | ||
25 | private static final String TAG_HTML_ON = "<html>"; | |
26 | private static final String TAG_HTML_OFF = "</html>"; | |
27 | | |
28 | public PanelAuth(PanelPreferences panelPreferences) { | |
29 | ||
30 |
1
1. <init> : removed call to com/jsql/view/swing/panel/preferences/PanelAuth::setBorder → NO_COVERAGE |
this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
31 | | |
32 | var groupLayout = new GroupLayout(this); | |
33 |
1
1. <init> : removed call to com/jsql/view/swing/panel/preferences/PanelAuth::setLayout → NO_COVERAGE |
this.setLayout(groupLayout); |
34 | ||
35 | // Digest label | |
36 | var labelDigestAuthenticationUsername = new JLabel("Username "); | |
37 | var labelDigestAuthenticationPassword = new JLabel("Password "); | |
38 | final var labelUseDigestAuthentication = new JButton("<html>Enable <b>Basic</b> and <b>NTLM</b> (for <b>Digest</b>: do not enable but just set the user and pass)</html>"); | |
39 | String tooltipUseDigestAuthentication = | |
40 | TAG_HTML_ON | |
41 | + "Enable <b>Basic</b>, <b>Digest</b>, <b>NTLM</b> authentication (e.g. WWW-Authenticate).<br>" | |
42 | + "Then define username and password for the host.<br>" | |
43 | + "<i><b>Negotiate</b> authentication is defined in URL.</i>" | |
44 | + TAG_HTML_OFF; | |
45 |
1
1. <init> : removed call to javax/swing/JButton::setToolTipText → NO_COVERAGE |
labelUseDigestAuthentication.setToolTipText(tooltipUseDigestAuthentication); |
46 | | |
47 | // Proxy setting: IP, port, checkbox to activate proxy | |
48 |
1
1. <init> : removed call to javax/swing/JCheckBox::setToolTipText → NO_COVERAGE |
this.getCheckboxUseDigestAuthentication().setToolTipText(tooltipUseDigestAuthentication); |
49 |
1
1. <init> : removed call to javax/swing/JCheckBox::setFocusable → NO_COVERAGE |
this.getCheckboxUseDigestAuthentication().setFocusable(false); |
50 | | |
51 | // Digest label | |
52 | var labelKerberosLoginConf = new JLabel("login.conf "); | |
53 | var labelKerberosKrb5Conf = new JLabel("krb5.conf "); | |
54 | final var labelUseKerberos = new JButton("Enable Kerberos"); | |
55 | String tooltipUseKerberos = TAG_HTML_ON | |
56 | + "Enable Kerberos authentication, then define path to <b>login.conf</b> and <b>krb5.conf</b>.<br>" | |
57 | + "Path to <b>.keytab</b> file is defined in login.conf ; name of <b>principal</b> must be correct.<br>" | |
58 | + "<b>Realm</b> and <b>kdc</b> are defined in krb5.conf.<br>" | |
59 | + "Finally use the <b>correct hostname</b> in URL, e.g. http://servicename.corp.test/[..]" | |
60 | + TAG_HTML_OFF; | |
61 |
1
1. <init> : removed call to javax/swing/JButton::setToolTipText → NO_COVERAGE |
labelUseKerberos.setToolTipText(tooltipUseKerberos); |
62 | | |
63 | // Proxy setting: IP, port, checkbox to activate proxy | |
64 |
1
1. <init> : removed call to javax/swing/JTextField::setToolTipText → NO_COVERAGE |
this.getTextKerberosLoginConf().setToolTipText( |
65 | TAG_HTML_ON | |
66 | + "Define the path to <b>login.conf</b>. Sample :<br>" | |
67 | + " <b>entry-name</b> {<br>" | |
68 | + "  com.sun.security.auth.module.Krb5LoginModule<br>" | |
69 | + "  required<br>" | |
70 | + "  useKeyTab=true<br>" | |
71 | + "  keyTab=\"<b>/path/to/my.keytab</b>\"<br>" | |
72 | + "  principal=\"<b>HTTP/SERVICENAME.CORP.TEST@CORP.TEST</b>\"<br>" | |
73 | + "  debug=false;<br>" | |
74 | + " }<br>" | |
75 | + "<i>Principal name is case sensitive ; entry-name is read automatically.</i>" | |
76 | + TAG_HTML_OFF); | |
77 |
1
1. <init> : removed call to javax/swing/JTextField::setToolTipText → NO_COVERAGE |
this.getTextKerberosKrb5Conf().setToolTipText( |
78 | TAG_HTML_ON | |
79 | + "Define the path to <b>krb5.conf</b>. Sample :<br>" | |
80 | + " [libdefaults]<br>" | |
81 | + "  default_realm = <b>CORP.TEST</b><br>" | |
82 | + "  udp_preference_limit = 1<br>" | |
83 | + " [realms]<br>" | |
84 | + "  <b>CORP.TEST</b> = {<br>" | |
85 | + "   kdc = <b>127.0.0.1:88</b><br>" | |
86 | + "  }<br>" | |
87 | + "<i>Realm and kdc are case sensitives.</i>" | |
88 | + TAG_HTML_OFF); | |
89 |
1
1. <init> : removed call to javax/swing/JCheckBox::setToolTipText → NO_COVERAGE |
this.getCheckboxUseKerberos().setToolTipText(tooltipUseKerberos); |
90 |
1
1. <init> : removed call to javax/swing/JCheckBox::setFocusable → NO_COVERAGE |
this.getCheckboxUseKerberos().setFocusable(false); |
91 | | |
92 |
1
1. <init> : removed call to javax/swing/JButton::addActionListener → NO_COVERAGE |
labelUseKerberos.addActionListener(actionEvent -> { |
93 | | |
94 |
2
1. lambda$new$0 : removed call to javax/swing/JCheckBox::setSelected → NO_COVERAGE 2. lambda$new$0 : negated conditional → NO_COVERAGE |
this.getCheckboxUseKerberos().setSelected(!this.getCheckboxUseKerberos().isSelected()); |
95 |
1
1. lambda$new$0 : negated conditional → NO_COVERAGE |
if (this.getCheckboxUseKerberos().isSelected()) { |
96 |
1
1. lambda$new$0 : removed call to javax/swing/JCheckBox::setSelected → NO_COVERAGE |
this.getCheckboxUseDigestAuthentication().setSelected(false); |
97 | } | |
98 | | |
99 |
1
1. lambda$new$0 : removed call to java/awt/event/ActionListener::actionPerformed → NO_COVERAGE |
panelPreferences.getActionListenerSave().actionPerformed(null); |
100 | }); | |
101 | | |
102 |
1
1. <init> : removed call to javax/swing/JButton::addActionListener → NO_COVERAGE |
labelUseDigestAuthentication.addActionListener(actionEvent -> { |
103 | | |
104 |
2
1. lambda$new$1 : removed call to javax/swing/JCheckBox::setSelected → NO_COVERAGE 2. lambda$new$1 : negated conditional → NO_COVERAGE |
this.getCheckboxUseDigestAuthentication().setSelected(!this.getCheckboxUseDigestAuthentication().isSelected()); |
105 |
1
1. lambda$new$1 : negated conditional → NO_COVERAGE |
if (this.getCheckboxUseDigestAuthentication().isSelected()) { |
106 |
1
1. lambda$new$1 : removed call to javax/swing/JCheckBox::setSelected → NO_COVERAGE |
this.getCheckboxUseKerberos().setSelected(false); |
107 | } | |
108 | | |
109 |
1
1. lambda$new$1 : removed call to java/awt/event/ActionListener::actionPerformed → NO_COVERAGE |
panelPreferences.getActionListenerSave().actionPerformed(null); |
110 | }); | |
111 | | |
112 |
1
1. <init> : removed call to javax/swing/JTextField::setMaximumSize → NO_COVERAGE |
this.getTextKerberosKrb5Conf().setMaximumSize(new Dimension(400, 0)); |
113 |
1
1. <init> : removed call to javax/swing/JTextField::setMaximumSize → NO_COVERAGE |
this.getTextKerberosLoginConf().setMaximumSize(new Dimension(400, 0)); |
114 |
1
1. <init> : removed call to javax/swing/JTextField::setMaximumSize → NO_COVERAGE |
this.getTextDigestAuthenticationUsername().setMaximumSize(new Dimension(200, 0)); |
115 |
1
1. <init> : removed call to javax/swing/JTextField::setMaximumSize → NO_COVERAGE |
this.getTextDigestAuthenticationPassword().setMaximumSize(new Dimension(200, 0)); |
116 | ||
117 |
1
1. <init> : removed call to javax/swing/JTextField::setFont → NO_COVERAGE |
this.getTextKerberosLoginConf().setFont(UiUtil.FONT_NON_MONO_BIG); |
118 |
1
1. <init> : removed call to javax/swing/JTextField::setFont → NO_COVERAGE |
this.getTextKerberosKrb5Conf().setFont(UiUtil.FONT_NON_MONO_BIG); |
119 | | |
120 |
1
1. <init> : removed call to javax/swing/JTextField::setFont → NO_COVERAGE |
this.getTextDigestAuthenticationUsername().setFont(UiUtil.FONT_NON_MONO_BIG); |
121 |
1
1. <init> : removed call to javax/swing/JTextField::setFont → NO_COVERAGE |
this.getTextDigestAuthenticationPassword().setFont(UiUtil.FONT_NON_MONO_BIG); |
122 | | |
123 | Stream.of( | |
124 | this.getCheckboxUseDigestAuthentication(), | |
125 | this.getCheckboxUseKerberos() | |
126 | ) | |
127 |
2
1. lambda$new$2 : 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())); |
128 | | |
129 | DocumentListener documentListenerSave = new DocumentListenerEditing() { | |
130 | @Override | |
131 | public void process() { | |
132 |
1
1. process : removed call to java/awt/event/ActionListener::actionPerformed → NO_COVERAGE |
panelPreferences.getActionListenerSave().actionPerformed(null); |
133 | } | |
134 | }; | |
135 | ||
136 | Stream.of( | |
137 | this.getTextDigestAuthenticationPassword(), | |
138 | this.getTextDigestAuthenticationUsername(), | |
139 | this.getTextKerberosKrb5Conf(), | |
140 | this.getTextKerberosLoginConf() | |
141 | ) | |
142 |
2
1. lambda$new$3 : 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)); |
143 | ||
144 | Stream.of( | |
145 | labelUseDigestAuthentication, | |
146 | labelUseKerberos | |
147 | ) | |
148 |
1
1. <init> : removed call to java/util/stream/Stream::forEach → NO_COVERAGE |
.forEach(label -> { |
149 | | |
150 |
1
1. lambda$new$4 : removed call to javax/swing/JButton::setHorizontalAlignment → NO_COVERAGE |
label.setHorizontalAlignment(SwingConstants.LEFT); |
151 |
1
1. lambda$new$4 : removed call to javax/swing/JButton::setBorderPainted → NO_COVERAGE |
label.setBorderPainted(false); |
152 |
1
1. lambda$new$4 : removed call to javax/swing/JButton::setContentAreaFilled → NO_COVERAGE |
label.setContentAreaFilled(false); |
153 | }); | |
154 | | |
155 | var labelMarginHidden = new JLabel(); | |
156 | var labelMargin = new JLabel(); | |
157 |
1
1. <init> : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE |
labelMargin.setBorder(BorderFactory.createEmptyBorder(15, 0, 0, 0)); |
158 | | |
159 | groupLayout | |
160 |
1
1. <init> : removed call to javax/swing/GroupLayout::setHorizontalGroup → NO_COVERAGE |
.setHorizontalGroup( |
161 | groupLayout | |
162 | .createSequentialGroup() | |
163 | .addGroup( | |
164 | groupLayout | |
165 | .createParallelGroup(GroupLayout.Alignment.TRAILING, false) | |
166 | .addComponent(this.getCheckboxUseDigestAuthentication()) | |
167 | .addComponent(labelDigestAuthenticationUsername) | |
168 | .addComponent(labelDigestAuthenticationPassword) | |
169 | .addComponent(labelMarginHidden) | |
170 | .addComponent(this.getCheckboxUseKerberos()) | |
171 | .addComponent(labelKerberosLoginConf) | |
172 | .addComponent(labelKerberosKrb5Conf) | |
173 | ) | |
174 | .addGroup( | |
175 | groupLayout | |
176 | .createParallelGroup() | |
177 | .addComponent(labelUseDigestAuthentication) | |
178 | .addComponent(this.getTextDigestAuthenticationUsername()) | |
179 | .addComponent(this.getTextDigestAuthenticationPassword()) | |
180 | .addComponent(labelMargin) | |
181 | .addComponent(labelUseKerberos) | |
182 | .addComponent(this.getTextKerberosLoginConf()) | |
183 | .addComponent(this.getTextKerberosKrb5Conf()) | |
184 | ) | |
185 | ); | |
186 | | |
187 | groupLayout | |
188 |
1
1. <init> : removed call to javax/swing/GroupLayout::setVerticalGroup → NO_COVERAGE |
.setVerticalGroup( |
189 | groupLayout | |
190 | .createSequentialGroup() | |
191 | .addGroup( | |
192 | groupLayout | |
193 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
194 | .addComponent(this.getCheckboxUseDigestAuthentication()) | |
195 | .addComponent(labelUseDigestAuthentication) | |
196 | ) | |
197 | .addGroup( | |
198 | groupLayout | |
199 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
200 | .addComponent(labelDigestAuthenticationUsername) | |
201 | .addComponent(this.getTextDigestAuthenticationUsername()) | |
202 | ) | |
203 | .addGroup( | |
204 | groupLayout | |
205 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
206 | .addComponent(labelDigestAuthenticationPassword) | |
207 | .addComponent(this.getTextDigestAuthenticationPassword()) | |
208 | ) | |
209 | .addGroup( | |
210 | groupLayout | |
211 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
212 | .addComponent(labelMarginHidden) | |
213 | .addComponent(labelMargin) | |
214 | ) | |
215 | .addGroup( | |
216 | groupLayout | |
217 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
218 | .addComponent(this.getCheckboxUseKerberos()) | |
219 | .addComponent(labelUseKerberos) | |
220 | ) | |
221 | .addGroup( | |
222 | groupLayout | |
223 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
224 | .addComponent(labelKerberosLoginConf) | |
225 | .addComponent(this.getTextKerberosLoginConf()) | |
226 | ) | |
227 | .addGroup( | |
228 | groupLayout | |
229 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
230 | .addComponent(labelKerberosKrb5Conf) | |
231 | .addComponent(this.getTextKerberosKrb5Conf()) | |
232 | ) | |
233 | ); | |
234 | } | |
235 | | |
236 | | |
237 | // Getter and setter | |
238 | | |
239 | public JCheckBox getCheckboxUseDigestAuthentication() { | |
240 |
1
1. getCheckboxUseDigestAuthentication : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuth::getCheckboxUseDigestAuthentication → NO_COVERAGE |
return this.checkboxUseDigestAuthentication; |
241 | } | |
242 | ||
243 | public JTextField getTextDigestAuthenticationUsername() { | |
244 |
1
1. getTextDigestAuthenticationUsername : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuth::getTextDigestAuthenticationUsername → NO_COVERAGE |
return this.textDigestAuthenticationUsername; |
245 | } | |
246 | ||
247 | public JTextField getTextDigestAuthenticationPassword() { | |
248 |
1
1. getTextDigestAuthenticationPassword : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuth::getTextDigestAuthenticationPassword → NO_COVERAGE |
return this.textDigestAuthenticationPassword; |
249 | } | |
250 | ||
251 | public JCheckBox getCheckboxUseKerberos() { | |
252 |
1
1. getCheckboxUseKerberos : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuth::getCheckboxUseKerberos → NO_COVERAGE |
return this.checkboxUseKerberos; |
253 | } | |
254 | ||
255 | public JTextField getTextKerberosKrb5Conf() { | |
256 |
1
1. getTextKerberosKrb5Conf : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuth::getTextKerberosKrb5Conf → NO_COVERAGE |
return this.textKerberosKrb5Conf; |
257 | } | |
258 | ||
259 | public JTextField getTextKerberosLoginConf() { | |
260 |
1
1. getTextKerberosLoginConf : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelAuth::getTextKerberosLoginConf → NO_COVERAGE |
return this.textKerberosLoginConf; |
261 | } | |
262 | } | |
Mutations | ||
30 |
1.1 |
|
33 |
1.1 |
|
45 |
1.1 |
|
48 |
1.1 |
|
49 |
1.1 |
|
61 |
1.1 |
|
64 |
1.1 |
|
77 |
1.1 |
|
89 |
1.1 |
|
90 |
1.1 |
|
92 |
1.1 |
|
94 |
1.1 2.2 |
|
95 |
1.1 |
|
96 |
1.1 |
|
99 |
1.1 |
|
102 |
1.1 |
|
104 |
1.1 2.2 |
|
105 |
1.1 |
|
106 |
1.1 |
|
109 |
1.1 |
|
112 |
1.1 |
|
113 |
1.1 |
|
114 |
1.1 |
|
115 |
1.1 |
|
117 |
1.1 |
|
118 |
1.1 |
|
120 |
1.1 |
|
121 |
1.1 |
|
127 |
1.1 2.2 |
|
132 |
1.1 |
|
142 |
1.1 2.2 |
|
148 |
1.1 |
|
150 |
1.1 |
|
151 |
1.1 |
|
152 |
1.1 |
|
157 |
1.1 |
|
160 |
1.1 |
|
188 |
1.1 |
|
240 |
1.1 |
|
244 |
1.1 |
|
248 |
1.1 |
|
252 |
1.1 |
|
256 |
1.1 |
|
260 |
1.1 |