+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cadi.principal;\r
-\r
-public class TGuardPrincipal extends BearerPrincipal {\r
-\r
- private String name, tresp;\r
-\r
- public TGuardPrincipal(String tresp) {\r
- this.tresp=tresp;\r
- }\r
-\r
- /**\r
- * TODO Need to figure out what Organizations TGuard entities should be part of. \r
- * \r
- */\r
- public String getName() {\r
- if(name==null) {\r
- String temp = get("iv-user");\r
- if(temp==null)return null;\r
- StringBuilder sb = new StringBuilder();\r
- int at = temp.indexOf('@');\r
- if(at<0) {\r
- sb.append(temp);\r
- } else {\r
- sb.append(temp.substring(0, at));\r
- }\r
- if(temp.endsWith("@uverse.com"))sb.append("@uverse.tguard.att.com");\r
- else if(temp.endsWith("@att.com"))sb.append("@com.tguard.att.com");\r
- else if(temp.endsWith("@att.net"))sb.append("@net.tguard.att.com");\r
- else sb.append("@tguard.att.com");\r
- name = sb.toString();\r
- }\r
- return name;\r
- }\r
-\r
- /**\r
- * Get a value from a named TGuard Property\r
- * \r
- * 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
- * @param key\r
- * @return\r
- */\r
- public String get(String key) {\r
- if(key==null)return null;\r
- int idx=0,equal=0,amp=0;\r
- while(idx>=0 && (equal = tresp.indexOf('=',idx))>=0) {\r
- amp = tresp.indexOf('&',equal);\r
- if(key.regionMatches(0, tresp, idx, equal-idx)) {\r
- return amp>=0?tresp.substring(equal+1, amp):tresp.substring(equal+1); \r
- }\r
- idx=amp+(amp>0?1:0);\r
- }\r
- return null;\r
- }\r
-\r
- public String info() {\r
- return tresp;\r
- }\r
-}\r