+++ /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.aaf;\r
-\r
-import java.security.Principal;\r
-import java.util.regex.Pattern;\r
-\r
-import org.onap.aaf.cadi.Transmutate;\r
-import org.onap.aaf.cadi.lur.ConfigPrincipal;\r
-import org.onap.aaf.cadi.principal.BasicPrincipal;\r
-import org.onap.aaf.cadi.principal.CSPPrincipal_T;\r
-\r
-/**\r
- * AAFTransmutate\r
- * \r
- * Each System determines the mechanisms for which one Principal is transmutated to another, such as whether it is created\r
- * independently, etc.\r
- * \r
- * For AAF, the only important thing is that these are valid ATTUID/mechIDs, to avoid unnecessary user hits\r
- * \r
- * attUIDs look like ab1234 or AB1234 or AZ123a\r
- * mechids look like m12345\r
- * \r
- *\r
- */\r
-public final class AAFTransmutate implements Transmutate<Principal> {\r
- private Pattern pattern = Pattern.compile("[a-zA-Z]\\w\\d\\d\\d\\w");\r
-\r
- public Principal mutate(Principal p) {\r
- // Accept these three internal kinds of Principals\r
- if(p instanceof CSPPrincipal_T \r
- || p instanceof BasicPrincipal\r
- || p instanceof ConfigPrincipal) { \r
- return p;\r
- } else { \r
- \r
- final String name = p.getName();\r
- final int idx = name.indexOf('@');\r
- String shortName;\r
- if(idx>0) { // strip off any domain\r
- shortName = name.substring(0,idx); \r
- } else {\r
- shortName = name;\r
- }\r
-\r
- // Check for ATTUID specs before creating CSP_T\r
- return pattern.matcher(shortName).matches()?\r
- new CSP_T(name): // Note: use REAL name, short name for CSP_T\r
- null;\r
- }\r
- }\r
-\r
- /**\r
- * Essential Principal reflecting CSP Principal\r
- * \r
- *\r
- */\r
- private final class CSP_T implements CSPPrincipal_T {\r
- private String name;\r
- public CSP_T(String name) {\r
- this.name = name;\r
- }\r
- public String getName() {\r
- return name;\r
- }\r
- }\r
-}\r