1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * Copyright © 2017 Amdocs
\r
7 * * ===========================================================================
\r
8 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * * you may not use this file except in compliance with the License.
\r
10 * * You may obtain a copy of the License at
\r
12 * * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * * Unless required by applicable law or agreed to in writing, software
\r
15 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * * See the License for the specific language governing permissions and
\r
18 * * limitations under the License.
\r
19 * * ============LICENSE_END====================================================
\r
21 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 ******************************************************************************/
\r
24 package com.att.cadi.aaf.v2_0;
\r
26 import javax.servlet.http.HttpServletRequest ;
\r
28 import com.att.cadi.Lur;
\r
29 import com.att.cadi.TrustChecker;
\r
30 import com.att.cadi.aaf.AAFPermission;
\r
31 import com.att.cadi.principal.TrustPrincipal;
\r
32 import com.att.cadi.taf.TafResp;
\r
33 import com.att.cadi.taf.TrustNotTafResp;
\r
34 import com.att.cadi.taf.TrustTafResp;
\r
35 import com.att.inno.env.util.Split;
\r
37 public class AAFTrustChecker implements TrustChecker {
\r
38 private final String tag,type,instance,action;
\r
43 * Instance will be replaced by Identity
\r
49 public AAFTrustChecker(final String tag, final String perm) {
\r
51 String[] split = Split.split('|', perm);
\r
52 this.type = split[0];
\r
53 this.instance = split[1];
\r
54 this.action = split[2];
\r
58 * @see com.att.cadi.TrustChecker#setLur(com.att.cadi.Lur)
\r
61 public void setLur(Lur lur) {
\r
66 public TafResp mayTrust(TafResp tresp, HttpServletRequest req) {
\r
67 String user_info = req.getHeader(tag);
\r
68 if(user_info !=null ) {
\r
69 String[] info = Split.split(',', user_info);
\r
71 String[] flds = Split.split(':',info[0]);
\r
72 if(flds.length>3 && "AS".equals(flds[3])) { // is it set for "AS"
\r
73 if(!tresp.getPrincipal().getName().equals(flds[0])) { // We do trust ourselves, if a trust entry is made with self
\r
74 if(lur.fish(tresp.getPrincipal(), new AAFPermission(type,instance,action))) {
\r
75 return new TrustTafResp(tresp,
\r
76 new TrustPrincipal(tresp.getPrincipal(), flds[0]),
\r
77 " " + flds[0] + " validated using " + flds[2] + " by " + flds[1] + ','
\r
80 return new TrustNotTafResp(tresp, " " + tresp.getPrincipal().getName() +
\r
81 " requested identity change to " + flds[0] + ", but does not have Authorization");
\r