use of com.tremolosecurity.scalejs.token.data.ScaleTokenUser in project OpenUnison by TremoloSecurity.
the class ScaleToken method doFilter.
@Override
public void doFilter(HttpFilterRequest request, HttpFilterResponse response, HttpFilterChain chain) throws Exception {
Gson gson = new Gson();
request.getServletRequest().setAttribute("com.tremolosecurity.unison.proxy.noRedirectOnError", "com.tremolosecurity.unison.proxy.noRedirectOnError");
if (request.getRequestURI().endsWith("/token/config")) {
response.setContentType("application/json");
ScaleJSUtils.addCacheHeaders(response);
response.getWriter().println(gson.toJson(scaleConfig).trim());
} else if (request.getMethod().equalsIgnoreCase("GET") && request.getRequestURI().endsWith("/token/user")) {
AuthInfo userData = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL)).getAuthInfo();
ScaleTokenUser stu = new ScaleTokenUser();
Attribute displayNameAttribute = userData.getAttribs().get(this.scaleConfig.getDisplayNameAttribute());
if (displayNameAttribute != null) {
stu.setDisplayName(displayNameAttribute.getValues().get(0));
} else {
stu.setDisplayName("Unknown");
}
stu.setToken(this.tokenLoader.loadToken(userData, request.getSession()));
ScaleJSUtils.addCacheHeaders(response);
response.setContentType("application/json");
response.getWriter().println(gson.toJson(stu).trim());
}
}
Aggregations