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.aaf;
\r
26 import java.security.Principal;
\r
27 import java.util.regex.Pattern;
\r
29 import com.att.cadi.Transmutate;
\r
30 import com.att.cadi.lur.ConfigPrincipal;
\r
31 import com.att.cadi.principal.BasicPrincipal;
\r
32 import com.att.cadi.principal.CSPPrincipal_T;
\r
37 * Each System determines the mechanisms for which one Principal is transmutated to another, such as whether it is created
\r
38 * independently, etc.
\r
40 * For AAF, the only important thing is that these are valid ATTUID/mechIDs, to avoid unnecessary user hits
\r
42 * attUIDs look like ab1234 or AB1234 or AZ123a
\r
43 * mechids look like m12345
\r
47 public final class AAFTransmutate implements Transmutate<Principal> {
\r
48 private Pattern pattern = Pattern.compile("[a-zA-Z]\\w\\d\\d\\d\\w");
\r
50 public Principal mutate(Principal p) {
\r
51 // Accept these three internal kinds of Principals
\r
52 if(p instanceof CSPPrincipal_T
\r
53 || p instanceof BasicPrincipal
\r
54 || p instanceof ConfigPrincipal) {
\r
57 String name = p.getName();
\r
58 final int idx = name.indexOf('@');
\r
59 if(idx>0) { // strip off any domain
\r
60 name = name.substring(0,idx);
\r
63 // Check for ATTUID specs before creating CSP_T
\r
64 return pattern.matcher(name).matches()?
\r
71 * Essential Principal reflecting CSP Principal
\r
75 private final class CSP_T implements CSPPrincipal_T {
\r
76 private String name;
\r
77 public CSP_T(String name) {
\r
80 public String getName() {
\r