Remove Tabs, per Jococo
[aaf/authz.git] / cadi / core / src / main / java / org / onap / aaf / cadi / taf / TrustTafResp.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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====================================================
19  *
20  */
21
22 package org.onap.aaf.cadi.taf;
23
24 import java.io.IOException;
25
26 import org.onap.aaf.cadi.Access;
27 import org.onap.aaf.cadi.principal.TaggedPrincipal;
28 import org.onap.aaf.cadi.util.Timing;
29
30 public class TrustTafResp implements TafResp {
31     private final TafResp delegate;
32     private final TaggedPrincipal principal;
33     private final String desc;
34     private float timing;
35     
36     public TrustTafResp(final TafResp delegate, final TaggedPrincipal principal, final String desc) {
37         this.delegate = delegate;
38         this.principal = principal;
39         this.desc = desc + ' ' + delegate.desc();
40     }
41     
42     @Override
43     public boolean isValid() {
44         return delegate.isValid();
45     }
46
47     @Override
48     public String desc() {
49         return desc;
50     }
51
52     @Override
53     public RESP isAuthenticated() {
54         return delegate.isAuthenticated();
55     }
56
57     @Override
58     public RESP authenticate() throws IOException {
59         return delegate.authenticate();
60     }
61
62     @Override
63     public TaggedPrincipal getPrincipal() {
64         return principal;
65     }
66
67     /* (non-Javadoc)
68      * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
69      */
70     @Override
71     public String getTarget() {
72         return delegate.getTarget();
73     }
74
75     @Override
76     public Access getAccess() {
77         return delegate.getAccess();
78     }
79
80     @Override
81     public boolean isFailedAttempt() {
82         return delegate.isFailedAttempt();
83     }
84     @Override
85     public float timing() {
86         return timing;
87     }
88
89     @Override
90     public void timing(long start) {
91         timing = Timing.millis(start);
92     }
93     
94     public String toString() {
95         return principal.getName() + " by trust of " + desc();
96     }
97     
98     @Override
99     public String taf() {
100         return "Trust";
101     }
102
103 }