// Path: server/src/main/java/com/cloudwise/sap/niping/common/vo/User.java
// @Data
// @Builder
// @AllArgsConstructor
// public class User {
// 	protected String userId;
// 	protected String accountId;
// 	protected String name;
// 	protected String loginName;
// 	private String password;
// 	private String passwordSalt;
// }


import com.cloudwise.sap.niping.common.vo.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
import java.net.URI;
package com.cloudwise.sap.niping.filter;



@Provider
public class NiPingAuthFilter implements ContainerRequestFilter {

    private static final String attributeName = "niping";

    @Context
    private HttpServletRequest httpServletRequest;

    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {
        final HttpSession session = httpServletRequest.getSession(false);
        if (null == session || null == session.getAttribute(attributeName)) {
            requestContext.abortWith(Response.seeOther(URI.create("/")).build());
        }
    }

// Path: server/src/main/java/com/cloudwise/sap/niping/common/vo/User.java
// @Data
// @Builder
// @AllArgsConstructor
// public class User {
// 	protected String userId;
// 	protected String accountId;
// 	protected String name;
// 	protected String loginName;
// 	private String password;
// 	private String passwordSalt;
// }


// Path: server/src/main/java/com/cloudwise/sap/niping/filter/NiPingAuthFilter.java
import com.cloudwise.sap.niping.common.vo.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
import java.net.URI;

package com.cloudwise.sap.niping.filter;



@Provider
public class NiPingAuthFilter implements ContainerRequestFilter {

    private static final String attributeName = "niping";

    @Context
    private HttpServletRequest httpServletRequest;

    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {
        final HttpSession session = httpServletRequest.getSession(false);
        if (null == session || null == session.getAttribute(attributeName)) {
            requestContext.abortWith(Response.seeOther(URI.create("/")).build());
        }
    }

    public static void setSession(HttpSession session, User user) {