Search in sources :

Example 1 with NextSys

use of com.tremolosecurity.proxy.util.NextSys in project OpenUnison by TremoloSecurity.

the class AzFilter method doFilter.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    NextSys nextSys = new FilterNextSys(chain);
    azSys.doAz(request, response, nextSys);
}
Also used : FilterNextSys(com.tremolosecurity.proxy.util.FilterNextSys) NextSys(com.tremolosecurity.proxy.util.NextSys) FilterNextSys(com.tremolosecurity.proxy.util.FilterNextSys)

Example 2 with NextSys

use of com.tremolosecurity.proxy.util.NextSys in project OpenUnison by TremoloSecurity.

the class TokenData method completeFederation.

private void completeFederation(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, MalformedURLException {
    final OpenIDConnectTransaction transaction = (OpenIDConnectTransaction) request.getSession().getAttribute(OpenIDConnectIdP.TRANSACTION_DATA);
    final AuthInfo authInfo = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL)).getAuthInfo();
    if (!authInfo.isAuthComplete()) {
        logger.warn("Attempted completetd federation before autthentication is completeed, clearing authentication and redirecting to the original URL");
        UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG);
        request.getSession().removeAttribute(ProxyConstants.AUTH_CTL);
        holder.getConfig().createAnonUser(request.getSession());
        StringBuffer b = new StringBuffer();
        b.append(transaction.getRedirectURI()).append("?error=login_reset");
        response.sendRedirect(b.toString());
        return;
    }
    request.setAttribute(AzSys.FORCE, "true");
    NextSys completeFed = new NextSys() {

        public void nextSys(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
            UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG);
            HttpFilterRequest filterReq = new HttpFilterRequestImpl(request, null);
            HttpFilterResponse filterResp = new HttpFilterResponseImpl(response);
            PostProcess postProc = new PostProcess() {

                @Override
                public void postProcess(HttpFilterRequest req, HttpFilterResponse resp, UrlHolder holder, HttpFilterChain chain) throws Exception {
                    postResponse(transaction, request, response, authInfo, holder);
                }

                @Override
                public boolean addHeader(String name) {
                    return false;
                }
            };
            HttpFilterChain chain = new HttpFilterChainImpl(holder, postProc);
            try {
                chain.nextFilter(filterReq, filterResp, chain);
            } catch (Exception e) {
                throw new ServletException(e);
            }
        }
    };
    AzSys az = new AzSys();
    az.doAz(request, response, completeFed);
}
Also used : AuthInfo(com.tremolosecurity.proxy.auth.AuthInfo) HttpServletResponse(javax.servlet.http.HttpServletResponse) NextSys(com.tremolosecurity.proxy.util.NextSys) AuthController(com.tremolosecurity.proxy.auth.AuthController) ProvisioningException(com.tremolosecurity.provisioning.core.ProvisioningException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) LDAPException(com.novell.ldap.LDAPException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) URISyntaxException(java.net.URISyntaxException) InvalidJwtException(org.jose4j.jwt.consumer.InvalidJwtException) IllegalBlockSizeException(javax.crypto.IllegalBlockSizeException) JoseException(org.jose4j.lang.JoseException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ParseException(org.json.simple.parser.ParseException) NoSuchPaddingException(javax.crypto.NoSuchPaddingException) MalformedURLException(java.net.MalformedURLException) BadPaddingException(javax.crypto.BadPaddingException) UrlHolder(com.tremolosecurity.config.util.UrlHolder) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpFilterResponse(com.tremolosecurity.proxy.filter.HttpFilterResponse) ServletException(javax.servlet.ServletException) PostProcess(com.tremolosecurity.proxy.filter.PostProcess) HttpFilterRequestImpl(com.tremolosecurity.proxy.filter.HttpFilterRequestImpl) HttpFilterResponseImpl(com.tremolosecurity.proxy.filter.HttpFilterResponseImpl) AzSys(com.tremolosecurity.proxy.auth.AzSys) HttpFilterChainImpl(com.tremolosecurity.proxy.filter.HttpFilterChainImpl) HttpFilterChain(com.tremolosecurity.proxy.filter.HttpFilterChain) HttpFilterRequest(com.tremolosecurity.proxy.filter.HttpFilterRequest)

Example 3 with NextSys

use of com.tremolosecurity.proxy.util.NextSys in project OpenUnison by TremoloSecurity.

the class AuthFilter method doFilter.

@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
    // HttpSession session = ((HttpServletRequest) req).getSession(true);
    // SharedSession.getSharedSession().registerSession(session);
    // HttpSession session = (HttpSession) req.getAttribute(ConfigFilter.AUTOIDM_SESSION);//((HttpServletRequest) req).getSession();
    NextSys next = new FilterNextSys(chain);
    authMgr.doAuth(req, resp, next);
}
Also used : NextSys(com.tremolosecurity.proxy.util.NextSys) FilterNextSys(com.tremolosecurity.proxy.util.FilterNextSys) FilterNextSys(com.tremolosecurity.proxy.util.FilterNextSys)

Example 4 with NextSys

use of com.tremolosecurity.proxy.util.NextSys in project OpenUnison by TremoloSecurity.

the class AuthMechMgr method doFilter.

@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) resp;
    AuthController ac = (AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL);
    AuthStep curStep = ac.getCurrentStep();
    if (curStep != null) {
        curStep.setExecuted(true);
        curStep.setSuccess(false);
    }
    NextSys next = new FilterNextSys(chain);
    sys.doAuthMgr(request, response, next, curStep);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) FilterNextSys(com.tremolosecurity.proxy.util.FilterNextSys) NextSys(com.tremolosecurity.proxy.util.NextSys) FilterNextSys(com.tremolosecurity.proxy.util.FilterNextSys) AuthStep(com.tremolosecurity.proxy.auth.util.AuthStep)

Example 5 with NextSys

use of com.tremolosecurity.proxy.util.NextSys in project OpenUnison by TremoloSecurity.

the class SamlTransaction method completeFederation.

private void completeFederation(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, MalformedURLException {
    final SamlTransaction transaction = (SamlTransaction) request.getSession().getAttribute(Saml2Idp.TRANSACTION_DATA);
    final AuthInfo authInfo = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL)).getAuthInfo();
    if (!authInfo.isAuthComplete()) {
        logger.warn("Attempted completetd federation before autthentication is completeed, clearing authentication and redirecting to the original URL");
        UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG);
        request.getSession().removeAttribute(ProxyConstants.AUTH_CTL);
        holder.getConfig().createAnonUser(request.getSession());
        this.postErrorResponse(transaction, request, response, authInfo, holder);
        return;
    }
    request.setAttribute(AzSys.FORCE, "true");
    NextSys completeFed = new NextSys() {

        @Override
        public void nextSys(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
            // System.out.println("Authorized!!!!");
            final AuthInfo authInfo = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL)).getAuthInfo();
            UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG);
            HttpFilterRequest filterReq = new HttpFilterRequestImpl(request, null);
            HttpFilterResponse filterResp = new HttpFilterResponseImpl(response);
            PostProcess postProc = new PostProcess() {

                @Override
                public void postProcess(HttpFilterRequest req, HttpFilterResponse resp, UrlHolder holder, HttpFilterChain chain) throws Exception {
                    postResponse(transaction, request, response, authInfo, holder);
                }

                @Override
                public boolean addHeader(String name) {
                    return false;
                }
            };
            HttpFilterChain chain = new HttpFilterChainImpl(holder, postProc);
            try {
                chain.nextFilter(filterReq, filterResp, chain);
            } catch (Exception e) {
                throw new ServletException(e);
            }
        }
    };
    AzSys az = new AzSys();
    az.doAz(request, response, completeFed);
}
Also used : AuthInfo(com.tremolosecurity.proxy.auth.AuthInfo) HttpServletResponse(javax.servlet.http.HttpServletResponse) NextSys(com.tremolosecurity.proxy.util.NextSys) AuthController(com.tremolosecurity.proxy.auth.AuthController) ServletException(javax.servlet.ServletException) SignatureException(java.security.SignatureException) UnmarshallingException(org.opensaml.core.xml.io.UnmarshallingException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SAXException(org.xml.sax.SAXException) InvalidKeyException(java.security.InvalidKeyException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InitializationException(org.opensaml.core.config.InitializationException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) UrlHolder(com.tremolosecurity.config.util.UrlHolder) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpFilterResponse(com.tremolosecurity.proxy.filter.HttpFilterResponse) ServletException(javax.servlet.ServletException) PostProcess(com.tremolosecurity.proxy.filter.PostProcess) HttpFilterRequestImpl(com.tremolosecurity.proxy.filter.HttpFilterRequestImpl) HttpFilterResponseImpl(com.tremolosecurity.proxy.filter.HttpFilterResponseImpl) AzSys(com.tremolosecurity.proxy.auth.AzSys) HttpFilterChainImpl(com.tremolosecurity.proxy.filter.HttpFilterChainImpl) HttpFilterChain(com.tremolosecurity.proxy.filter.HttpFilterChain) HttpFilterRequest(com.tremolosecurity.proxy.filter.HttpFilterRequest)

Aggregations

NextSys (com.tremolosecurity.proxy.util.NextSys)5 FilterNextSys (com.tremolosecurity.proxy.util.FilterNextSys)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 UrlHolder (com.tremolosecurity.config.util.UrlHolder)2 AuthController (com.tremolosecurity.proxy.auth.AuthController)2 AuthInfo (com.tremolosecurity.proxy.auth.AuthInfo)2 AzSys (com.tremolosecurity.proxy.auth.AzSys)2 HttpFilterChain (com.tremolosecurity.proxy.filter.HttpFilterChain)2 HttpFilterChainImpl (com.tremolosecurity.proxy.filter.HttpFilterChainImpl)2 HttpFilterRequest (com.tremolosecurity.proxy.filter.HttpFilterRequest)2 HttpFilterRequestImpl (com.tremolosecurity.proxy.filter.HttpFilterRequestImpl)2 HttpFilterResponse (com.tremolosecurity.proxy.filter.HttpFilterResponse)2 HttpFilterResponseImpl (com.tremolosecurity.proxy.filter.HttpFilterResponseImpl)2 PostProcess (com.tremolosecurity.proxy.filter.PostProcess)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 InvalidKeyException (java.security.InvalidKeyException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2