Commit f52814df authored by Daniel Gerhardt's avatar Daniel Gerhardt

Merge branch 'code-cleanup' into 'master'

Clean up code

See merge request !46
parents 51d58b66 bbb7288c
......@@ -47,7 +47,8 @@ public class CASLogoutSuccessHandler implements LogoutSuccessHandler {
final HttpServletResponse response,
final Authentication authentication
) throws IOException, ServletException {
String referer = request.getHeader("referer");
/* Typo in "referer" intended. It is in the spec. */
String referrer = request.getHeader("referer");
if (response.isCommitted()) {
LOGGER.info("Response has already been committed. Unable to redirect to target");
return;
......@@ -55,7 +56,7 @@ public class CASLogoutSuccessHandler implements LogoutSuccessHandler {
redirectStrategy.sendRedirect(
request,
response,
(casUrl + "/logout?url=") + (referer != null ? referer : defaultTarget)
(casUrl + "/logout?url=") + (referrer != null ? referrer : defaultTarget)
);
}
......
......@@ -36,7 +36,7 @@ public class CasUserDetailsService extends AbstractCasAssertionUserDetailsServic
@Override
protected UserDetails loadUserDetails(final Assertion assertion) {
final List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
final List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
grantedAuthorities.add(new SimpleGrantedAuthority("ROLE_USER"));
return new User(
......
......@@ -58,7 +58,7 @@ public class FeedbackStorage {
}
private final Map<Session, Map<User, FeedbackStorageObject>> data =
new ConcurrentHashMap<Session, Map<User, FeedbackStorageObject>>();
new ConcurrentHashMap<>();
public Feedback getFeedback(final Session session) {
int a = 0;
......@@ -116,7 +116,7 @@ public class FeedbackStorage {
@Transactional(isolation = Isolation.READ_COMMITTED)
public Map<Session, List<User>> cleanFeedbackVotes(final int cleanupFeedbackDelay) {
final Map<Session, List<User>> removedFeedbackOfUsersInSession = new HashMap<Session, List<User>>();
final Map<Session, List<User>> removedFeedbackOfUsersInSession = new HashMap<>();
for (final Session session : data.keySet()) {
if (!session.getFeatures().isLiveClicker()) {
List<User> affectedUsers = cleanFeedbackVotesInSession(session, cleanupFeedbackDelay);
......@@ -135,7 +135,7 @@ public class FeedbackStorage {
final boolean forceClean = cleanupFeedbackDelayInMins == 0;
final Map<User, FeedbackStorageObject> sessionFeedbacks = data.get(session);
final List<User> affectedUsers = new ArrayList<User>();
final List<User> affectedUsers = new ArrayList<>();
if (sessionFeedbacks != null) {
for (final Map.Entry<User, FeedbackStorageObject> entry : sessionFeedbacks.entrySet()) {
......
......@@ -31,7 +31,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
/**
......@@ -44,18 +43,18 @@ import java.net.URL;
public class ImageUtils {
// Or whatever size you want to read in at a time.
private static final int CHUNK_SIZE = 4096;
static final int CHUNK_SIZE = 4096;
/** Base64-Mimetype-Prefix start */
public static final String IMAGE_PREFIX_START = "data:image/";
static final String IMAGE_PREFIX_START = "data:image/";
/** Base64-Mimetype-Prefix middle part */
public static final String IMAGE_PREFIX_MIDDLE = ";base64,";
static final String IMAGE_PREFIX_MIDDLE = ";base64,";
/* default value is 200 pixel in width, set the value in the configuration file */
private static final int THUMB_WIDTH_DEFAULT = 200;
static final int THUMB_WIDTH_DEFAULT = 200;
/* default value is 200 pixel in height, set the value in the configuration file */
private static final int THUMB_HEIGHT_DEFAULT = 200;
static final int THUMB_HEIGHT_DEFAULT = 200;
public static final Logger LOGGER = LoggerFactory.getLogger(ImageUtils.class);
......@@ -74,7 +73,6 @@ public class ImageUtils {
public String encodeImageToString(final String imageUrl) {
final String[] urlParts = imageUrl.split("\\.");
final StringBuilder result = new StringBuilder();
// get format
//
......@@ -83,10 +81,7 @@ public class ImageUtils {
if (urlParts.length > 0) {
final String extension = urlParts[urlParts.length - 1];
result.append("data:image/" + extension + ";base64,");
result.append(Base64.encodeBase64String(convertFileToByteArray(imageUrl)));
return result.toString();
return "data:image/" + extension + ";base64," + Base64.encodeBase64String(convertFileToByteArray(imageUrl));
}
return null;
......@@ -98,7 +93,7 @@ public class ImageUtils {
* @param maybeImage The Image as a base64 encoded {@link String}
* @return true if the string is a potentially a base 64 encoded image.
*/
public boolean isBase64EncodedImage(String maybeImage) {
boolean isBase64EncodedImage(String maybeImage) {
return extractImageInfo(maybeImage) != null;
}
......@@ -113,7 +108,7 @@ public class ImageUtils {
* @return two-dimensional {@link String}-array containing the information
* "extension" and the "raw-image-{@link String}"
*/
public String[] extractImageInfo(final String maybeImage) {
String[] extractImageInfo(final String maybeImage) {
if (maybeImage == null) {
return null;
} else if (maybeImage.isEmpty()) {
......@@ -159,7 +154,7 @@ public class ImageUtils {
* @return The rescaled Image as Base64-encoded {@link String}, returns null
* if the passed-on image isn't in a valid format (a Base64-Image).
*/
public String createCover(String originalImageString, final int width, final int height) {
String createCover(String originalImageString, final int width, final int height) {
if (!isBase64EncodedImage(originalImageString)) {
return null;
} else {
......@@ -228,43 +223,13 @@ public class ImageUtils {
return false;
}
/**
* Gets the bytestream of an image url.
* s
* @param imageUrl The image url as a {@link String}
* @return The <code>byte[]</code> of the image on success, otherwise <code>null</code>.
*/
public byte[] convertImageToByteArray(final String imageUrl, final String extension) {
try {
final URL url = new URL(imageUrl);
final BufferedImage image = ImageIO.read(url);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, extension, baos);
baos.flush();
baos.close();
return baos.toByteArray();
} catch (final MalformedURLException e) {
LOGGER.error(e.getLocalizedMessage());
} catch (final IOException e) {
LOGGER.error(e.getLocalizedMessage());
}
return null;
}
/**
* Gets the bytestream of an image url.
*
* @param imageUrl The image url as a {@link String}
* @return The <code>byte[]</code> of the image on success, otherwise <code>null</code>.
*/
public byte[] convertFileToByteArray(final String imageUrl) {
byte[] convertFileToByteArray(final String imageUrl) {
try {
final URL url = new URL(imageUrl);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
......@@ -282,9 +247,7 @@ public class ImageUtils {
return baos.toByteArray();
} catch (final MalformedURLException e) {
LOGGER.error(e.getLocalizedMessage());
} catch (final IOException e) {
} catch (IOException e) {
LOGGER.error(e.getLocalizedMessage());
}
......
......@@ -44,9 +44,8 @@ public class LoginAuthenticationSucessHandler extends
if (session == null || session.getAttribute("ars-login-success-url") == null) {
return targetUrl;
}
String redirect = (String) session.getAttribute("ars-login-success-url");
return redirect;
return (String) session.getAttribute("ars-login-success-url");
}
public void setTargetUrl(final String url) {
......
......@@ -56,9 +56,6 @@ public class RangeAspect {
private static final Logger logger = LoggerFactory.getLogger(RangeAspect.class);
/** Sets start and end parameters based on request's range header and sets content range header for the response.
*
* @param controller
* @throws Throwable
*/
@Around("execution(java.util.List+ de.thm.arsnova.controller.*.*(..)) && this(controller) && @annotation(de.thm.arsnova.web.Pagination)")
public Object handlePaginationRange(ProceedingJoinPoint pjp, final PaginationController controller) throws Throwable {
......
......@@ -35,10 +35,6 @@ public class UserSessionAspect {
private UserSessionService userSessionService;
/** Sets current user and ARSnova session in session scoped UserSessionService
*
* @param jp
* @param keyword
* @param session
*/
@AfterReturning(
pointcut = "execution(public * de.thm.arsnova.services.SessionService.joinSession(..)) && args(keyword)",
......
......@@ -19,7 +19,6 @@ package de.thm.arsnova.cache;
import de.thm.arsnova.events.*;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
......
......@@ -18,11 +18,11 @@
package de.thm.arsnova.config;
import de.thm.arsnova.ImageUtils;
import de.thm.arsnova.web.CorsFilter;
import de.thm.arsnova.connector.client.ConnectorClient;
import de.thm.arsnova.connector.client.ConnectorClientImpl;
import de.thm.arsnova.socket.ARSnovaSocket;
import de.thm.arsnova.socket.ARSnovaSocketIOServer;
import de.thm.arsnova.web.CorsFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
......@@ -36,11 +36,9 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.Arrays;
/**
......@@ -70,10 +68,10 @@ public class ExtraConfig extends WebMvcConfigurerAdapter {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
final PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
configurer.setLocations(new Resource[] {
new ClassPathResource("arsnova.properties.example"),
new FileSystemResource("/etc/arsnova/arsnova.properties"),
});
configurer.setLocations(
new ClassPathResource("arsnova.properties.example"),
new FileSystemResource("/etc/arsnova/arsnova.properties")
);
configurer.setIgnoreResourceNotFound(true);
configurer.setIgnoreUnresolvablePlaceholders(false);
return configurer;
......
......@@ -41,7 +41,6 @@ import org.springframework.context.annotation.Profile;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.security.access.PermissionEvaluator;
import org.springframework.security.authentication.AuthenticationManager;
......@@ -140,7 +139,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements Serv
if (twitterEnabled) {
http.addFilterAfter(twitterFilter(), CasAuthenticationFilter.class);
}
};
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
......@@ -170,7 +169,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements Serv
auth.authenticationProvider(twitterAuthProvider());
}
logger.info("Enabled authentication providers: {}", providers);
};
}
@Bean
@Override
......@@ -181,10 +180,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements Serv
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
final PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
configurer.setLocations(new Resource[] {
new ClassPathResource("arsnova.properties.example"),
new FileSystemResource("file:///etc/arsnova/arsnova.properties"),
});
configurer.setLocations(
new ClassPathResource("arsnova.properties.example"),
new FileSystemResource("file:///etc/arsnova/arsnova.properties")
);
configurer.setIgnoreResourceNotFound(true);
configurer.setIgnoreUnresolvablePlaceholders(false);
......@@ -251,7 +250,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements Serv
// LDAP Authentication Configuration
@Bean
public LdapAuthenticationProvider ldapAuthenticationProvider() throws Exception {
public LdapAuthenticationProvider ldapAuthenticationProvider() {
LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProvider(ldapAuthenticator(), ldapAuthoritiesPopulator());
ldapAuthenticationProvider.setUserDetailsContextMapper(customLdapUserDetailsMapper());
......@@ -259,7 +258,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements Serv
}
@Bean
public LdapContextSource ldapContextSource() throws Exception {
public LdapContextSource ldapContextSource() {
DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(ldapUrl);
/* TODO: implement support for LDAP bind using manager credentials */
if (!"".equals(ldapManagerUserDn) && !"".equals(ldapManagerPassword)) {
......@@ -272,7 +271,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements Serv
}
@Bean
public LdapAuthenticator ldapAuthenticator() throws Exception {
public LdapAuthenticator ldapAuthenticator() {
BindAuthenticator authenticator = new BindAuthenticator(ldapContextSource());
authenticator.setUserAttributes(new String[] {ldapUserIdAttr});
if (!"".equals(ldapSearchFilter)) {
......@@ -287,7 +286,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements Serv
}
@Bean
public LdapAuthoritiesPopulator ldapAuthoritiesPopulator() throws Exception {
public LdapAuthoritiesPopulator ldapAuthoritiesPopulator() {
return new NullLdapAuthoritiesPopulator();
}
......
......@@ -162,10 +162,10 @@ public class ConfigurationController extends AbstractController {
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public HashMap<String, Object> getConfiguration(HttpServletRequest request) {
HashMap<String, Object> config = new HashMap<String, Object>();
HashMap<String, Boolean> features = new HashMap<String, Boolean>();
HashMap<String, String> publicPool = new HashMap<String, String>();
HashMap<String, Object> splashscreen = new HashMap<String, Object>();
HashMap<String, Object> config = new HashMap<>();
HashMap<String, Boolean> features = new HashMap<>();
HashMap<String, String> publicPool = new HashMap<>();
HashMap<String, Object> splashscreen = new HashMap<>();
/* The API path could be unknown to the client in case the request was forwarded */
if ("".equals(apiPath)) {
......@@ -268,7 +268,7 @@ public class ConfigurationController extends AbstractController {
}
if (!"".equals(trackingTrackerUrl)) {
HashMap<String, String> tracking = new HashMap<String, String>();
HashMap<String, String> tracking = new HashMap<>();
config.put("tracking", tracking);
tracking.put("provider", trackingProvider);
......
......@@ -69,7 +69,7 @@ public class CourseController extends AbstractController {
throw new NotImplementedException();
}
final List<Course> result = new ArrayList<Course>();
final List<Course> result = new ArrayList<>();
for (final Course course : connectorClient.getCourses(currentUser.getUsername()).getCourse()) {
if (
......
......@@ -234,19 +234,15 @@ public class LecturerQuestionController extends PaginationController {
@RequestParam(value = "lecturequestionsonly", defaultValue = "false", required = false) final boolean lectureQuestionsOnly,
@RequestParam(value = "preparationquestionsonly", defaultValue = "false", required = false) final boolean preparationQuestionsOnly
) {
boolean p = true;
boolean p = publish == null || publish;
List<Question> questions;
if (publish != null) {
p = publish;
}
if (lectureQuestionsOnly) {
questions = questionService.getLectureQuestions(sessionkey);
questionService.publishQuestions(sessionkey, publish, questions);
questionService.publishQuestions(sessionkey, p, questions);
} else if (preparationQuestionsOnly) {
questions = questionService.getPreparationQuestions(sessionkey);
questionService.publishQuestions(sessionkey, publish, questions);
questionService.publishQuestions(sessionkey, p, questions);
} else {
questionService.publishAll(sessionkey, p);
}
......@@ -309,7 +305,7 @@ public class LecturerQuestionController extends PaginationController {
questions = questionService.replaceImageData(questions);
}
return new PaginationListDecorator<Question>(questions, offset, limit);
return new PaginationListDecorator<>(questions, offset, limit);
}
@ApiOperation(value = "Delete skill questions",
......@@ -392,8 +388,6 @@ public class LecturerQuestionController extends PaginationController {
/**
* returns a JSON document which represents the given answer of a question.
*
* @param sessionKey
* Session Keyword to which the question belongs to
* @param questionId
* CouchDB Question ID for which the given answer should be
* retrieved
......@@ -428,12 +422,9 @@ public class LecturerQuestionController extends PaginationController {
* <tt>answerText</tt>, <tt>answerSubject</tt> and <tt>answerCount</tt>
* properties are set
*
* @param sessionKey
* Session Keyword to which the question belongs to
* @param questionId
* CouchDB Question ID for which the given answers should be
* retrieved
* @return List<{@link Answer}> or {@link NotFoundException}
* @throws NotFoundException
* if wrong session, wrong question or no answers was given
* @throws ForbiddenException
......@@ -448,7 +439,7 @@ public class LecturerQuestionController extends PaginationController {
@RequestParam(value = "all", required = false, defaultValue = "false") final Boolean allAnswers,
final HttpServletResponse response
) {
List<Answer> answers = null;
List<Answer> answers;
if (allAnswers) {
answers = questionService.getAllAnswers(questionId, -1, -1);
} else if (null == piRound) {
......@@ -462,7 +453,7 @@ public class LecturerQuestionController extends PaginationController {
answers = questionService.getAnswers(questionId, piRound, offset, limit);
}
if (answers == null) {
return new ArrayList<Answer>();
return new ArrayList<>();
}
return answers;
}
......@@ -543,8 +534,6 @@ public class LecturerQuestionController extends PaginationController {
/**
*
* @param sessionKey
* Session Keyword to which the question belongs to
* @param questionId
* CouchDB Question ID for which the given answers should be
* retrieved
......@@ -584,12 +573,10 @@ public class LecturerQuestionController extends PaginationController {
nickname = "getAnswerAndAbstentionCount")
@RequestMapping(value = "/{questionId}/answerandabstentioncount", method = RequestMethod.GET)
public List<Integer> getAnswerAndAbstentionCount(@PathVariable final String questionId) {
List<Integer> list = Arrays.asList(
return Arrays.asList(
questionService.getAnswerCount(questionId),
questionService.getAbstentionAnswerCount(questionId)
);
return list;
}
@ApiOperation(value = "Get all Freetext answers by a question, identified by the question ID",
......
......@@ -59,7 +59,6 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
......@@ -207,7 +206,7 @@ public class LoginController extends AbstractController {
response.setStatus(HttpStatus.UNAUTHORIZED.value());
}
} else if (guestEnabled && "guest".equals(type)) {
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
List<GrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority("ROLE_GUEST"));
if (username == null || !username.startsWith("Guest") || username.length() != MAX_USERNAME_LENGTH) {
username = "Guest" + Sha512DigestUtils.shaHex(request.getSession().getId()).substring(0, MAX_GUESTHASH_LENGTH);
......@@ -314,7 +313,7 @@ public class LoginController extends AbstractController {
@RequestMapping(value = { "/auth/services" }, method = RequestMethod.GET)
@ResponseBody
public List<ServiceDescription> getServices(final HttpServletRequest request) {
List<ServiceDescription> services = new ArrayList<ServiceDescription>();
List<ServiceDescription> services = new ArrayList<>();
if ("".equals(apiPath)) {
apiPath = request.getContextPath();
......@@ -417,7 +416,7 @@ public class LoginController extends AbstractController {
}
private Collection<GrantedAuthority> getAuthorities() {
List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
List<GrantedAuthority> authList = new ArrayList<>();
authList.add(new SimpleGrantedAuthority("ROLE_USER"));
return authList;
}
......
......@@ -38,7 +38,6 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -67,7 +66,7 @@ public class MotdController extends AbstractController {
@ApiParam(value = "audience", required = false) @RequestParam(value = "audience", defaultValue = "all") final String audience,
@ApiParam(value = "sessionkey", required = false) @RequestParam(value = "sessionkey", defaultValue = "null") final String sessionkey
) {
List<Motd> motds = new ArrayList<Motd>();
List<Motd> motds;
Date client = new Date(System.currentTimeMillis());
if (!clientdate.isEmpty()) {
client.setTime(Long.parseLong(clientdate));
......@@ -96,7 +95,7 @@ public class MotdController extends AbstractController {
final HttpServletResponse response
) {
if (motd != null) {
Motd newMotd = new Motd();
Motd newMotd;
if (motd.getAudience().equals("session") && motd.getSessionkey() != null) {
newMotd = motdService.saveSessionMotd(motd.getSessionkey(), motd);
} else {
......
......@@ -52,7 +52,7 @@ public class SecurityExceptionControllerAdvice {
final Exception e,
final HttpServletRequest req
) {
final Map<String, String> result = new HashMap<String, String>();
final Map<String, String> result = new HashMap<>();
result.put("code", "500");
result.put("status", "Internal server error");
result.put("message", e.getMessage());
......
......@@ -17,7 +17,6 @@
*/
package de.thm.arsnova.controller;
import org.springframework.context.annotation.Import;
import de.thm.arsnova.connector.model.Course;
import de.thm.arsnova.entities.Session;
import de.thm.arsnova.entities.SessionFeature;
......@@ -114,7 +113,7 @@ public class SessionController extends PaginationController {
@ResponseStatus(HttpStatus.CREATED)
public Session postNewSession(@ApiParam(value = "current session", required = true) @RequestBody final Session session, final HttpServletResponse response) {
if (session != null && session.isCourseSession()) {
final List<Course> courses = new ArrayList<Course>();
final List<Course> courses = new ArrayList<>();
final Course course = new Course();
course.setId(session.getCourseId());
courses.add(course);
......@@ -171,7 +170,7 @@ public class SessionController extends PaginationController {
"username", defaultValue = "") final String username,
final HttpServletResponse response
) {
List<Session> sessions = null;
List<Session> sessions;
if (!username.equals("")) {
try {
......@@ -218,9 +217,6 @@ public class SessionController extends PaginationController {
/**
* Returns a list of my own sessions with only the necessary information like name, keyword, or counters.
* @param statusOnly The flag that has to be set in order to get this shortened list.
* @param response
* @return
*/
@ApiOperation(value = "Retrieves a Session",
nickname = "getMySessions")
......@@ -310,7 +306,7 @@ public class SessionController extends PaginationController {
@ApiParam(value = "wether interposed questions shall be exported", required = true) @RequestParam(value = "withFeedbackQuestions", defaultValue = "false") final Boolean withFeedbackQuestions,
final HttpServletResponse response
) {
List<ImportExportSession> sessions = new ArrayList<ImportExportSession>();
List<ImportExportSession> sessions = new ArrayList<>();
ImportExportSession temp;
for (String key : sessionkey) {
sessionService.setActive(key, false);
......
......@@ -67,10 +67,10 @@ public class SocketController extends AbstractController {
@ApiResponse(code = 403, message = HTML_STATUS_403)
})
@RequestMapping(method = RequestMethod.POST, value = "/assign")
public void authorize(@ApiParam(value = "sessionMap", required = true) @RequestBody final Map < String, String> sessionMap, @ApiParam(value = "response", required = true) final HttpServletResponse response) {
public void authorize(@ApiParam(value = "sessionMap", required = true) @RequestBody final Map <String, String> sessionMap, @ApiParam(value = "response", required = true) final HttpServletResponse response) {
String socketid = sessionMap.get("session");
if (null == socketid) {
LOGGER.debug("Expected property 'session' missing", socketid);
LOGGER.debug("Expected property 'session' missing");
response.setStatus(HttpStatus.BAD_REQUEST.value());
return;
}
......@@ -89,12 +89,7 @@ public class SocketController extends AbstractController {
nickname = "getSocketUrl")
@RequestMapping(value = "/url", method = RequestMethod.GET)
public String getSocketUrl(final HttpServletRequest request) {
StringBuilder url = new StringBuilder();
url.append(server.isUseSSL() ? "https://" : "http://");
url.append(request.getServerName() + ":" + server.getPortNumber());
return url.toString();
return (server.isUseSSL() ? "https://" : "http://") + request.getServerName() + ":" + server.getPortNumber();
}
}
......@@ -23,7 +23,6 @@ import de.thm.arsnova.services.UserSessionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -52,7 +51,7 @@ public class UserController extends AbstractController {
public static final Logger LOGGER = LoggerFactory
.getLogger(UserController.class);
@RequestMapping(value = { "/register" }, method = RequestMethod.POST)
@RequestMapping(value = "/register", method = RequestMethod.POST)
public void register(@RequestParam final String username,
@RequestParam final String password,
final HttpServletRequest request, final HttpServletResponse response) {
......@@ -64,7 +63,7 @@ public class UserController extends AbstractController {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
@RequestMapping(value = { "/{username}/activate" }, method = { RequestMethod.POST,
@RequestMapping(value = "/{username}/activate", method = { RequestMethod.POST,
RequestMethod.GET })
public void activate(
@PathVariable final String username,
......@@ -81,7 +80,7 @@ public class UserController extends AbstractController {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
@RequestMapping(value = { "/{username}/" }, method = RequestMethod.DELETE)
@RequestMapping(value = "/{username}/", method = RequestMethod.DELETE)
public void activate(
@PathVariable final String username,
final HttpServletRequest request,
......@@ -91,7 +90,7 @@ public class UserController extends AbstractController {
}
}
@RequestMapping(value = { "/{username}/resetpassword" }, method = RequestMethod.POST)
@RequestMapping(value = "/{username}/resetpassword", method = RequestMethod.POST)
public void resetPassword(
@PathVariable final String username,
@RequestParam(required = false) final String key,
......
......@@ -81,7 +81,7 @@ public class WelcomeController extends AbstractController {
@RequestMapping(value = "/checkframeoptionsheader", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)