tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/IAMServiceAccountsService.java
public boolean hasAddOrRemovePermission(UserDetails userDetails, String serviceAccount, String token) {
		// Owner of the service account and admin users can add/remove users, groups, aws roles
		// and approles to service account
		if (userDetails.isAdmin()) {
			return true;
		}
		String ownerPolicy = new StringBuffer()
				.append(TVaultConstants.SVC_ACC_POLICIES_PREFIXES.getKey(TVaultConstants.SUDO_POLICY))
				.append(IAMServiceAccountConstants.IAMSVCACC_POLICY_PREFIX).append(serviceAccount).toString();
		String[] policies = policyUtils.getCurrentPolicies(token, userDetails.getUsername(), userDetails);
		if (ArrayUtils.contains(policies, ownerPolicy)) {
			return true;
		}
		return false;
	}
/**
	 * Check if user has the permission to add user/group/awsrole/approles to
	 * the IAM Service Account
	 *
	 * @param userDetails
	 * @param action
	 * @param token
	 * @return
	 */
Check if user has the permission to add user/group/awsrole/approles to
the IAM Service Account


Check if user has the permission to add user / group / awsrole / approles to the IAM Service Account
public boolean hasAddOrRemovePermission(UserDetails userDetails, String serviceAccount, String token) {
		if (userDetails.isAdmin()) {
			return true;
		}
		String ownerPolicy = new StringBuffer()
				.append(TVaultConstants.SVC_ACC_POLICIES_PREFIXES.getKey(TVaultConstants.SUDO_POLICY))
				.append(IAMServiceAccountConstants.IAMSVCACC_POLICY_PREFIX).append(serviceAccount).toString();
		String[] policies = policyUtils.getCurrentPolicies(token, userDetails.getUsername(), userDetails);
		if (ArrayUtils.contains(policies, ownerPolicy)) {
			return true;
		}
		return false;
	}
public boolean hasAddOrRemovePermission ( UserDetails userDetails , String serviceAccount , String token ) { if ( userDetails . isAdmin ( ) ) { return true ; } String ownerPolicy = new StringBuffer ( ) . append ( TVaultConstants . SVC_ACC_POLICIES_PREFIXES . getKey ( TVaultConstants . SUDO_POLICY ) ) . append ( IAMServiceAccountConstants . IAMSVCACC_POLICY_PREFIX ) . append ( serviceAccount ) . toString ( ) ; String [ ] policies = policyUtils . getCurrentPolicies ( token , userDetails . getUsername ( ) , userDetails ) ; if ( ArrayUtils . contains ( policies , ownerPolicy ) ) { return true ; } return false ; }
Check if user has the permission to add user/group/awsrole/approles to
 the IAM Service Account
Check if user has the permission to add user / group / awsrole / approles to the IAM Service Account
// Owner of the service account and admin users can add/remove users, groups, aws roles // and approles to service account