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.principal;
\r
26 public class TGuardPrincipal extends BearerPrincipal {
\r
28 private String name, tresp;
\r
30 public TGuardPrincipal(String tresp) {
\r
35 * TODO Need to figure out what Organizations TGuard entities should be part of.
\r
38 public String getName() {
\r
40 String temp = get("iv-user");
\r
41 if(temp==null)return null;
\r
42 StringBuilder sb = new StringBuilder();
\r
43 int at = temp.indexOf('@');
\r
47 sb.append(temp.substring(0, at));
\r
49 if(temp.endsWith("@uverse.com"))sb.append("@uverse.tguard.att.com");
\r
50 else if(temp.endsWith("@att.com"))sb.append("@com.tguard.att.com");
\r
51 else if(temp.endsWith("@att.net"))sb.append("@net.tguard.att.com");
\r
52 else sb.append("@tguard.att.com");
\r
53 name = sb.toString();
\r
59 * Get a value from a named TGuard Property
\r
61 * 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
65 public String get(String key) {
\r
66 if(key==null)return null;
\r
67 int idx=0,equal=0,amp=0;
\r
68 while(idx>=0 && (equal = tresp.indexOf('=',idx))>=0) {
\r
69 amp = tresp.indexOf('&',equal);
\r
70 if(key.regionMatches(0, tresp, idx, equal-idx)) {
\r
71 return amp>=0?tresp.substring(equal+1, amp):tresp.substring(equal+1);
\r
73 idx=amp+(amp>0?1:0);
\r
78 public String info() {
\r