Commit 683dce59 by Tuomas Riihimäki

We need to add domain to logging in username because we no longer inject it in H…

…ostnameFilter to BortalLocalContextHolder
1 parent 91223aea
...@@ -23,13 +23,13 @@ import io.swagger.annotations.Api; ...@@ -23,13 +23,13 @@ import io.swagger.annotations.Api;
@RequestScoped @RequestScoped
@Path("/apiapp/v1") @Path("/apiapp/v1")
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({MediaType.APPLICATION_JSON})
@Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" }) @Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"})
@Api(value = "/apiapp/v1/", description = "Manage api application and keys") @Api(value = "/apiapp/v1/", description = "Manage api application and keys")
public class ApiAppRestViewV1 { public class ApiAppRestViewV1 {
private static final Logger logger = LoggerFactory.getLogger(ApiAppRestViewV1.class); private static final Logger logger = LoggerFactory.getLogger(ApiAppRestViewV1.class);
@Context @Context
private HttpServletRequest servletRequest; private HttpServletRequest servletRequest;
...@@ -49,8 +49,10 @@ public class ApiAppRestViewV1 { ...@@ -49,8 +49,10 @@ public class ApiAppRestViewV1 {
principal = null; principal = null;
} }
servletRequest.getSession(true); servletRequest.getSession(true);
servletRequest.login(username, password); String domain = servletRequest.getHeader("host");
servletRequest.login(username + "@" + domain, password);
ApiApplication app = apibean.findApplication(appKey); ApiApplication app = apibean.findApplication(appKey);
ApiApplicationInstance apiInstance = apibean.createApplicationInstance(app); ApiApplicationInstance apiInstance = apibean.createApplicationInstance(app);
ApiApplicationInstancePojo ret = new ApiApplicationInstancePojo(); ApiApplicationInstancePojo ret = new ApiApplicationInstancePojo();
...@@ -59,7 +61,7 @@ public class ApiAppRestViewV1 { ...@@ -59,7 +61,7 @@ public class ApiAppRestViewV1 {
ret.setEnabled(apiInstance.isEnabled()); ret.setEnabled(apiInstance.isEnabled());
ret.setSecret(apiInstance.getSecretKey()); ret.setSecret(apiInstance.getSecretKey());
return Response.ok(ret).build(); return Response.ok(ret).build();
} catch (ServletException e) { } catch (ServletException e) {
logger.warn("Error logging in while creating ApiApplication instance"); logger.warn("Error logging in while creating ApiApplication instance");
return Response.serverError().entity(e.getCause()).build(); return Response.serverError().entity(e.getCause()).build();
......
...@@ -60,8 +60,10 @@ public class EventInfoV1 { ...@@ -60,8 +60,10 @@ public class EventInfoV1 {
if (principal != null && principal.getName() != null) { if (principal != null && principal.getName() != null) {
servletRequest.logout(); servletRequest.logout();
} }
String domain = servletRequest.getHeader("host");
servletRequest.getSession(true); servletRequest.getSession(true);
servletRequest.login(username, password); servletRequest.login(username + "@"+domain, password);
} }
return Response.ok(PojoUtils.parseEvents(eventBean.findAllEventsForCurrentUser())).build(); return Response.ok(PojoUtils.parseEvents(eventBean.findAllEventsForCurrentUser())).build();
} catch (ServletException e) { } catch (ServletException e) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!