You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2020/11/25 15:37:18 UTC

[syncope] branch 2_1_X updated (1cec965 -> 091781e)

This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a change to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git.


    from 1cec965  [SYNCOPE-1604] short date years represented by 4 digits (#228)
     new aeea76c  Allow easier subclassing
     new 091781e  Upgrading Mockito

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../markup/html/form/AjaxDateTimeFieldPanel.java   | 14 +++++++-----
 .../wicket/markup/html/form/DateFieldPanel.java    | 25 ++++++++++-----------
 .../java/pushpull/DBPasswordPullActions.java       | 26 +++++++++-------------
 .../java/pushpull/LDAPPasswordPullActions.java     |  8 +++----
 pom.xml                                            |  2 +-
 5 files changed, 36 insertions(+), 39 deletions(-)


[syncope] 01/02: Allow easier subclassing

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit aeea76c69ca54fc25081cadb02b8a0b4e070b3a3
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Wed Nov 25 12:35:07 2020 +0100

    Allow easier subclassing
---
 .../markup/html/form/AjaxDateTimeFieldPanel.java   | 14 +++++++-----
 .../wicket/markup/html/form/DateFieldPanel.java    | 25 ++++++++++-----------
 .../java/pushpull/DBPasswordPullActions.java       | 26 +++++++++-------------
 .../java/pushpull/LDAPPasswordPullActions.java     |  8 +++----
 4 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/AjaxDateTimeFieldPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/AjaxDateTimeFieldPanel.java
index 37318cf..485ceec 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/AjaxDateTimeFieldPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/AjaxDateTimeFieldPanel.java
@@ -19,10 +19,9 @@
 package org.apache.syncope.client.console.wicket.markup.html.form;
 
 import com.googlecode.wicket.kendo.ui.form.datetime.AjaxDateTimePicker;
-
 import java.text.DateFormat;
 import java.util.Date;
-
+import java.util.Locale;
 import org.apache.commons.lang3.time.FastDateFormat;
 import org.apache.syncope.client.console.SyncopeConsoleSession;
 import org.apache.wicket.model.IModel;
@@ -40,10 +39,13 @@ public class AjaxDateTimeFieldPanel extends DateFieldPanel {
 
         // dateTimePattern should be spit into separate date and time pattern strings in order to be passed to the
         // AjaxDateTimePicker constructor, but there is no safe way to do that - ignoring
-        field = new AjaxDateTimePicker("field", model, SyncopeConsoleSession.get().getLocale(),
-                FastDateFormat.getDateInstance(DateFormat.SHORT, SyncopeConsoleSession.get().getLocale()).getPattern()
-                        .replace("yy", "yyyy"),
-                FastDateFormat.getTimeInstance(DateFormat.SHORT, SyncopeConsoleSession.get().getLocale()).getPattern());
+        Locale locale = SyncopeConsoleSession.get().getLocale();
+        field = new AjaxDateTimePicker(
+                "field",
+                model,
+                locale,
+                FastDateFormat.getDateInstance(DateFormat.SHORT, locale).getPattern().replace("yy", "yyyy"),
+                FastDateFormat.getTimeInstance(DateFormat.SHORT, locale).getPattern());
         add(field.setLabel(new ResourceModel(name, name)).setOutputMarkupId(true));
     }
 
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateFieldPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateFieldPanel.java
index ff8f4d9..99d2ad4 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateFieldPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateFieldPanel.java
@@ -23,6 +23,7 @@ import java.io.Serializable;
 import java.text.ParseException;
 import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 import org.apache.commons.lang3.time.FastDateFormat;
 import org.apache.syncope.client.console.SyncopeConsoleSession;
 import org.apache.syncope.common.lib.to.AttributableTO;
@@ -55,7 +56,6 @@ public class DateFieldPanel extends FieldPanel<Date> {
             @Override
             public Date getObject() {
                 Date date = null;
-
                 if (list != null && !list.isEmpty() && StringUtils.hasText(list.get(0).toString())) {
                     try {
                         // Parse string using datePattern
@@ -116,7 +116,7 @@ public class DateFieldPanel extends FieldPanel<Date> {
             @Override
             @SuppressWarnings("unchecked")
             public void setObject(final Date object) {
-                item.setModelObject(object != null ? fmt.format(object) : null);
+                item.setModelObject(Optional.ofNullable(object).map(fmt::format).orElse(null));
             }
         };
 
@@ -124,17 +124,17 @@ public class DateFieldPanel extends FieldPanel<Date> {
         return this;
     }
 
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    public FieldPanel<Date> setNewModel(final AttributableTO attributableTO, final String schema) {
-        field.setModel(new Model() {
+    @Override
+    public FieldPanel<Date> setNewModel(final AttributableTO attributable, final String schema) {
+        field.setModel(new Model<Date>() {
 
             private static final long serialVersionUID = -4214654722524358000L;
 
             @Override
-            public Serializable getObject() {
-                if (!attributableTO.getPlainAttr(schema).get().getValues().isEmpty()) {
+            public Date getObject() {
+                if (!attributable.getPlainAttr(schema).get().getValues().isEmpty()) {
                     try {
-                        return fmt.parse(attributableTO.getPlainAttr(schema).get().getValues().get(0));
+                        return fmt.parse(attributable.getPlainAttr(schema).get().getValues().get(0));
                     } catch (ParseException ex) {
                         LOG.error("While parsing date", ex);
                     }
@@ -143,13 +143,12 @@ public class DateFieldPanel extends FieldPanel<Date> {
             }
 
             @Override
-            public void setObject(final Serializable object) {
-                attributableTO.getPlainAttr(schema).get().getValues().clear();
+            public void setObject(final Date object) {
+                attributable.getPlainAttr(schema).get().getValues().clear();
                 if (object != null) {
-                    attributableTO.getPlainAttr(schema).get().getValues().add(fmt.format(object));
+                    attributable.getPlainAttr(schema).get().getValues().add(fmt.format(object));
                 }
             }
-
         });
 
         return this;
@@ -159,6 +158,6 @@ public class DateFieldPanel extends FieldPanel<Date> {
     public void renderHead(final IHeaderResponse response) {
         super.renderHead(response);
         response.render(JavaScriptHeaderItem.forReference(
-                new KendoCultureResourceReference(SyncopeConsoleSession.get().getLocale())));
+                new KendoCultureResourceReference(getLocale())));
     }
 }
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DBPasswordPullActions.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DBPasswordPullActions.java
index 7d76887..74fa96c 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DBPasswordPullActions.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DBPasswordPullActions.java
@@ -18,14 +18,12 @@
  */
 package org.apache.syncope.core.provisioning.java.pushpull;
 
-import java.util.Optional;
 import org.apache.syncope.common.lib.patch.AnyPatch;
 import org.apache.syncope.common.lib.patch.PasswordPatch;
 import org.apache.syncope.common.lib.patch.UserPatch;
 import org.apache.syncope.common.lib.to.EntityTO;
 import org.apache.syncope.common.lib.to.UserTO;
 import org.apache.syncope.common.lib.types.CipherAlgorithm;
-import org.apache.syncope.common.lib.types.ConnConfProperty;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
 import org.apache.syncope.core.persistence.api.entity.ConnInstance;
 import org.apache.syncope.core.persistence.api.entity.user.User;
@@ -47,16 +45,16 @@ import org.springframework.transaction.annotation.Transactional;
  */
 public class DBPasswordPullActions implements PullActions {
 
-    private static final Logger LOG = LoggerFactory.getLogger(DBPasswordPullActions.class);
+    protected static final Logger LOG = LoggerFactory.getLogger(DBPasswordPullActions.class);
 
-    private static final String CLEARTEXT = "CLEARTEXT";
+    protected static final String CLEARTEXT = "CLEARTEXT";
 
     @Autowired
-    private UserDAO userDAO;
+    protected UserDAO userDAO;
 
-    private String encodedPassword;
+    protected String encodedPassword;
 
-    private CipherAlgorithm cipher;
+    protected CipherAlgorithm cipher;
 
     @Transactional(readOnly = true)
     @Override
@@ -85,7 +83,7 @@ public class DBPasswordPullActions implements PullActions {
         }
     }
 
-    private void parseEncodedPassword(final String password, final Connector connector) {
+    protected void parseEncodedPassword(final String password, final Connector connector) {
         if (password != null) {
             ConnInstance connInstance = connector.getConnInstance();
 
@@ -102,14 +100,12 @@ public class DBPasswordPullActions implements PullActions {
         }
     }
 
-    private String getCipherAlgorithm(final ConnInstance connInstance) {
-        Optional<ConnConfProperty> cipherAlgorithm = connInstance.getConf().stream().
+    protected String getCipherAlgorithm(final ConnInstance connInstance) {
+        return connInstance.getConf().stream().
                 filter(property -> "cipherAlgorithm".equals(property.getSchema().getName())
-                && property.getValues() != null && !property.getValues().isEmpty()).findFirst();
-
-        return cipherAlgorithm.isPresent()
-                ? (String) cipherAlgorithm.get().getValues().get(0)
-                : CLEARTEXT;
+                && property.getValues() != null && !property.getValues().isEmpty()).findFirst().
+                map(cipherAlgorithm -> cipherAlgorithm.getValues().get(0).toString()).
+                orElse(CLEARTEXT);
     }
 
     @Transactional
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/LDAPPasswordPullActions.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/LDAPPasswordPullActions.java
index 7a5f286..ea49d83 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/LDAPPasswordPullActions.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/LDAPPasswordPullActions.java
@@ -47,11 +47,11 @@ public class LDAPPasswordPullActions implements PullActions {
     protected static final Logger LOG = LoggerFactory.getLogger(LDAPPasswordPullActions.class);
 
     @Autowired
-    private UserDAO userDAO;
+    protected UserDAO userDAO;
 
-    private String encodedPassword;
+    protected String encodedPassword;
 
-    private CipherAlgorithm cipher;
+    protected CipherAlgorithm cipher;
 
     @Transactional(readOnly = true)
     @Override
@@ -80,7 +80,7 @@ public class LDAPPasswordPullActions implements PullActions {
         }
     }
 
-    private void parseEncodedPassword(final String password) {
+    protected void parseEncodedPassword(final String password) {
         if (password != null && password.startsWith("{")) {
             int closingBracketIndex = password.indexOf('}');
             String digest = password.substring(1, password.indexOf('}'));


[syncope] 02/02: Upgrading Mockito

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 091781e21a22f63a8f8c4ec1d327261cdc467d81
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Wed Nov 25 15:35:32 2020 +0100

    Upgrading Mockito
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 7b0f8b3..300fa7b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -450,7 +450,7 @@ under the License.
     <h2.version>1.4.200</h2.version>
 
     <junit.version>5.7.0</junit.version>
-    <mockito.version>3.6.0</mockito.version>
+    <mockito.version>3.6.28</mockito.version>
 
     <conf.directory>${project.build.directory}/test-classes</conf.directory>
     <bundles.directory>${project.build.directory}/bundles</bundles.directory>