2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.rserv;
24 import java.io.IOException;
26 import javax.servlet.Filter;
27 import javax.servlet.FilterChain;
28 import javax.servlet.FilterConfig;
29 import javax.servlet.ServletException;
30 import javax.servlet.ServletRequest;
31 import javax.servlet.ServletResponse;
33 import org.onap.aaf.cadi.principal.TaggedPrincipal;
34 import org.onap.aaf.misc.env.TimeTaken;
35 import org.onap.aaf.misc.env.TransStore;
38 * Create a new Transaction Object for each and every incoming Transaction
40 * Attach to Request. User "FilterHolder" mechanism to retain single instance.
42 * TransFilter includes CADIFilter as part of the package, so that it can
43 * set User Data, etc, as necessary.
48 public abstract class TransOnlyFilter<TRANS extends TransStore> implements Filter {
50 public void init(FilterConfig filterConfig) throws ServletException {
55 protected abstract TRANS newTrans();
56 protected abstract TimeTaken start(TRANS trans, ServletRequest request);
57 protected abstract void authenticated(TRANS trans, TaggedPrincipal p);
58 protected abstract void tallyHo(TRANS trans);
61 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
62 TRANS trans = newTrans();
64 TimeTaken overall = start(trans,request);
66 request.setAttribute(TransFilter.TRANS_TAG, trans);
67 chain.doFilter(request, response);
75 public void destroy() {