diff --git a/docker/getversion.sh b/docker/getversion.sh index 055cb36cf..8d181d60c 100755 --- a/docker/getversion.sh +++ b/docker/getversion.sh @@ -21,5 +21,5 @@ jlversion=`echo "$jlversion" | tr _ .` # tadaaa! # echo $jlversion -echo 2.6.0.3 +echo 2.6.0.5 diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/SplashThread.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/SplashThread.java index 83629f0a0..a3b5cf0f4 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/SplashThread.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/SplashThread.java @@ -799,6 +799,7 @@ public void run() { AppUserBean[] assistUsers = null; AppUserBean[] allUsers = null; List loginEnabledUsers=null; + List messagingEnabledUsers=null; try { SystemManagementRemote mgmt = locator.lookupSystemManagementRemote(); ArchiveFileServiceRemote afs = locator.lookupArchiveFileServiceRemote(); @@ -827,6 +828,7 @@ public void run() { updateStatus(java.util.ResourceBundle.getBundle("com/jdimension/jlawyer/client/SplashThread").getString("status.option.6"), true); loginEnabledUsers = security.getUsersHavingRole(UserSettings.ROLE_LOGIN); + messagingEnabledUsers = security.getMessagingEnabledUsers(); List users = mgmt.getUsers(); List lawyers = new ArrayList<>(); @@ -879,6 +881,7 @@ public void run() { UserSettings.getInstance().setAssistantUsers(assistUsers); UserSettings.getInstance().setAllUsers(allUsers); UserSettings.getInstance().setLoginEnabledUsers(loginEnabledUsers); + UserSettings.getInstance().setMessagingEnabledUsers(messagingEnabledUsers); settings.setTitles(titles); settings.setTitlesInAddress(titlesInAddress); settings.setCountries(countries); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/UserAdministrationDialog.form b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/UserAdministrationDialog.form index eb35abe6f..56bc91c80 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/UserAdministrationDialog.form +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/UserAdministrationDialog.form @@ -62,7 +62,13 @@ - + + + + + + + @@ -72,13 +78,13 @@ - - - - - - - + + + + + + + @@ -101,8 +107,10 @@ - - + + + + @@ -256,7 +264,7 @@ - + @@ -613,9 +621,9 @@ - + - + @@ -715,7 +723,7 @@ - + @@ -931,7 +939,7 @@ - + @@ -1068,7 +1076,7 @@ - + @@ -1258,9 +1266,9 @@ - + - + @@ -1357,7 +1365,7 @@ - + @@ -1396,5 +1404,13 @@ + + + + + + + + diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/UserAdministrationDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/UserAdministrationDialog.java index c1a3fcc36..eac5cf7e8 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/UserAdministrationDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/configuration/UserAdministrationDialog.java @@ -681,6 +681,7 @@ import com.jdimension.jlawyer.client.utils.ComponentUtils; import com.jdimension.jlawyer.client.utils.FileUtils; import com.jdimension.jlawyer.client.utils.FrameUtils; +import com.jdimension.jlawyer.client.utils.StringUtils; import com.jdimension.jlawyer.client.voip.EpostSetPasswordDialog; import com.jdimension.jlawyer.client.voip.EpostVendorIdRequestDialog; import com.jdimension.jlawyer.fax.SipUser; @@ -734,12 +735,8 @@ public UserAdministrationDialog(java.awt.Frame parent, boolean modal) { try { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); - SystemManagementRemote mgmt = locator.lookupSystemManagementRemote(); - List allUsers = mgmt.getUsers(); - for (AppUserBean u : allUsers) { - m.addElement(u); - } - + this.populateUsersList(this.chkShowExternalUsers.isSelected()); + CalendarUtils cu = CalendarUtils.getInstance(); this.countries = cu.getCountryCodes(); ArrayList countryNames = new ArrayList(); @@ -799,6 +796,24 @@ public UserAdministrationDialog(java.awt.Frame parent, boolean modal) { } + private void populateUsersList(boolean includeExternalUsers) throws Exception { + ClientSettings settings = ClientSettings.getInstance(); + JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); + UserListModel m=(UserListModel)this.lstUsers.getModel(); + m.clear(); + SystemManagementRemote mgmt = locator.lookupSystemManagementRemote(); + List allUsers = mgmt.getUsers(); + for (AppUserBean u : allUsers) { + if(StringUtils.isEmpty(u.getExternalId())) { + // internal users are always displayed + m.addElement(u); + } else { + if(includeExternalUsers) + m.addElement(u); + } + } + } + private void updateEpostStatus() { String encryptedVendorId=ServerSettings.getInstance().getSetting(ServerSettings.SERVERCONF_EPOSTVENDORID_ENCRYPTED, ""); if("".equalsIgnoreCase(encryptedVendorId)) { @@ -915,6 +930,7 @@ private void initComponents() { jLabel7 = new javax.swing.JLabel(); jScrollPane3 = new javax.swing.JScrollPane(); tblInvoicePools = new javax.swing.JTable(); + chkShowExternalUsers = new javax.swing.JCheckBox(); mnuDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/editdelete.png"))); // NOI18N mnuDelete.setText("Löschen"); @@ -1204,7 +1220,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jPanel13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(281, Short.MAX_VALUE)) + .addContainerGap(164, Short.MAX_VALUE)) ); jPanel1.getAccessibleContext().setAccessibleName(""); @@ -1284,8 +1300,8 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel6Layout.createSequentialGroup() .add(jLabel21) - .add(0, 430, Short.MAX_VALUE)) - .add(jScrollPane5)) + .add(0, 382, Short.MAX_VALUE)) + .add(jScrollPane5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)) .addContainerGap()) ); @@ -1335,7 +1351,7 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { .add(jPanel7Layout.createSequentialGroup() .addContainerGap() .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(jScrollPane6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 517, Short.MAX_VALUE) + .add(jScrollPane6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 476, Short.MAX_VALUE) .add(jPanel7Layout.createSequentialGroup() .add(jLabel22) .add(0, 0, Short.MAX_VALUE))) @@ -1441,7 +1457,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .add(jPanel10Layout.createSequentialGroup() .add(pnlCloudConnection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(18, 18, 18) - .add(nextcloudTeaserPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE))) + .add(nextcloudTeaserPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 486, Short.MAX_VALUE))) .addContainerGap()) ); jPanel10Layout.setVerticalGroup( @@ -1453,7 +1469,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .add(pnlCloudConnection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add(jLabel5) - .addContainerGap(339, Short.MAX_VALUE)) + .addContainerGap(248, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Nextcloud", jPanel10); @@ -1597,7 +1613,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .add(jSeparator2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jLabel26) - .addContainerGap(248, Short.MAX_VALUE)) + .addContainerGap(154, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Sipgate / E-POST", jPanel11); @@ -1675,8 +1691,8 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel9Layout.createSequentialGroup() .add(jLabel19) - .add(0, 435, Short.MAX_VALUE)) - .add(jScrollPane4)) + .add(0, 382, Short.MAX_VALUE)) + .add(jScrollPane4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)) .addContainerGap()) ); @@ -1729,12 +1745,19 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { .add(jPanel12Layout.createSequentialGroup() .add(jLabel7) .add(0, 0, Short.MAX_VALUE)) - .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 519, Short.MAX_VALUE)) + .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 476, Short.MAX_VALUE)) .addContainerGap()) ); jTabbedPane1.addTab("Belege", jPanel12); + chkShowExternalUsers.setText("Nutzer aus externen System anzeigen"); + chkShowExternalUsers.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + chkShowExternalUsersActionPerformed(evt); + } + }); + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( @@ -1743,6 +1766,11 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jTabbedPane1) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .add(0, 0, Short.MAX_VALUE) + .add(cmdSave) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(cmdClose)) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(cmdAdd) @@ -1751,12 +1779,11 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(txtUser, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 216, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) .add(18, 18, 18) - .add(jScrollPane1)) - .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() - .add(0, 0, Short.MAX_VALUE) - .add(cmdSave) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(cmdClose))) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(chkShowExternalUsers) + .add(0, 0, Short.MAX_VALUE)) + .add(jScrollPane1)))) .addContainerGap()) ); layout.setVerticalGroup( @@ -1772,8 +1799,10 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { .add(cmdAdd)) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 137, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 570, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(chkShowExternalUsers) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 532, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 27, Short.MAX_VALUE) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(cmdClose) .add(cmdSave)) @@ -2076,6 +2105,41 @@ private void lstUsersValueChanged(javax.swing.event.ListSelectionEvent evt) {//G log.error("Error connecting to server", ex); JOptionPane.showMessageDialog(this, ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); } + } else { + this.chkLawyer.setSelected(false); + this.cmbCountry.setSelectedIndex(0); + this.cmbArea.setSelectedIndex(0); + this.txtAbbreviation.setText(""); + this.cmbPrimaryGroup.setSelectedIndex(0); + + this.pnlCloudConnection.setCloudHost(""); + this.pnlCloudConnection.setCloudPath(""); + this.pnlCloudConnection.setCloudPort(443); + this.pnlCloudConnection.setCloudUser(""); + this.pnlCloudConnection.setCloudPassword(""); + this.pnlCloudConnection.setSsl(true); + + this.txtVoipPassword.setText(""); + this.txtVoipUser.setText(""); + this.cmbVoipId.removeAllItems(); + + this.txtEpostCustomer.setText(""); + this.txtEpostSecret.setText(""); + + this.pwdEpostPassword.setText(""); + + this.txtDisplayName.setText(""); + + + this.rdAutoLogin.setSelected(false); + this.rdManualLogin.setSelected(true); + + this.pwdBeaCertificatePassword.setText(""); + this.currentCertificate = null; + + + this.taBeaCertificate.setText(""); + } }//GEN-LAST:event_lstUsersValueChanged @@ -2569,6 +2633,15 @@ private void cmdSetEpostPasswordActionPerformed(java.awt.event.ActionEvent evt) }//GEN-LAST:event_cmdSetEpostPasswordActionPerformed + private void chkShowExternalUsersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkShowExternalUsersActionPerformed + try { + this.populateUsersList(this.chkShowExternalUsers.isSelected()); + } catch (Exception ex) { + log.error("Error loading users", ex); + JOptionPane.showMessageDialog(this, ex.getMessage(), com.jdimension.jlawyer.client.utils.DesktopUtils.POPUP_TITLE_ERROR, JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_chkShowExternalUsersActionPerformed + private List getRolesFromUI(String principalId) { List result = new ArrayList<>(); @@ -2834,6 +2907,7 @@ public static void main(String args[]) { private javax.swing.JCheckBox chkRemoveOption; private javax.swing.JCheckBox chkReportCommon; private javax.swing.JCheckBox chkReportConfidential; + private javax.swing.JCheckBox chkShowExternalUsers; private javax.swing.JCheckBox chkWriteAddress; private javax.swing.JCheckBox chkWriteFile; private javax.swing.JCheckBox chkWriteOption; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java index cbedd1263..21c358fae 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java @@ -855,7 +855,7 @@ public ArchiveFilePanel() { ComponentUtils.decorateSplitPane(this.splitNotes); this.messageSendPanel1.setMessageConsumer(this); - this.messageSendPanel1.setUsers(UserSettings.getInstance().getLoginEnabledUsers()); + this.messageSendPanel1.setUsers(UserSettings.getInstance().getMessagingEnabledUsers()); this.tagPanel.setLayout(new WrapLayout()); this.documentTagPanel.setLayout(new WrapLayout()); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/CalloutPanelComponent.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/CalloutPanelComponent.java index 22e131132..914b28fa7 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/CalloutPanelComponent.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/CalloutPanelComponent.java @@ -907,13 +907,8 @@ protected void paintComponent(Graphics g) { g2d.setColor(DefaultColorTheme.COLOR_DARK_GREY); } - //g2d.fillRoundRect(0, 0, width, height, cornerRadius, cornerRadius); g2d.fillRect(0, 0, width, height); -// int[] xPoints = {width, width, width}; -// int[] yPoints = {height / 2, height / 2, height / 2}; -// -// g2d.fillPolygon(xPoints, yPoints, 3); if (this.message != null && this.message.hasMentions()) { if (this.message.hasOpenMentions()) { if(this.message.getMentions().size()==this.message.getOpenMentionsCount()) @@ -930,8 +925,6 @@ protected void paintComponent(Graphics g) { } g2d.setColor(DefaultColorTheme.COLOR_DARK_GREY); - //g2d.drawRoundRect(0, 0, width, height, cornerRadius, cornerRadius); - //g2d.drawRect(0, 0, width, height); g2d.setFont(defaultFont); @@ -971,7 +964,6 @@ protected void paintComponent(Graphics g) { g2d.setFont(miniFont); g2d.setColor(DefaultColorTheme.COLOR_LIGHT_GREY); - //g2d.drawString(timestamp, 10, yOffset + 15); // Timestamp position Date sent = null; if (this.message == null || this.message.getSent() == null) { sent = new Date(); @@ -984,21 +976,16 @@ protected void paintComponent(Graphics g) { if (read == READ) { // read g2d.setColor(DefaultColorTheme.COLOR_LOGO_GREEN); - //g2d.fillOval(width - 25, 10, 10, 10); // Unread indicator position g2d.fillOval(10, indicatorY, 15, 15); // Unread indicator position } else { // unread g2d.setColor(DefaultColorTheme.COLOR_LOGO_RED); - //g2d.fillOval(width - 25, 10, 10, 10); // Unread indicator position g2d.fillOval(10, indicatorY, 15, 15); // Unread indicator position } } // delete button this.deleteX=width-70; -// g2d.setFont(miniFont.deriveFont(defaultFont.getStyle() | java.awt.Font.BOLD)); -// g2d.setColor(DefaultColorTheme.COLOR_LIGHT_GREY); -// g2d.drawString("x", this.deleteX,this.deleteY); // Timestamp position // delete icon ICON_DELETE.paintIcon(this, g2d, this.deleteX, this.deleteY); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/MessagingCenterPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/MessagingCenterPanel.java index c592d4632..a293bc097 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/MessagingCenterPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/MessagingCenterPanel.java @@ -768,7 +768,7 @@ public MessagingCenterPanel() { this.refresh(); - this.messageSendPanel1.setUsers(UserSettings.getInstance().getLoginEnabledUsers()); + this.messageSendPanel1.setUsers(UserSettings.getInstance().getMessagingEnabledUsers()); EventBroker eb = EventBroker.getInstance(); eb.subscribeConsumer(this, Event.TYPE_INSTANTMESSAGING_NEWMESSAGES); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/PopoutMessenger.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/PopoutMessenger.java index 40ef0ab5a..b4f1e7f47 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/PopoutMessenger.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/messenger/PopoutMessenger.java @@ -717,7 +717,7 @@ public PopoutMessenger(java.awt.Frame parent, boolean modal, ArrayList loginEnabledUsers = null; + private List messagingEnabledUsers = null; private SystemManagementRemote mgmt = null; @@ -767,13 +768,13 @@ public class UserSettings { private ImageIcon smallIcon = null; private ImageIcon bigIcon = null; - private Hashtable userIconsSmall = new Hashtable(); - private Hashtable userIconsBig = new Hashtable(); - private Hashtable> userRoles = new Hashtable>(); + private Hashtable userIconsSmall = new Hashtable<>(); + private Hashtable userIconsBig = new Hashtable<>(); + private Hashtable> userRoles = new Hashtable<>(); - private Hashtable> userMailboxes = new Hashtable>(); + private Hashtable> userMailboxes = new Hashtable<>(); - private ArrayList invalidUsers = new ArrayList(); + private ArrayList invalidUsers = new ArrayList<>(); /** * Creates a new instance of ClientSettings @@ -1107,4 +1108,18 @@ private void loadUserIconsToCache(String principalId) { } } + /** + * @return the messagingEnabledUsers + */ + public List getMessagingEnabledUsers() { + return messagingEnabledUsers; + } + + /** + * @param messagingEnabledUsers the messagingEnabledUsers to set + */ + public void setMessagingEnabledUsers(List messagingEnabledUsers) { + this.messagingEnabledUsers = messagingEnabledUsers; + } + } diff --git a/j-lawyer-server-api/src/com/jdimension/jlawyer/services/SecurityServiceRemote.java b/j-lawyer-server-api/src/com/jdimension/jlawyer/services/SecurityServiceRemote.java index 430d54396..cfdb68717 100644 --- a/j-lawyer-server-api/src/com/jdimension/jlawyer/services/SecurityServiceRemote.java +++ b/j-lawyer-server-api/src/com/jdimension/jlawyer/services/SecurityServiceRemote.java @@ -726,4 +726,6 @@ public interface SecurityServiceRemote { MailboxSetup updateMailboxSetup(MailboxSetup cs); void removeMailboxSetup(MailboxSetup cs); + + List getMessagingEnabledUsers() throws Exception; } diff --git a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/AppUserBean.java b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/AppUserBean.java index 70501b8b9..1e0485342 100755 --- a/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/AppUserBean.java +++ b/j-lawyer-server-entities/src/java/com/jdimension/jlawyer/persistence/AppUserBean.java @@ -677,6 +677,7 @@ @NamedQueries({ @NamedQuery(name = "AppUserBean.findAll", query = "SELECT a FROM AppUserBean a"), @NamedQuery(name = "AppUserBean.findByPrincipalId", query = "SELECT a FROM AppUserBean a WHERE a.principalId = :principalId"), + @NamedQuery(name = "AppUserBean.findByExternalId", query = "SELECT a FROM AppUserBean a WHERE a.externalId = :externalId"), @NamedQuery(name = "AppUserBean.findByPassword", query = "SELECT a FROM AppUserBean a WHERE a.password = :password")}) public class AppUserBean implements Serializable { private static final long serialVersionUID = 1L; @@ -750,6 +751,9 @@ public class AppUserBean implements Serializable { @Column(name = "epost_secret") protected String epostSecret; + @Column(name = "ext_id") + private String externalId; + public AppUserBean() { } @@ -1114,6 +1118,20 @@ public String getEpostSecret() { public void setEpostSecret(String epostSecret) { this.epostSecret = epostSecret; } + + /** + * @return the externalId + */ + public String getExternalId() { + return externalId; + } + + /** + * @param externalId the externalId to set + */ + public void setExternalId(String externalId) { + this.externalId = externalId; + } diff --git a/j-lawyer-server-entities/src/java/db/migration/V2_6_0_5__UsersAddExtId.sql b/j-lawyer-server-entities/src/java/db/migration/V2_6_0_5__UsersAddExtId.sql new file mode 100644 index 000000000..765877d11 --- /dev/null +++ b/j-lawyer-server-entities/src/java/db/migration/V2_6_0_5__UsersAddExtId.sql @@ -0,0 +1,5 @@ +alter table security_users add `ext_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL; +alter table security_users add unique index `idx_users_extid` (ext_id); + +insert into server_settings(settingKey, settingValue) values('jlawyer.server.database.version','2.6.0.5') ON DUPLICATE KEY UPDATE settingValue = '2.6.0.5'; +commit; \ No newline at end of file diff --git a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/SecurityEndpointV1.java b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/SecurityEndpointV1.java index f0175882b..999a5ea12 100644 --- a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/SecurityEndpointV1.java +++ b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v1/SecurityEndpointV1.java @@ -700,5 +700,5 @@ public Response getApiMetadata() { return res; } - + } diff --git a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/SecurityEndpointLocalV6.java b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/SecurityEndpointLocalV6.java index c262ef447..d43a8e1cd 100644 --- a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/SecurityEndpointLocalV6.java +++ b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/SecurityEndpointLocalV6.java @@ -665,6 +665,7 @@ You should also get your employer (if you work as a programmer) or school, import javax.ejb.Local; import javax.ws.rs.core.Response; +import org.jlawyer.io.rest.v6.pojo.RestfulUserV6; /** * @@ -675,4 +676,10 @@ public interface SecurityEndpointLocalV6 { Response getEnabledUsers(); + Response listUsers(); + + Response getUserByExternalId(String extId); + + Response createUser(RestfulUserV6 userData); + } diff --git a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/SecurityEndpointV6.java b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/SecurityEndpointV6.java index 3fd8bfd3e..88c85e616 100644 --- a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/SecurityEndpointV6.java +++ b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/SecurityEndpointV6.java @@ -665,13 +665,17 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.persistence.AppUserBean; import com.jdimension.jlawyer.services.SecurityServiceLocal; +import com.jdimension.jlawyer.services.SystemManagementLocal; import java.util.ArrayList; import java.util.List; +import javax.annotation.security.RolesAllowed; import javax.ejb.Stateless; import javax.naming.InitialContext; import javax.ws.rs.Consumes; import javax.ws.rs.GET; +import javax.ws.rs.PUT; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -687,11 +691,14 @@ You should also get your employer (if you work as a programmer) or school, @Consumes({"application/json"}) @Produces({"application/json"}) public class SecurityEndpointV6 implements SecurityEndpointLocalV6 { - + private static final Logger log = Logger.getLogger(SecurityEndpointV6.class.getName()); + + private static final String LOOKUP_SYSMAN="java:global/j-lawyer-server/j-lawyer-server-ejb/SystemManagement!com.jdimension.jlawyer.services.SystemManagementLocal"; /** - * Returns all user available in the system who have at least the permission to log in + * Returns all user available in the system who have at least the permission + * to log in * * @response 401 User not authorized * @response 403 User not authenticated @@ -699,23 +706,17 @@ public class SecurityEndpointV6 implements SecurityEndpointLocalV6 { @Override @Path("/users") @GET - @Produces(MediaType.APPLICATION_JSON+";charset=utf-8") + @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8") public Response getEnabledUsers() { try { InitialContext ic = new InitialContext(); SecurityServiceLocal security = (SecurityServiceLocal) ic.lookup("java:global/j-lawyer-server/j-lawyer-server-ejb/SecurityService!com.jdimension.jlawyer.services.SecurityServiceLocal"); - List enabledUsers=security.getUsersHavingRole("loginRole"); - ArrayList resultList=new ArrayList<>(); - for(AppUserBean au: enabledUsers) { - RestfulUserV6 u=new RestfulUserV6(); - u.setAbbreviation(au.getAbbreviation()); - u.setAreaCode(au.getAreaCode()); - u.setCountryCode(au.getCountryCode()); - u.setDisplayName(au.getDisplayName()); - u.setLawyer(u.isLawyer()); - u.setPrincipalId(au.getPrincipalId()); + List enabledUsers = security.getUsersHavingRole("loginRole"); + ArrayList resultList = new ArrayList<>(); + for (AppUserBean au : enabledUsers) { + RestfulUserV6 u = RestfulUserV6.fromAppUserBean(au); resultList.add(u); } @@ -729,4 +730,109 @@ public Response getEnabledUsers() { } + /** + * Lists all users, including ones without login permission + * + * @response 401 User not authorized + * @response 403 User not authenticated + */ + @Override + @GET + @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8") + @Path("/users/list") + @RolesAllowed({"loginRole"}) + public Response listUsers() { + try { + InitialContext ic = new InitialContext(); + SystemManagementLocal system = (SystemManagementLocal) ic.lookup(LOOKUP_SYSMAN); + List allUsers=system.getUsers(); + ArrayList resultList = new ArrayList<>(); + for (AppUserBean au : allUsers) { + RestfulUserV6 u = RestfulUserV6.fromAppUserBean(au); + resultList.add(u); + } + + return Response.ok(resultList).build(); + } catch (Exception ex) { + log.error("can not get document template folder structure ", ex); + return Response.serverError().build(); + } + + } + + /** + * Returns a users metadata given its external ID + * + * @param extId the users external ID + * @response 401 User not authorized + * @response 403 User not authenticated + * @response 404 No user found with this external ID + */ + @Override + @GET + @Produces(MediaType.APPLICATION_JSON+";charset=utf-8") + @Path("/users/byexternalid/{extId}") + @RolesAllowed({"loginRole"}) + public Response getUserByExternalId(@PathParam("extId") String extId) { + try { + InitialContext ic = new InitialContext(); + SecurityServiceLocal security = (SecurityServiceLocal) ic.lookup("java:global/j-lawyer-server/j-lawyer-server-ejb/SecurityService!com.jdimension.jlawyer.services.SecurityServiceLocal"); + AppUserBean au=security.getUserByExternalId(extId); + + if(au!=null) { + + RestfulUserV6 u = RestfulUserV6.fromAppUserBean(au); + return Response.ok(u).build(); + } else { + return Response.status(Response.Status.NOT_FOUND).build(); + } + } catch (Exception ex) { + log.error("can not get user by external id " + extId, ex); + return Response.serverError().build(); + } + + } + + /** + * Creates a new user. No permissions will be granted. Does currently not support all attributes. + * + * @param userData user data + * @response 401 User not authorized + * @response 403 User not authenticated + */ + @Override + @PUT + @Produces(MediaType.APPLICATION_JSON+";charset=utf-8") + @Path("/users/create") + @RolesAllowed({"adminRole"}) + public Response createUser(RestfulUserV6 userData) { + + // curl -u admin:a -X PUT -H "Content-Type: application/json" -d '{"name":"via REST", "reason":"wegen REST", "subjectField":"Familienrecht", "notice":"notiz REST","assistant":"user", "lawyer":"admin", "claimNumber":"RESTcn","claimValue":"3.44","custom1":"RESTc1","custom2":"RESTc2","custom3":"RESTc3"}' http://localhost:8080/j-lawyer-io/rest/cases/create + try { + + if (userData.getPrincipalId() == null || "".equals(userData.getPrincipalId())) { + log.error("Can not create new user - no principal ID given"); + return Response.serverError().build(); + } + + InitialContext ic = new InitialContext(); + SystemManagementLocal system = (SystemManagementLocal) ic.lookup(LOOKUP_SYSMAN); + + AppUserBean u = new AppUserBean(); + u = userData.toAppUserBean(u); + + // apply dummy password - not an issue, because the user will not have any login permission anyways + u.setPassword(""+System.currentTimeMillis()); + u=system.createUser(u, new ArrayList<>()); + + userData = RestfulUserV6.fromAppUserBean(u); + + Response res = Response.ok(userData).build(); + return res; + } catch (Exception ex) { + log.error("can not create new user " + userData.getPrincipalId(), ex); + return Response.serverError().build(); + } + } + } diff --git a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/pojo/RestfulUserV6.java b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/pojo/RestfulUserV6.java index ba78f41e9..548625999 100644 --- a/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/pojo/RestfulUserV6.java +++ b/j-lawyer-server/j-lawyer-io/src/java/org/jlawyer/io/rest/v6/pojo/RestfulUserV6.java @@ -663,6 +663,8 @@ You should also get your employer (if you work as a programmer) or school, */ package org.jlawyer.io.rest.v6.pojo; +import com.jdimension.jlawyer.persistence.AppUserBean; + /** * * @author jens @@ -678,9 +680,36 @@ public class RestfulUserV6 { protected String displayName; + private String externalId=null; + public RestfulUserV6() { } + + public AppUserBean toAppUserBean(AppUserBean au) { + + au.setPrincipalId(principalId); + au.setLawyer(lawyer); + au.setCountryCode(countryCode); + au.setAreaCode(areaCode); + au.setAbbreviation(abbreviation); + au.setDisplayName(displayName); + au.setExternalId(externalId); + return au; + + } + + public static RestfulUserV6 fromAppUserBean(AppUserBean au) { + RestfulUserV6 u = new RestfulUserV6(); + u.setAbbreviation(au.getAbbreviation()); + u.setAreaCode(au.getAreaCode()); + u.setCountryCode(au.getCountryCode()); + u.setDisplayName(au.getDisplayName()); + u.setExternalId(au.getExternalId()); + u.setLawyer(au.isLawyer()); + u.setPrincipalId(au.getPrincipalId()); + return u; + } /** * @return the principalId @@ -765,5 +794,19 @@ public String getDisplayName() { public void setDisplayName(String displayName) { this.displayName = displayName; } + + /** + * @return the externalId + */ + public String getExternalId() { + return externalId; + } + + /** + * @param externalId the externalId to set + */ + public void setExternalId(String externalId) { + this.externalId = externalId; + } } diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/AppUserBeanFacade.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/AppUserBeanFacade.java index c1fe83bb2..1f7a28089 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/AppUserBeanFacade.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/AppUserBeanFacade.java @@ -668,6 +668,7 @@ import javax.annotation.security.RolesAllowed; import javax.ejb.Stateless; import javax.persistence.EntityManager; +import javax.persistence.NoResultException; import javax.persistence.PersistenceContext; /** @@ -704,6 +705,16 @@ public AppUserBean findByPrincipalIdUnrestricted(String principalId) { return u; } + + + @Override + public AppUserBean findByExternalId(String externalId) { + try { + return (AppUserBean) em.createNamedQuery("AppUserBean.findByExternalId").setParameter("externalId", externalId).getSingleResult(); + } catch (NoResultException nre) { + return null; + } + } @Override @RolesAllowed("loginRole") diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/AppUserBeanFacadeLocal.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/AppUserBeanFacadeLocal.java index 7cedf81ea..db99a5a68 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/AppUserBeanFacadeLocal.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/persistence/AppUserBeanFacadeLocal.java @@ -689,6 +689,8 @@ public interface AppUserBeanFacadeLocal { AppUserBean findByPrincipalId(String principalId); AppUserBean findByPrincipalIdUnrestricted(String principalId); + + AppUserBean findByExternalId(String externalId); boolean hasPrincipalId(String principalId); } diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SecurityService.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SecurityService.java index 77f8dbaaa..9770de038 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SecurityService.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SecurityService.java @@ -909,6 +909,8 @@ public List getCalendarsForUser(String principalId) throws Except return calendars; } + + @Override @RolesAllowed({"loginRole"}) public List getUsersHavingRole(String role) throws Exception { @@ -925,6 +927,12 @@ public List getUsersHavingRole(String role) throws Exception { } return resultList; } + + @Override + @RolesAllowed({"loginRole"}) + public AppUserBean getUserByExternalId(String extId) { + return this.userBeanFacade.findByExternalId(extId); + } @Override @RolesAllowed({"adminRole"}) @@ -1015,4 +1023,28 @@ public boolean addUserToInvoicePool(String principalId, String poolId) throws Ex return true; } + @Override + @RolesAllowed({"loginRole"}) + public List getMessagingEnabledUsers() throws Exception { + List allUsers=this.userBeanFacade.findAll(); + List resultList=new ArrayList<>(); + for(AppUserBean u: allUsers) { + if(u.getExternalId()!=null && !"".equals(u.getExternalId())) { + // external users are always enabled for messaging + resultList.add(u); + } else { + // if not an external user, check for login permission + List userRoles = this.roleBeanFacade.findByPrincipalId(u.getPrincipalId()); + for (AppRoleBean r : userRoles) { + if (r.getRole().equalsIgnoreCase("loginRole")) { + resultList.add(u); + break; + } + } + } + + } + return resultList; + } + } diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SecurityServiceLocal.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SecurityServiceLocal.java index 9875d3624..c70b81bde 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SecurityServiceLocal.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SecurityServiceLocal.java @@ -692,4 +692,6 @@ public interface SecurityServiceLocal { boolean addUserToInvoicePool(String principalId, String poolId) throws Exception; + public AppUserBean getUserByExternalId(String extId); + } diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SystemManagementLocal.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SystemManagementLocal.java index 4a21aed8f..969612393 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SystemManagementLocal.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/SystemManagementLocal.java @@ -664,6 +664,7 @@ package com.jdimension.jlawyer.services; import com.jdimension.jlawyer.persistence.AppOptionGroupBean; +import com.jdimension.jlawyer.persistence.AppRoleBean; import com.jdimension.jlawyer.persistence.AppUserBean; import com.jdimension.jlawyer.persistence.ArchiveFileBean; import com.jdimension.jlawyer.persistence.Invoice; @@ -701,6 +702,10 @@ public interface SystemManagementLocal { PartyTypeBean getPartyType(String id); AppUserBean getUser(String principalId); + + List getUsers(); + + AppUserBean createUser(AppUserBean user, List roles) throws Exception; List getMappingTables();