1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.cadi.client;
\r
25 import java.security.Principal;
\r
27 import org.onap.aaf.cadi.SecuritySetter;
\r
28 import org.onap.aaf.cadi.config.SecurityInfoC;
\r
29 import org.onap.aaf.cadi.principal.BasicPrincipal;
\r
30 import org.onap.aaf.cadi.principal.TGuardPrincipal;
\r
31 import org.onap.aaf.cadi.principal.TrustPrincipal;
\r
33 public abstract class AbsTransferSS<CLIENT> implements SecuritySetter<CLIENT> {
\r
34 protected String value;
\r
35 protected SecurityInfoC<CLIENT> securityInfo;
\r
36 protected SecuritySetter<CLIENT> defSS;
\r
37 private Principal principal;
\r
39 //Format:<ID>:<APP>:<protocol>[:AS][,<ID>:<APP>:<protocol>]*
\r
40 public AbsTransferSS(Principal principal, String app) {
\r
41 init(principal, app);
\r
44 public AbsTransferSS(Principal principal, String app, SecurityInfoC<CLIENT> si) {
\r
45 init(principal,app);
\r
47 this.defSS = si.defSS;
\r
50 private void init(Principal principal, String app) {
\r
51 this.principal=principal;
\r
52 if(principal==null) {
\r
54 } else if(principal instanceof BasicPrincipal) {
\r
55 value = principal.getName() + ':' + app + ":BasicAuth:AS";
\r
56 } else if(principal instanceof TrustPrincipal) {
\r
57 TrustPrincipal tp = (TrustPrincipal)principal;
\r
59 init(tp.original(),app);
\r
60 value += principal.getName() + ':' + app + ":Trust:AS" + ',' + tp.userChain();
\r
61 } else if(principal instanceof TGuardPrincipal) {
\r
62 value = principal.getName() + ':' + app + ":TGUARD:AS";
\r
67 * @see com.att.cadi.SecuritySetter#getID()
\r
70 public String getID() {
\r
71 return principal==null?"":principal.getName();
\r