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.principal;
\r
25 public class TGuardPrincipal extends BearerPrincipal {
\r
27 private String name, tresp;
\r
29 public TGuardPrincipal(String tresp) {
\r
34 * TODO Need to figure out what Organizations TGuard entities should be part of.
\r
37 public String getName() {
\r
39 String temp = get("iv-user");
\r
40 if(temp==null)return null;
\r
41 StringBuilder sb = new StringBuilder();
\r
42 int at = temp.indexOf('@');
\r
46 sb.append(temp.substring(0, at));
\r
48 if(temp.endsWith("@uverse.com"))sb.append("@uverse.tguard.att.com");
\r
49 else if(temp.endsWith("@att.com"))sb.append("@com.tguard.att.com");
\r
50 else if(temp.endsWith("@att.net"))sb.append("@net.tguard.att.com");
\r
51 else sb.append("@tguard.att.com");
\r
52 name = sb.toString();
\r
58 * Get a value from a named TGuard Property
\r
60 * TGuard response info is very dynamic. They can add new properties at any time, so we dare not code field names for these values.
\r
64 public String get(String key) {
\r
65 if(key==null)return null;
\r
66 int idx=0,equal=0,amp=0;
\r
67 while(idx>=0 && (equal = tresp.indexOf('=',idx))>=0) {
\r
68 amp = tresp.indexOf('&',equal);
\r
69 if(key.regionMatches(0, tresp, idx, equal-idx)) {
\r
70 return amp>=0?tresp.substring(equal+1, amp):tresp.substring(equal+1);
\r
72 idx=amp+(amp>0?1:0);
\r
77 public String info() {
\r