Fix sonar issue

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-08-05 15:55:49 +02:00
parent c71cf4852a
commit 5f20066cff
9 changed files with 121 additions and 67 deletions

View File

@@ -28,11 +28,6 @@ import org.springframework.security.core.context.SecurityContextImpl;
*/
public class SecurityContextTenantAware implements TenantAware {
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.tenancy.TenantAware#getCurrentTenantId()
*/
@Override
public String getCurrentTenant() {
final SecurityContext context = SecurityContextHolder.getContext();
@@ -56,7 +51,7 @@ public class SecurityContextTenantAware implements TenantAware {
}
}
private SecurityContext buildSecurityContext(final String tenant) {
private static SecurityContext buildSecurityContext(final String tenant) {
final SecurityContextImpl securityContext = new SecurityContextImpl();
securityContext.setAuthentication(
new AuthenticationDelegate(SecurityContextHolder.getContext().getAuthentication(), tenant));
@@ -68,7 +63,7 @@ public class SecurityContextTenantAware implements TenantAware {
* {@link Authentication} object except setting the details specifically for
* a specific tenant.
*/
private class AuthenticationDelegate implements Authentication {
private static final class AuthenticationDelegate implements Authentication {
private static final long serialVersionUID = 1L;
private final Authentication delegate;

View File

@@ -34,7 +34,7 @@ import com.google.common.base.Throwables;
@Service
public class SystemSecurityContext {
private static final Logger logger = LoggerFactory.getLogger(SystemSecurityContext.class);
private static final Logger LOG = LoggerFactory.getLogger(SystemSecurityContext.class);
private final TenantAware tenantAware;
@@ -96,7 +96,7 @@ public class SystemSecurityContext {
public <T> T runAsSystemAsTenant(final Callable<T> callable, final String tenant) {
final SecurityContext oldContext = SecurityContextHolder.getContext();
try {
logger.debug("entering system code execution");
LOG.debug("entering system code execution");
return tenantAware.runAsTenant(tenant, () -> {
try {
setSystemContext(SecurityContextHolder.getContext());
@@ -110,7 +110,7 @@ public class SystemSecurityContext {
} finally {
SecurityContextHolder.setContext(oldContext);
logger.debug("leaving system code execution");
LOG.debug("leaving system code execution");
}
}
@@ -136,7 +136,7 @@ public class SystemSecurityContext {
* {@link SpringEvalExpressions#SYSTEM_ROLE} which is allowed to execute all
* secured methods.
*/
public static class SystemCodeAuthentication implements Authentication {
public static final class SystemCodeAuthentication implements Authentication {
private static final long serialVersionUID = 1L;
private static final List<SimpleGrantedAuthority> AUTHORITIES = Collections