Unneeded constants
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/03bf9c83 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/03bf9c83 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/03bf9c83 Branch: refs/heads/master Commit: 03bf9c83817656d953a7fc7308ae1bfb1d125708 Parents: aa8e9f1 Author: Francesco Chicchiriccò <ilgro...@apache.org> Authored: Fri Mar 10 15:17:10 2017 +0100 Committer: Francesco Chicchiriccò <ilgro...@apache.org> Committed: Fri Mar 10 15:17:20 2017 +0100 ---------------------------------------------------------------------- .../console/resources/FilesystemResource.java | 4 ++-- .../resources/WorkflowDefGETResource.java | 4 ++-- .../console/rest/NotificationRestClient.java | 7 +++---- .../client/console/rest/ReportRestClient.java | 6 +++--- .../client/console/rest/RoleRestClient.java | 6 +++--- .../markup/html/form/BinaryFieldPanel.java | 6 ++---- .../enduser/resources/AnyTypeClassResource.java | 4 ++-- .../enduser/resources/AnyTypeResource.java | 5 ++--- .../resources/ExternalResourceResource.java | 5 ++--- .../client/enduser/resources/GroupResource.java | 3 ++- .../client/enduser/resources/InfoResource.java | 4 ++-- .../client/enduser/resources/LoginResource.java | 5 +++-- .../client/enduser/resources/RealmResource.java | 4 ++-- .../enduser/resources/SchemaResource.java | 5 ++--- .../resources/SecurityQuestionResource.java | 4 ++-- .../resources/UserSelfChangePassword.java | 4 ++-- .../resources/UserSelfConfirmPasswordReset.java | 4 ++-- .../resources/UserSelfCreateResource.java | 4 ++-- .../resources/UserSelfPasswordReset.java | 4 ++-- .../enduser/resources/UserSelfReadResource.java | 4 ++-- .../resources/UserSelfUpdateResource.java | 18 ++++++++-------- .../syncope/common/lib/SyncopeConstants.java | 5 ----- .../apache/syncope/core/logic/ReportLogic.java | 10 ++++----- .../core/logic/report/ReportJobDelegate.java | 4 ++-- .../jpa/content/XMLContentExporter.java | 4 ++-- .../persistence/jpa/inner/PlainAttrTest.java | 4 ++-- .../cxf/service/MailTemplateServiceImpl.java | 4 ++-- .../cxf/service/ReportTemplateServiceImpl.java | 4 ++-- .../core/rest/cxf/service/RoleServiceImpl.java | 4 ++-- .../syncope/core/spring/security/Encryptor.java | 10 ++++----- .../provisioning/camel/SyncopeCamelContext.java | 4 ++-- .../org/apache/syncope/fit/cli/CLIITCase.java | 22 ++++++++++---------- .../syncope/fit/core/ConfigurationITCase.java | 4 ++-- .../syncope/fit/core/MailTemplateITCase.java | 12 +++++------ .../org/apache/syncope/fit/core/RESTITCase.java | 8 +++---- .../apache/syncope/fit/core/ReportITCase.java | 4 ++-- .../syncope/fit/core/ReportTemplateITCase.java | 12 +++++------ .../apache/syncope/fit/core/WorkflowITCase.java | 6 +++--- 38 files changed, 111 insertions(+), 120 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/console/src/main/java/org/apache/syncope/client/console/resources/FilesystemResource.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/resources/FilesystemResource.java b/client/console/src/main/java/org/apache/syncope/client/console/resources/FilesystemResource.java index 4259ff7..a05a5b5 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/resources/FilesystemResource.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/resources/FilesystemResource.java @@ -21,7 +21,7 @@ package org.apache.syncope.client.console.resources; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import org.apache.syncope.common.lib.SyncopeConstants; +import java.nio.charset.StandardCharsets; import org.apache.wicket.request.resource.AbstractResource; import org.apache.wicket.util.io.IOUtils; import org.slf4j.Logger; @@ -56,7 +56,7 @@ public class FilesystemResource extends AbstractResource { replace('/', File.separatorChar); LOG.debug("Request for {}", subPath); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new WriteCallback() { @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefGETResource.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefGETResource.java b/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefGETResource.java index 24a5d15..8735f4a 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefGETResource.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefGETResource.java @@ -19,9 +19,9 @@ package org.apache.syncope.client.console.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import javax.ws.rs.core.MediaType; import org.apache.syncope.client.console.rest.WorkflowRestClient; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.wicket.request.resource.AbstractResource; import org.apache.wicket.util.io.IOUtils; @@ -39,7 +39,7 @@ public class WorkflowDefGETResource extends AbstractResource { ResourceResponse response = new ResourceResponse(); response.disableCaching(); response.setContentType(MediaType.APPLICATION_JSON); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new WriteCallback() { @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/console/src/main/java/org/apache/syncope/client/console/rest/NotificationRestClient.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/NotificationRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/NotificationRestClient.java index fd99f32..3422545 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/rest/NotificationRestClient.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/NotificationRestClient.java @@ -19,10 +19,10 @@ package org.apache.syncope.client.console.rest; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.List; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.JobTO; import org.apache.syncope.common.lib.to.MailTemplateTO; import org.apache.syncope.common.lib.to.NotificationTO; @@ -88,8 +88,7 @@ public class NotificationRestClient extends BaseRestClient public String readTemplateFormat(final String key, final MailTemplateFormat format) { try { return IOUtils.toString(InputStream.class.cast( - getService(MailTemplateService.class).getFormat(key, format).getEntity()), - SyncopeConstants.DEFAULT_CHARSET); + getService(MailTemplateService.class).getFormat(key, format).getEntity()), StandardCharsets.UTF_8); } catch (Exception e) { LOG.error("Error retrieving mail template {} as {}", key, format, e); return StringUtils.EMPTY; @@ -99,6 +98,6 @@ public class NotificationRestClient extends BaseRestClient @Override public void updateTemplateFormat(final String key, final String content, final MailTemplateFormat format) { getService(MailTemplateService.class).setFormat( - key, format, IOUtils.toInputStream(content, SyncopeConstants.DEFAULT_CHARSET)); + key, format, IOUtils.toInputStream(content, StandardCharsets.UTF_8)); } } http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/console/src/main/java/org/apache/syncope/client/console/rest/ReportRestClient.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/ReportRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/ReportRestClient.java index 954b245..2eb3b00 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/rest/ReportRestClient.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/ReportRestClient.java @@ -19,13 +19,13 @@ package org.apache.syncope.client.console.rest; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.List; import javax.ws.rs.NotSupportedException; import javax.ws.rs.core.Response; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.BulkAction; import org.apache.syncope.common.lib.to.BulkActionResult; import org.apache.syncope.common.lib.to.ExecTO; @@ -134,7 +134,7 @@ public class ReportRestClient extends BaseRestClient try { return IOUtils.toString(InputStream.class.cast( getService(ReportTemplateService.class).getFormat(key, format).getEntity()), - SyncopeConstants.DEFAULT_CHARSET); + StandardCharsets.UTF_8); } catch (Exception e) { LOG.error("Error retrieving mail template {} as {}", key, format, e); return StringUtils.EMPTY; @@ -144,7 +144,7 @@ public class ReportRestClient extends BaseRestClient @Override public void updateTemplateFormat(final String key, final String content, final ReportTemplateFormat format) { getService(ReportTemplateService.class).setFormat( - key, format, IOUtils.toInputStream(content, SyncopeConstants.DEFAULT_CHARSET)); + key, format, IOUtils.toInputStream(content, StandardCharsets.UTF_8)); } public BulkActionResult bulkAction(final BulkAction action) { http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/console/src/main/java/org/apache/syncope/client/console/rest/RoleRestClient.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/RoleRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/RoleRestClient.java index 5b7c156..32404e1 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/rest/RoleRestClient.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/RoleRestClient.java @@ -19,12 +19,12 @@ package org.apache.syncope.client.console.rest; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.RoleTO; import org.apache.syncope.common.rest.api.service.RoleService; @@ -63,7 +63,7 @@ public class RoleRestClient extends BaseRestClient { try { return IOUtils.toString(InputStream.class.cast( getService(RoleService.class).getConsoleLayoutInfo(roleKey).getEntity()), - SyncopeConstants.DEFAULT_CHARSET); + StandardCharsets.UTF_8); } catch (Exception e) { LOG.error("Error retrieving console layout info for role {}", roleKey, e); return StringUtils.EMPTY; @@ -72,7 +72,7 @@ public class RoleRestClient extends BaseRestClient { public void setConsoleLayoutInfo(final String roleKey, final String content) { getService(RoleService.class).setConsoleLayoutInfo( - roleKey, IOUtils.toInputStream(content, SyncopeConstants.DEFAULT_CHARSET)); + roleKey, IOUtils.toInputStream(content, StandardCharsets.UTF_8)); } public void removeConsoleLayoutInfo(final String roleKey) { http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java index 6aeb435..cc34be5 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java @@ -26,6 +26,7 @@ import de.agilecoders.wicket.extensions.markup.html.bootstrap.form.fileinput.Fil import de.agilecoders.wicket.jquery.JQuery; import de.agilecoders.wicket.jquery.function.IFunction; import java.io.ByteArrayInputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -35,7 +36,6 @@ import org.apache.syncope.client.console.commons.HttpResourceStream; import org.apache.syncope.client.console.commons.Constants; import org.apache.syncope.client.console.commons.PreviewUtils; import org.apache.syncope.client.console.wicket.markup.html.form.preview.AbstractBinaryPreviewer; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.wicket.Component; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior; @@ -165,9 +165,7 @@ public class BinaryFieldPanel extends FieldPanel<String> { final FileUpload uploadedFile = fileUpload.getFileUpload(); if (uploadedFile != null) { final byte[] uploadedBytes = uploadedFile.getBytes(); - final String uploaded = new String( - Base64.encodeBase64(uploadedBytes), - SyncopeConstants.DEFAULT_CHARSET); + final String uploaded = new String(Base64.encodeBase64(uploadedBytes), StandardCharsets.UTF_8); field.setModelObject(uploaded); target.add(field); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeClassResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeClassResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeClassResource.java index b1a3cc3..406186c 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeClassResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeClassResource.java @@ -19,11 +19,11 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.AnyTypeClassTO; import org.apache.syncope.common.rest.api.service.AnyTypeClassService; import org.apache.wicket.request.resource.AbstractResource; @@ -56,7 +56,7 @@ public class AnyTypeClassResource extends AbstractBaseResource { final List<AnyTypeClassTO> anyTypeClassTOs = anyTypeClassService.list(); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new AbstractResource.WriteCallback() { @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeResource.java index 251cd55..6f07e18 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeResource.java @@ -19,10 +19,10 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.AnyTypeTO; import org.apache.syncope.common.rest.api.service.AnyTypeService; import org.apache.wicket.request.resource.AbstractResource; @@ -39,7 +39,6 @@ public class AnyTypeResource extends AbstractBaseResource { @Override protected ResourceResponse newResourceResponse(final Attributes attributes) { - LOG.debug("Get all available auxiliary classes"); ResourceResponse response = new ResourceResponse(); @@ -56,7 +55,7 @@ public class AnyTypeResource extends AbstractBaseResource { String kind = attributes.getParameters().get(0).toString(); final AnyTypeTO anyTypeTO = anyTypeService.read(kind); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new AbstractResource.WriteCallback() { http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/ExternalResourceResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/ExternalResourceResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/ExternalResourceResource.java index b0602c4..8eb46b8 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/ExternalResourceResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/ExternalResourceResource.java @@ -19,11 +19,11 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.ResourceTO; import org.apache.syncope.common.rest.api.service.ResourceService; import org.apache.wicket.request.resource.AbstractResource; @@ -41,7 +41,6 @@ public class ExternalResourceResource extends AbstractBaseResource { @Override protected AbstractResource.ResourceResponse newResourceResponse(final IResource.Attributes attributes) { - LOG.debug("Search all available resources"); AbstractResource.ResourceResponse response = new AbstractResource.ResourceResponse(); @@ -57,7 +56,7 @@ public class ExternalResourceResource extends AbstractBaseResource { final List<ResourceTO> resourceTOs = resourceService.list(); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new AbstractResource.WriteCallback() { @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/GroupResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/GroupResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/GroupResource.java index 150fa96..fc9f280 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/GroupResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/GroupResource.java @@ -19,6 +19,7 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; @@ -59,7 +60,7 @@ public class GroupResource extends AbstractBaseResource { final List<GroupTO> groupTOs = groupService.search(new AnyQuery.Builder().realm(realm). fiql(SyncopeClient.getGroupSearchConditionBuilder().isAssignable().query()). build()).getResult(); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new AbstractResource.WriteCallback() { @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/InfoResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/InfoResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/InfoResource.java index d6eab9a..9c397d6 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/InfoResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/InfoResource.java @@ -19,13 +19,13 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; import org.apache.syncope.client.enduser.SyncopeEnduserConstants; import org.apache.syncope.client.enduser.SyncopeEnduserSession; import org.apache.syncope.client.enduser.adapters.PlatformInfoAdapter; import org.apache.syncope.client.enduser.util.SaltGenerator; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.wicket.request.resource.IResource; import org.apache.wicket.util.cookies.CookieUtils; @@ -48,7 +48,7 @@ public class InfoResource extends AbstractBaseResource { sessionCookieUtils.save(SyncopeEnduserConstants.XSRF_COOKIE, SaltGenerator.generate( SyncopeEnduserSession.get().getId())); } - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new WriteCallback() { @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/LoginResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/LoginResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/LoginResource.java index a8483cc..8f50351 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/LoginResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/LoginResource.java @@ -19,13 +19,13 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; import org.apache.syncope.client.enduser.SyncopeEnduserApplication; import org.apache.syncope.client.enduser.model.Credentials; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.wicket.request.resource.AbstractResource; import org.apache.wicket.request.resource.IResource; import org.apache.wicket.util.io.IOUtils; @@ -61,8 +61,9 @@ public class LoginResource extends AbstractBaseResource { } else if (!SyncopeEnduserApplication.get().getAdminUser().equalsIgnoreCase(username) && SyncopeEnduserSession.get().authenticate(username, password)) { // user has been authenticated successfully - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new WriteCallback() { + @Override public void writeData(final Attributes attributes) throws IOException { attributes.getResponse().write(username); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/RealmResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/RealmResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/RealmResource.java index c87b653..421ce40 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/RealmResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/RealmResource.java @@ -19,11 +19,11 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.RealmTO; import org.apache.syncope.common.rest.api.service.RealmService; import org.apache.wicket.request.resource.AbstractResource; @@ -54,7 +54,7 @@ public class RealmResource extends AbstractBaseResource { final List<RealmTO> realmTOs = realmService.list(); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new AbstractResource.WriteCallback() { http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SchemaResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SchemaResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SchemaResource.java index c64e73d..94d7d1f 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SchemaResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SchemaResource.java @@ -19,6 +19,7 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -27,7 +28,6 @@ import org.apache.commons.collections4.IterableUtils; import org.apache.commons.collections4.Predicate; import org.apache.syncope.client.enduser.SyncopeEnduserSession; import org.apache.syncope.client.enduser.model.SchemaResponse; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.AbstractSchemaTO; import org.apache.syncope.common.lib.to.AnyTypeTO; import org.apache.syncope.common.lib.to.GroupTO; @@ -60,7 +60,6 @@ public class SchemaResource extends AbstractBaseResource { @Override protected AbstractResource.ResourceResponse newResourceResponse(final IResource.Attributes attributes) { - LOG.debug("Search all {} any type kind related schemas", AnyTypeKind.USER.name()); AbstractResource.ResourceResponse response = new AbstractResource.ResourceResponse(); @@ -126,7 +125,7 @@ public class SchemaResource extends AbstractBaseResource { } } - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new AbstractResource.WriteCallback() { http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SecurityQuestionResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SecurityQuestionResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SecurityQuestionResource.java index 452f337..db26cd3 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SecurityQuestionResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SecurityQuestionResource.java @@ -19,12 +19,12 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.SecurityQuestionTO; import org.apache.syncope.common.rest.api.service.SecurityQuestionService; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -83,7 +83,7 @@ public class SecurityQuestionResource extends AbstractBaseResource { } response.setContentType(MediaType.APPLICATION_JSON); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setStatusCode(Response.Status.OK.getStatusCode()); } catch (Exception e) { LOG.error("Error retrieving security questions", e); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfChangePassword.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfChangePassword.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfChangePassword.java index b4ed2a2..e75e36b 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfChangePassword.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfChangePassword.java @@ -19,11 +19,11 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.rest.api.service.UserSelfService; import org.apache.wicket.request.resource.AbstractResource; import org.apache.wicket.request.resource.IResource; @@ -59,7 +59,7 @@ public class UserSelfChangePassword extends AbstractBaseResource { final String responseMessage = new StringBuilder().append("Password changed correctly").toString(); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new WriteCallback() { http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfConfirmPasswordReset.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfConfirmPasswordReset.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfConfirmPasswordReset.java index da36e47..0bf3e30 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfConfirmPasswordReset.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfConfirmPasswordReset.java @@ -19,11 +19,11 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.rest.api.service.UserSelfService; import org.apache.wicket.request.resource.AbstractResource; import org.apache.wicket.request.resource.IResource; @@ -65,7 +65,7 @@ public class UserSelfConfirmPasswordReset extends AbstractBaseResource { final String responseMessage = new StringBuilder().append("Password changed correctly").toString(); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new WriteCallback() { @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfCreateResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfCreateResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfCreateResource.java index 4476989..fa9d672 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfCreateResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfCreateResource.java @@ -19,6 +19,7 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -32,7 +33,6 @@ import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.time.FastDateFormat; import org.apache.syncope.client.enduser.SyncopeEnduserConstants; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.common.lib.to.MembershipTO; import org.apache.syncope.common.lib.to.PlainSchemaTO; @@ -177,7 +177,7 @@ public class UserSelfCreateResource extends AbstractBaseResource { // adapt request and create user final Response res = userSelfService.create(userTO, true); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new WriteCallback() { http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfPasswordReset.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfPasswordReset.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfPasswordReset.java index a173672..00f935b 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfPasswordReset.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfPasswordReset.java @@ -19,13 +19,13 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import org.apache.commons.lang3.ArrayUtils; import org.apache.syncope.client.enduser.SyncopeEnduserConstants; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.rest.api.service.UserSelfService; import org.apache.wicket.request.resource.AbstractResource; import org.apache.wicket.request.resource.IResource; @@ -78,7 +78,7 @@ public class UserSelfPasswordReset extends AbstractBaseResource { final String responseMessage = new StringBuilder(). append("Password reset request sent for user ").append(usernameParam[0]).toString(); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new WriteCallback() { @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfReadResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfReadResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfReadResource.java index 411c720..dac8a3f 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfReadResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfReadResource.java @@ -19,6 +19,7 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -28,7 +29,6 @@ import javax.ws.rs.core.Response; import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.time.FastDateFormat; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.common.lib.to.MembershipTO; import org.apache.syncope.common.lib.to.PlainSchemaTO; @@ -94,7 +94,7 @@ public class UserSelfReadResource extends AbstractBaseResource { final String selfTOJson = MAPPER.writeValueAsString(userTO); response.setContentType(MediaType.APPLICATION_JSON); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new WriteCallback() { http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfUpdateResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfUpdateResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfUpdateResource.java index e144ead..30a89d0 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfUpdateResource.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfUpdateResource.java @@ -19,6 +19,7 @@ package org.apache.syncope.client.enduser.resources; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -32,7 +33,6 @@ import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.time.FastDateFormat; import org.apache.syncope.client.enduser.SyncopeEnduserConstants; import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.common.lib.to.MembershipTO; import org.apache.syncope.common.lib.to.PlainSchemaTO; @@ -167,12 +167,12 @@ public class UserSelfUpdateResource extends AbstractBaseResource { final String responseMessage = res.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL) ? new StringBuilder(). - append("User").append(userTO.getUsername()).append(" successfully updated").toString() + append("User").append(userTO.getUsername()).append(" successfully updated").toString() : new StringBuilder(). - append("ErrorMessage{{ ").append(res.getStatusInfo().getReasonPhrase()).append(" }}"). - toString(); + append("ErrorMessage{{ ").append(res.getStatusInfo().getReasonPhrase()).append(" }}"). + toString(); - response.setTextEncoding(SyncopeConstants.DEFAULT_ENCODING); + response.setTextEncoding(StandardCharsets.UTF_8.name()); response.setWriteCallback(new WriteCallback() { @Override @@ -187,10 +187,10 @@ public class UserSelfUpdateResource extends AbstractBaseResource { LOG.error("Error while updating user", e); response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder(). - append("ErrorMessage{{ "). - append(e.getMessage()). - append(" }}"). - toString()); + append("ErrorMessage{{ "). + append(e.getMessage()). + append(" }}"). + toString()); } return response; } http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/common/lib/src/main/java/org/apache/syncope/common/lib/SyncopeConstants.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/SyncopeConstants.java b/common/lib/src/main/java/org/apache/syncope/common/lib/SyncopeConstants.java index 5ab80d2..3c4e39b 100644 --- a/common/lib/src/main/java/org/apache/syncope/common/lib/SyncopeConstants.java +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/SyncopeConstants.java @@ -18,7 +18,6 @@ */ package org.apache.syncope.common.lib; -import java.nio.charset.Charset; import java.util.Collections; import java.util.Set; import java.util.regex.Pattern; @@ -53,10 +52,6 @@ public final class SyncopeConstants { public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ssZ"; - public static final String DEFAULT_ENCODING = "UTF-8"; - - public static final Charset DEFAULT_CHARSET = Charset.forName(DEFAULT_ENCODING); - public static final String ROOT_LOGGER = "ROOT"; public static final Pattern EMAIL_PATTERN = Pattern.compile( http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/core/logic/src/main/java/org/apache/syncope/core/logic/ReportLogic.java ---------------------------------------------------------------------- diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/ReportLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/ReportLogic.java index af8a29f..5a27343 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/ReportLogic.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ReportLogic.java @@ -21,6 +21,7 @@ package org.apache.syncope.core.logic; import java.io.ByteArrayInputStream; import java.io.OutputStream; import java.lang.reflect.Method; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -39,7 +40,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.Triple; import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.ExecTO; import org.apache.syncope.common.lib.to.ReportTO; import org.apache.syncope.common.lib.types.ClientExceptionType; @@ -235,7 +235,7 @@ public class ReportLogic extends AbstractExecutableLogic<ReportTO> { case HTML: XSLTTransformer xsl2html = new XSLTTransformer(new StreamSource( IOUtils.toInputStream(reportExec.getReport().getTemplate().getHTMLTemplate(), - SyncopeConstants.DEFAULT_CHARSET))); + StandardCharsets.UTF_8))); xsl2html.setParameters(parameters); pipeline.addComponent(xsl2html); pipeline.addComponent(XMLSerializer.createXHTMLSerializer()); @@ -244,7 +244,7 @@ public class ReportLogic extends AbstractExecutableLogic<ReportTO> { case PDF: XSLTTransformer xsl2pdf = new XSLTTransformer(new StreamSource( IOUtils.toInputStream(reportExec.getReport().getTemplate().getFOTemplate(), - SyncopeConstants.DEFAULT_CHARSET))); + StandardCharsets.UTF_8))); xsl2pdf.setParameters(parameters); pipeline.addComponent(xsl2pdf); pipeline.addComponent(new FopSerializer(MimeConstants.MIME_PDF)); @@ -253,7 +253,7 @@ public class ReportLogic extends AbstractExecutableLogic<ReportTO> { case RTF: XSLTTransformer xsl2rtf = new XSLTTransformer(new StreamSource( IOUtils.toInputStream(reportExec.getReport().getTemplate().getFOTemplate(), - SyncopeConstants.DEFAULT_CHARSET))); + StandardCharsets.UTF_8))); xsl2rtf.setParameters(parameters); pipeline.addComponent(xsl2rtf); pipeline.addComponent(new FopSerializer(MimeConstants.MIME_RTF)); @@ -262,7 +262,7 @@ public class ReportLogic extends AbstractExecutableLogic<ReportTO> { case CSV: XSLTTransformer xsl2csv = new XSLTTransformer(new StreamSource( IOUtils.toInputStream(reportExec.getReport().getTemplate().getCSVTemplate(), - SyncopeConstants.DEFAULT_CHARSET))); + StandardCharsets.UTF_8))); xsl2csv.setParameters(parameters); pipeline.addComponent(xsl2csv); pipeline.addComponent(new TextSerializer()); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/core/logic/src/main/java/org/apache/syncope/core/logic/report/ReportJobDelegate.java ---------------------------------------------------------------------- diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/report/ReportJobDelegate.java b/core/logic/src/main/java/org/apache/syncope/core/logic/report/ReportJobDelegate.java index a87c1de..6d41686 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/report/ReportJobDelegate.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/report/ReportJobDelegate.java @@ -20,6 +20,7 @@ package org.apache.syncope.core.logic.report; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.zip.Deflater; import java.util.zip.ZipEntry; @@ -30,7 +31,6 @@ import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamResult; import org.apache.commons.io.IOUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.report.ReportletConf; import org.apache.syncope.common.lib.types.ReportExecStatus; import org.apache.syncope.core.provisioning.api.utils.ExceptionUtils2; @@ -107,7 +107,7 @@ public class ReportJobDelegate { tFactory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); handler = tFactory.newTransformerHandler(); Transformer serializer = handler.getTransformer(); - serializer.setOutputProperty(OutputKeys.ENCODING, SyncopeConstants.DEFAULT_ENCODING); + serializer.setOutputProperty(OutputKeys.ENCODING, StandardCharsets.UTF_8.name()); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); // a single ZipEntry in the ZipOutputStream http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java index 7618e1b..6c7ce53 100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java @@ -21,6 +21,7 @@ package org.apache.syncope.core.persistence.jpa.content; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.sql.Blob; import java.sql.Connection; import java.sql.DatabaseMetaData; @@ -51,7 +52,6 @@ import org.apache.commons.collections4.IterableUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.core.provisioning.api.utils.FormatUtils; import org.apache.syncope.core.spring.ApplicationContextProvider; import org.apache.syncope.core.persistence.api.content.ContentExporter; @@ -340,7 +340,7 @@ public class XMLContentExporter extends AbstractContentDealer implements Content TransformerHandler handler = transformerFactory.newTransformerHandler(); Transformer serializer = handler.getTransformer(); - serializer.setOutputProperty(OutputKeys.ENCODING, SyncopeConstants.DEFAULT_ENCODING); + serializer.setOutputProperty(OutputKeys.ENCODING, StandardCharsets.UTF_8.name()); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); handler.setResult(streamResult); handler.startDocument(); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainAttrTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainAttrTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainAttrTest.java index 2b7f441..3eda5ed 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainAttrTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainAttrTest.java @@ -25,10 +25,10 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Random; import javax.validation.ValidationException; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.types.AnyTypeKind; import org.apache.syncope.common.lib.types.EntityViolationType; import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException; @@ -207,7 +207,7 @@ public class PlainAttrTest extends AbstractTest { byte[] bytes = new byte[20]; new Random().nextBytes(bytes); - String photoB64Value = new String(Base64.encode(bytes), SyncopeConstants.DEFAULT_CHARSET); + String photoB64Value = new String(Base64.encode(bytes), StandardCharsets.UTF_8); UPlainAttr attr = entityFactory.newEntity(UPlainAttr.class); attr.setOwner(user); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java ---------------------------------------------------------------------- diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java index 8a6ede5..6ea590a 100644 --- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java +++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MailTemplateServiceImpl.java @@ -22,12 +22,12 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.ws.rs.InternalServerErrorException; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; import org.apache.commons.io.IOUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.MailTemplateTO; import org.apache.syncope.common.lib.types.MailTemplateFormat; import org.apache.syncope.common.rest.api.RESTHeaders; @@ -84,7 +84,7 @@ public class MailTemplateServiceImpl extends AbstractServiceImpl implements Mail @Override public void setFormat(final String key, final MailTemplateFormat format, final InputStream templateIn) { try { - logic.setFormat(key, format, IOUtils.toString(templateIn, SyncopeConstants.DEFAULT_CHARSET)); + logic.setFormat(key, format, IOUtils.toString(templateIn, StandardCharsets.UTF_8)); } catch (final IOException e) { LOG.error("While setting format {} for mail template {}", format, key, e); throw new InternalServerErrorException("Could not read entity", e); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportTemplateServiceImpl.java ---------------------------------------------------------------------- diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportTemplateServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportTemplateServiceImpl.java index 4a1b504..d63f5f6 100644 --- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportTemplateServiceImpl.java +++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ReportTemplateServiceImpl.java @@ -22,13 +22,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.ws.rs.InternalServerErrorException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; import org.apache.commons.io.IOUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.ReportTemplateTO; import org.apache.syncope.common.lib.types.ReportTemplateFormat; import org.apache.syncope.common.rest.api.RESTHeaders; @@ -85,7 +85,7 @@ public class ReportTemplateServiceImpl extends AbstractServiceImpl implements Re @Override public void setFormat(final String key, final ReportTemplateFormat format, final InputStream templateIn) { try { - logic.setFormat(key, format, IOUtils.toString(templateIn, SyncopeConstants.DEFAULT_CHARSET)); + logic.setFormat(key, format, IOUtils.toString(templateIn, StandardCharsets.UTF_8.name())); } catch (final IOException e) { LOG.error("While setting format {} for report template {}", format, key, e); throw new InternalServerErrorException("Could not read entity", e); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java ---------------------------------------------------------------------- diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java index 5e47078..a6a3f2e 100644 --- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java +++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java @@ -22,13 +22,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.ws.rs.InternalServerErrorException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; import org.apache.commons.io.IOUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.RoleTO; import org.apache.syncope.common.rest.api.RESTHeaders; import org.apache.syncope.common.rest.api.service.RoleService; @@ -89,7 +89,7 @@ public class RoleServiceImpl extends AbstractServiceImpl implements RoleService @Override public void setConsoleLayoutInfo(final String key, final InputStream consoleLayoutIn) { try { - logic.setConsoleLayoutInfo(key, IOUtils.toString(consoleLayoutIn, SyncopeConstants.DEFAULT_CHARSET)); + logic.setConsoleLayoutInfo(key, IOUtils.toString(consoleLayoutIn, StandardCharsets.UTF_8.name())); } catch (final IOException e) { LOG.error("While setting console layout info for role {}", key, e); throw new InternalServerErrorException("Could not read entity", e); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/core/spring/src/main/java/org/apache/syncope/core/spring/security/Encryptor.java ---------------------------------------------------------------------- diff --git a/core/spring/src/main/java/org/apache/syncope/core/spring/security/Encryptor.java b/core/spring/src/main/java/org/apache/syncope/core/spring/security/Encryptor.java index a1e8a9e..af64177 100644 --- a/core/spring/src/main/java/org/apache/syncope/core/spring/security/Encryptor.java +++ b/core/spring/src/main/java/org/apache/syncope/core/spring/security/Encryptor.java @@ -20,6 +20,7 @@ package org.apache.syncope.core.spring.security; import java.io.InputStream; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.Map; @@ -33,7 +34,6 @@ import javax.crypto.spec.SecretKeySpec; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.types.CipherAlgorithm; import org.jasypt.commons.CommonUtils; import org.jasypt.digest.StandardStringDigester; @@ -163,7 +163,7 @@ public final class Encryptor { try { keySpec = new SecretKeySpec(ArrayUtils.subarray( - actualKey.getBytes(SyncopeConstants.DEFAULT_CHARSET), 0, 16), + actualKey.getBytes(StandardCharsets.UTF_8), 0, 16), CipherAlgorithm.AES.getAlgorithm()); } catch (Exception e) { LOG.error("Error during key specification", e); @@ -178,7 +178,7 @@ public final class Encryptor { if (value != null) { if (cipherAlgorithm == null || cipherAlgorithm == CipherAlgorithm.AES) { - final byte[] cleartext = value.getBytes(SyncopeConstants.DEFAULT_CHARSET); + final byte[] cleartext = value.getBytes(StandardCharsets.UTF_8); final Cipher cipher = Cipher.getInstance(CipherAlgorithm.AES.getAlgorithm()); cipher.init(Cipher.ENCRYPT_MODE, keySpec); @@ -221,12 +221,12 @@ public final class Encryptor { String value = null; if (encodedValue != null && cipherAlgorithm == CipherAlgorithm.AES) { - final byte[] encoded = encodedValue.getBytes(SyncopeConstants.DEFAULT_CHARSET); + final byte[] encoded = encodedValue.getBytes(StandardCharsets.UTF_8); final Cipher cipher = Cipher.getInstance(CipherAlgorithm.AES.getAlgorithm()); cipher.init(Cipher.DECRYPT_MODE, keySpec); - value = new String(cipher.doFinal(Base64.decode(encoded)), SyncopeConstants.DEFAULT_CHARSET); + value = new String(cipher.doFinal(Base64.decode(encoded)), StandardCharsets.UTF_8); } return value; http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java index 99871cb..ca09718 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java @@ -19,6 +19,7 @@ package org.apache.syncope.core.provisioning.camel; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -32,7 +33,6 @@ import org.apache.camel.spring.SpringCamelContext; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Transformer; import org.apache.commons.io.IOUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.core.spring.ApplicationContextProvider; import org.apache.syncope.core.persistence.api.dao.CamelRouteDAO; import org.apache.syncope.core.persistence.api.entity.CamelRoute; @@ -101,7 +101,7 @@ public class SyncopeCamelContext { for (String route : routes) { InputStream input = null; try { - input = IOUtils.toInputStream(route, SyncopeConstants.DEFAULT_CHARSET); + input = IOUtils.toInputStream(route, StandardCharsets.UTF_8); LSInput lsinput = domImpl.createLSInput(); lsinput.setByteStream(input); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java index d139820..4f19f5a 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/cli/CLIITCase.java @@ -25,6 +25,7 @@ import static org.junit.Assert.fail; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -43,7 +44,6 @@ import org.apache.syncope.client.cli.commands.policy.PolicyCommand; import org.apache.syncope.client.cli.commands.report.ReportCommand; import org.apache.syncope.client.cli.commands.role.RoleCommand; import org.apache.syncope.client.cli.commands.user.UserCommand; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.fit.AbstractITCase; import org.junit.BeforeClass; import org.junit.Test; @@ -108,7 +108,7 @@ public class CLIITCase extends AbstractITCase { PROCESS_BUILDER.command(getCommand()); process = PROCESS_BUILDER.start(); - String result = IOUtils.toString(process.getInputStream(), SyncopeConstants.DEFAULT_CHARSET). + String result = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8). replaceAll("(?m)^\\s*$[\n\r]{1,}", ""); assertTrue(result.startsWith("Usage: Main [options]")); assertTrue(result.contains( @@ -138,7 +138,7 @@ public class CLIITCase extends AbstractITCase { process = PROCESS_BUILDER.start(); long entitlements = IterableUtils.countMatches( - IOUtils.readLines(process.getInputStream(), SyncopeConstants.DEFAULT_CHARSET), + IOUtils.readLines(process.getInputStream(), StandardCharsets.UTF_8), new Predicate<String>() { @Override @@ -166,7 +166,7 @@ public class CLIITCase extends AbstractITCase { process = PROCESS_BUILDER.start(); long bundles = IterableUtils.countMatches( - IOUtils.readLines(process.getInputStream(), SyncopeConstants.DEFAULT_CHARSET), + IOUtils.readLines(process.getInputStream(), StandardCharsets.UTF_8), new Predicate<String>() { @Override @@ -200,7 +200,7 @@ public class CLIITCase extends AbstractITCase { UserCommand.UserOptions.READ_BY_KEY.getOptionName(), String.valueOf(userKey1))); process1 = PROCESS_BUILDER.start(); - String result = IOUtils.toString(process1.getInputStream(), SyncopeConstants.DEFAULT_CHARSET); + String result = IOUtils.toString(process1.getInputStream(), StandardCharsets.UTF_8); assertTrue(result.contains("username: " + userService.read(userKey1).getUsername())); PROCESS_BUILDER.command(getCommand( @@ -210,7 +210,7 @@ public class CLIITCase extends AbstractITCase { String.valueOf(userKey3), String.valueOf(userKey4), String.valueOf(userKey5))); process2 = PROCESS_BUILDER.start(); long users = IterableUtils.countMatches( - IOUtils.readLines(process2.getInputStream(), SyncopeConstants.DEFAULT_CHARSET), + IOUtils.readLines(process2.getInputStream(), StandardCharsets.UTF_8), new Predicate<String>() { @Override @@ -226,7 +226,7 @@ public class CLIITCase extends AbstractITCase { String.valueOf(userKey1), String.valueOf(userKey2), String.valueOf(userKey3), String.valueOf(userKey4), String.valueOf(userKey5))); process3 = PROCESS_BUILDER.start(); - String result3 = IOUtils.toString(process3.getInputStream(), SyncopeConstants.DEFAULT_CHARSET); + String result3 = IOUtils.toString(process3.getInputStream(), StandardCharsets.UTF_8); assertTrue( result3.contains("username: " + userService.read(userKey1).getUsername()) && result3.contains("username: " + userService.read(userKey2).getUsername()) @@ -258,7 +258,7 @@ public class CLIITCase extends AbstractITCase { RoleCommand.RoleOptions.READ.getOptionName(), roleId)); process = PROCESS_BUILDER.start(); - final String result = IOUtils.toString(process.getInputStream(), SyncopeConstants.DEFAULT_CHARSET); + final String result = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8); assertTrue(result.contains(roleService.read(roleId).getEntitlements().iterator().next())); } catch (IOException e) { fail(e.getMessage()); @@ -278,7 +278,7 @@ public class CLIITCase extends AbstractITCase { ReportCommand.ReportOptions.READ.getOptionName(), "72")); process = PROCESS_BUILDER.start(); - final String result = IOUtils.toString(process.getInputStream(), SyncopeConstants.DEFAULT_CHARSET); + final String result = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8); assertTrue(result.contains("- Report 72 doesn't exist")); } catch (IOException e) { fail(e.getMessage()); @@ -298,7 +298,7 @@ public class CLIITCase extends AbstractITCase { PolicyCommand.PolicyOptions.READ.getOptionName(), "wrong")); process = PROCESS_BUILDER.start(); - final String result = IOUtils.toString(process.getInputStream(), SyncopeConstants.DEFAULT_CHARSET); + final String result = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8); assertTrue(result.contains("- Policy wrong doesn't exist")); } catch (IOException e) { fail(e.getMessage()); @@ -318,7 +318,7 @@ public class CLIITCase extends AbstractITCase { LoggerCommand.LoggerOptions.LAST_STATEMENTS.getOptionName(), "connid")); process = PROCESS_BUILDER.start(); - final String result = IOUtils.toString(process.getInputStream(), SyncopeConstants.DEFAULT_CHARSET); + final String result = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8); assertTrue(result.contains("\"level\" : \"DEBUG\",")); } catch (IOException e) { fail(e.getMessage()); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConfigurationITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConfigurationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConfigurationITCase.java index d2d9b64..dabbc4c 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConfigurationITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ConfigurationITCase.java @@ -28,13 +28,13 @@ import static org.junit.Assert.fail; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.apache.commons.io.IOUtils; import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.common.lib.to.PlainSchemaTO; import org.apache.syncope.common.lib.types.AttrSchemaType; @@ -147,7 +147,7 @@ public class ConfigurationITCase extends AbstractITCase { Object entity = response.getEntity(); assertTrue(entity instanceof InputStream); - String configExport = IOUtils.toString((InputStream) entity, SyncopeConstants.DEFAULT_ENCODING); + String configExport = IOUtils.toString((InputStream) entity, StandardCharsets.UTF_8.name()); assertFalse(configExport.isEmpty()); assertTrue(configExport.length() > 1000); } http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MailTemplateITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MailTemplateITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MailTemplateITCase.java index 4911382..b7c79a0 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MailTemplateITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/MailTemplateITCase.java @@ -26,12 +26,12 @@ import static org.junit.Assert.fail; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.apache.commons.io.IOUtils; import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.MailTemplateTO; import org.apache.syncope.common.lib.types.ClientExceptionType; import org.apache.syncope.common.lib.types.MailTemplateFormat; @@ -84,7 +84,7 @@ public class MailTemplateITCase extends AbstractITCase { // 3. set TEXT String textTemplate = "Hi there, I am ${username}."; mailTemplateService.setFormat( - key, MailTemplateFormat.TEXT, IOUtils.toInputStream(textTemplate, SyncopeConstants.DEFAULT_CHARSET)); + key, MailTemplateFormat.TEXT, IOUtils.toInputStream(textTemplate, StandardCharsets.UTF_8)); response = mailTemplateService.getFormat(key, MailTemplateFormat.TEXT); assertEquals(200, response.getStatus()); @@ -92,12 +92,12 @@ public class MailTemplateITCase extends AbstractITCase { assertTrue(response.getEntity() instanceof InputStream); assertEquals( textTemplate, - IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET)); + IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8)); // 3. set HTML String htmlTemplate = "<html><body>Hi there, I am ${username}.</body></html>"; mailTemplateService.setFormat( - key, MailTemplateFormat.HTML, IOUtils.toInputStream(htmlTemplate, SyncopeConstants.DEFAULT_CHARSET)); + key, MailTemplateFormat.HTML, IOUtils.toInputStream(htmlTemplate, StandardCharsets.UTF_8)); response = mailTemplateService.getFormat(key, MailTemplateFormat.HTML); assertEquals(200, response.getStatus()); @@ -105,7 +105,7 @@ public class MailTemplateITCase extends AbstractITCase { assertTrue(response.getEntity() instanceof InputStream); assertEquals( htmlTemplate, - IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET)); + IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8)); // 4. remove HTML mailTemplateService.removeFormat(key, MailTemplateFormat.HTML); @@ -123,7 +123,7 @@ public class MailTemplateITCase extends AbstractITCase { assertTrue(response.getEntity() instanceof InputStream); assertEquals( textTemplate, - IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET)); + IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8)); // 5. remove mail template mailTemplateService.delete(key); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/fit/core-reference/src/test/java/org/apache/syncope/fit/core/RESTITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/RESTITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/RESTITCase.java index b98dc53..b9d605f 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/RESTITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/RESTITCase.java @@ -26,6 +26,7 @@ import static org.junit.Assert.fail; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.security.AccessControlException; import java.util.List; import javax.ws.rs.ForbiddenException; @@ -42,7 +43,6 @@ import org.apache.syncope.client.lib.BasicAuthenticationHandler; import org.apache.syncope.client.lib.SyncopeClient; import org.apache.syncope.client.lib.SyncopeClientFactoryBean; import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.patch.GroupPatch; import org.apache.syncope.common.lib.patch.StringReplacePatchItem; import org.apache.syncope.common.lib.patch.UserPatch; @@ -100,7 +100,7 @@ public class RESTITCase extends AbstractITCase { assertEquals(Preference.RETURN_NO_CONTENT.toString(), response.getHeaderString(RESTHeaders.PREFERENCE_APPLIED)); assertEquals( StringUtils.EMPTY, - IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET)); + IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8)); group = getObject(response.getLocation(), GroupService.class, GroupTO.class); assertNotNull(group); @@ -114,14 +114,14 @@ public class RESTITCase extends AbstractITCase { assertEquals(Preference.RETURN_NO_CONTENT.toString(), response.getHeaderString(RESTHeaders.PREFERENCE_APPLIED)); assertEquals( StringUtils.EMPTY, - IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET)); + IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8)); response = noContentService.delete(group.getKey()); assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); assertEquals(Preference.RETURN_NO_CONTENT.toString(), response.getHeaderString(RESTHeaders.PREFERENCE_APPLIED)); assertEquals( StringUtils.EMPTY, - IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET)); + IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8)); } @Test http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportITCase.java index 57ba47e..1851e6d 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportITCase.java @@ -26,6 +26,7 @@ import static org.junit.Assert.fail; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.List; import java.util.Set; @@ -33,7 +34,6 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; import org.apache.commons.io.IOUtils; import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.report.AuditReportletConf; import org.apache.syncope.common.lib.report.UserReportletConf; import org.apache.syncope.common.lib.to.BulkActionResult; @@ -185,7 +185,7 @@ public class ReportITCase extends AbstractITCase { Object entity = response.getEntity(); assertTrue(entity instanceof InputStream); - assertFalse(IOUtils.toString((InputStream) entity, SyncopeConstants.DEFAULT_ENCODING).isEmpty()); + assertFalse(IOUtils.toString((InputStream) entity, StandardCharsets.UTF_8.name()).isEmpty()); } @Test http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportTemplateITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportTemplateITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportTemplateITCase.java index f640c43..c0882ee 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportTemplateITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportTemplateITCase.java @@ -26,12 +26,12 @@ import static org.junit.Assert.fail; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.apache.commons.io.IOUtils; import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.to.ReportTemplateTO; import org.apache.syncope.common.lib.types.ClientExceptionType; import org.apache.syncope.common.lib.types.ReportTemplateFormat; @@ -85,7 +85,7 @@ public class ReportTemplateITCase extends AbstractITCase { String csvTemplate = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'></xsl:stylesheet>"; reportTemplateService.setFormat( - key, ReportTemplateFormat.CSV, IOUtils.toInputStream(csvTemplate, SyncopeConstants.DEFAULT_CHARSET)); + key, ReportTemplateFormat.CSV, IOUtils.toInputStream(csvTemplate, StandardCharsets.UTF_8)); response = reportTemplateService.getFormat(key, ReportTemplateFormat.CSV); assertEquals(200, response.getStatus()); @@ -93,13 +93,13 @@ public class ReportTemplateITCase extends AbstractITCase { assertTrue(response.getEntity() instanceof InputStream); assertEquals( csvTemplate, - IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET)); + IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8)); // 3. set HTML String htmlTemplate = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'></xsl:stylesheet>"; reportTemplateService.setFormat( - key, ReportTemplateFormat.HTML, IOUtils.toInputStream(htmlTemplate, SyncopeConstants.DEFAULT_CHARSET)); + key, ReportTemplateFormat.HTML, IOUtils.toInputStream(htmlTemplate, StandardCharsets.UTF_8)); response = reportTemplateService.getFormat(key, ReportTemplateFormat.HTML); assertEquals(200, response.getStatus()); @@ -107,7 +107,7 @@ public class ReportTemplateITCase extends AbstractITCase { assertTrue(response.getEntity() instanceof InputStream); assertEquals( htmlTemplate, - IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET)); + IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8)); // 4. remove HTML reportTemplateService.removeFormat(key, ReportTemplateFormat.HTML); @@ -125,7 +125,7 @@ public class ReportTemplateITCase extends AbstractITCase { assertTrue(response.getEntity() instanceof InputStream); assertEquals( csvTemplate, - IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET)); + IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8)); // 5. remove report template reportTemplateService.delete(key); http://git-wip-us.apache.org/repos/asf/syncope/blob/03bf9c83/fit/core-reference/src/test/java/org/apache/syncope/fit/core/WorkflowITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/WorkflowITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/WorkflowITCase.java index db05c73..89f4190 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/WorkflowITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/WorkflowITCase.java @@ -26,9 +26,9 @@ import static org.junit.Assert.assertFalse; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import javax.ws.rs.core.Response; import org.apache.commons.io.IOUtils; -import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.types.AnyTypeKind; import org.apache.syncope.fit.AbstractITCase; import org.junit.Assume; @@ -41,7 +41,7 @@ public class WorkflowITCase extends AbstractITCase { assertTrue(response.getMediaType().toString(). startsWith(clientFactory.getContentType().getMediaType().toString())); assertTrue(response.getEntity() instanceof InputStream); - String definition = IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET); + String definition = IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8); assertNotNull(definition); assertFalse(definition.isEmpty()); } @@ -60,7 +60,7 @@ public class WorkflowITCase extends AbstractITCase { private void importDefinition(final AnyTypeKind type) throws IOException { Response response = workflowService.exportDefinition(type); - String definition = IOUtils.toString((InputStream) response.getEntity(), SyncopeConstants.DEFAULT_CHARSET); + String definition = IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8); workflowService.importDefinition(type, definition); }