Commit 37ccef3a authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

[CRV-323] added check for URL input fields

parent b28c7a58
......@@ -16,6 +16,8 @@
package org.apache.syncope.client.console.panels;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.syncope.client.console.rest.EnactmentEngineRestClient;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
......@@ -77,4 +79,8 @@ public abstract class AbstractEnactmentEngineModalPanel extends AbstractModalPan
form.add(urlInput);
}
protected void checkURL(final String s) throws MalformedURLException {
URL url = new URL(s);
}
}
......@@ -17,6 +17,7 @@ package org.apache.syncope.client.console.panels;
import eu.chorevolution.idm.common.to.EnactmentEngineTO;
import java.io.Serializable;
import java.net.MalformedURLException;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
......@@ -39,6 +40,7 @@ public class AddEnactmentEngineModalPanel extends AbstractEnactmentEngineModalPa
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
checkURL(urlInput.getModelObject());
EnactmentEngineTO enactmentEngineTO = new EnactmentEngineTO();
enactmentEngineTO.setName(nameInput.getModelObject());
enactmentEngineTO.setUsername(usernameInput.getModelObject());
......@@ -47,6 +49,8 @@ public class AddEnactmentEngineModalPanel extends AbstractEnactmentEngineModalPa
restClient.create(enactmentEngineTO);
modal.close(target);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (MalformedURLException e) {
SyncopeConsoleSession.get().error(getString("invalid_url"));
} catch (SyncopeClientException e) {
LOG.error("While creating new Enactment Engine", e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
......
......@@ -17,6 +17,7 @@ package org.apache.syncope.client.console.panels;
import eu.chorevolution.idm.common.to.EnactmentEngineTO;
import java.io.Serializable;
import java.net.MalformedURLException;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
......@@ -55,6 +56,7 @@ public class EditEnactmentEngineModalPanel extends AbstractEnactmentEngineModalP
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
checkURL(urlInput.getModelObject());
EnactmentEngineTO enactmentEngineTO = new EnactmentEngineTO();
enactmentEngineTO.setKey((enactmentEngine.getKey()));
enactmentEngineTO.setName(nameInput.getModelObject());
......@@ -64,6 +66,8 @@ public class EditEnactmentEngineModalPanel extends AbstractEnactmentEngineModalP
restClient.update(enactmentEngineTO);
modal.close(target);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (MalformedURLException e) {
SyncopeConsoleSession.get().error(getString("invalid_url"));
} catch (SyncopeClientException e) {
LOG.error("While creating new Enactment Engine", e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
......
......@@ -14,3 +14,4 @@
# limitations under the License.
#
header_title=Enactment Engines
invalid_url=Inserted URL is not valid
......@@ -14,3 +14,4 @@
# limitations under the License.
#
header_title=Enactment Engines
invalid_url=L'URL inserito non \u00e8 valido
......@@ -14,3 +14,4 @@
# limitations under the License.
#
header_title=Enactment Engines
invalid_url=O URL inserido \u00e9 inv\u00e1lido
......@@ -16,6 +16,8 @@
package org.apache.syncope.client.console.panels;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
import org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel;
......@@ -73,4 +75,8 @@ public abstract class AbstractSynthesisProcessorModalPanel extends AbstractModal
form.add(urlInput);
}
protected void checkURL(final String s) throws MalformedURLException {
URL url = new URL(s);
}
}
......@@ -17,6 +17,7 @@ package org.apache.syncope.client.console.panels;
import eu.chorevolution.idm.common.to.SynthesisProcessorTO;
import java.io.Serializable;
import java.net.MalformedURLException;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
......@@ -44,6 +45,7 @@ public class AddSynthesisProcessorModalPanel extends AbstractSynthesisProcessorM
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
checkURL(urlInput.getModelObject());
SynthesisProcessorTO synthesisProcessorTO = new SynthesisProcessorTO();
synthesisProcessorTO.setName(nameInput.getModelObject());
synthesisProcessorTO.setBaseUrl(urlInput.getModelObject());
......@@ -52,6 +54,8 @@ public class AddSynthesisProcessorModalPanel extends AbstractSynthesisProcessorM
restClient.create(synthesisProcessorTO);
modal.close(target);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (MalformedURLException e) {
SyncopeConsoleSession.get().error(getString("invalid_url"));
} catch (SyncopeClientException e) {
LOG.error("While creating new Synthesis Processor", e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
......
......@@ -17,6 +17,7 @@ package org.apache.syncope.client.console.panels;
import eu.chorevolution.idm.common.to.SynthesisProcessorTO;
import java.io.Serializable;
import java.net.MalformedURLException;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
......@@ -58,6 +59,7 @@ public class EditSynthesisProcessorModalPanel extends AbstractSynthesisProcessor
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
checkURL(urlInput.getModelObject());
SynthesisProcessorTO synthesisProcessorTO = new SynthesisProcessorTO();
synthesisProcessorTO.setKey((synthesisProcessor.getKey()));
synthesisProcessorTO.setName(nameInput.getModelObject());
......@@ -67,6 +69,8 @@ public class EditSynthesisProcessorModalPanel extends AbstractSynthesisProcessor
restClient.update(synthesisProcessorTO);
modal.close(target);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (MalformedURLException e) {
SyncopeConsoleSession.get().error(getString("invalid_url"));
} catch (SyncopeClientException e) {
LOG.error("While updating Synthesis Processor", e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
......
......@@ -14,3 +14,4 @@
# limitations under the License.
#
header_title=Synthesis Processors
invalid_url=Inserted URL is not valid
......@@ -14,3 +14,4 @@
# limitations under the License.
#
header_title=Synthesis Processors
invalid_url=L'URL inserito non \u00e8 valido
......@@ -14,3 +14,4 @@
# limitations under the License.
#
header_title=Synthesis Processors
invalid_url=O URL inserido \u00e9 inv\u00e1lido
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment