tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
private Map<String, List<String>> extractCertificateNameFromPoilcies(String[] policies) {
        List<String> internalCertificateNames = new ArrayList<>();
        List<String> externalCertificateNames = new ArrayList<>();
        List<String> deniedInternalCertificates = new ArrayList<>();
        List<String> deniedExternalCertificates = new ArrayList<>();

        if (policies != null) {
            for (String policy : policies) {
                if (isPolicyOfCertType(policy, SSLCertificateConstants.INTERNAL)) {
                    String certificateName = extractValidCertificateName(policy);
                    if (!policy.startsWith("d_")) {
                        // check for internal cert policy
                        if (!StringUtils.isEmpty(certificateName) && !internalCertificateNames.contains(certificateName)) {
                            internalCertificateNames.add(certificateName);
                        }
                    }
                    else {
                        deniedInternalCertificates.add(certificateName);
                    }
                }
                else if (isPolicyOfCertType(policy, SSLCertificateConstants.EXTERNAL)) {
                    String certificateName = extractValidCertificateName(policy);
                    if (!policy.startsWith("d_")) {
                        // check for external cert policy
                        if (!StringUtils.isEmpty(certificateName) && !externalCertificateNames.contains(certificateName)) {
                            externalCertificateNames.add(certificateName);
                        }
                    }
                    else {
                        deniedExternalCertificates.add(certificateName);
                    }
                }
            }
        }
        internalCertificateNames.removeAll(deniedInternalCertificates);
        externalCertificateNames.removeAll(deniedExternalCertificates);

        Map<String, List<String>> certificateList = new HashMap<>();
        certificateList.put(SSLCertificateConstants.INTERNAL, internalCertificateNames);
        certificateList.put(SSLCertificateConstants.EXTERNAL, externalCertificateNames);
        return certificateList;
    }
/**
     * To get certificate names from policy list.
     * @param policies
     * @return
     */
To get certificate names from policy list.
@param policies
@return
To get certificate names from policy list . @param policies @return
private Map<String, List<String>> extractCertificateNameFromPoilcies(String[] policies) {
        List<String> internalCertificateNames = new ArrayList<>();
        List<String> externalCertificateNames = new ArrayList<>();
        List<String> deniedInternalCertificates = new ArrayList<>();
        List<String> deniedExternalCertificates = new ArrayList<>();
        if (policies != null) {
            for (String policy : policies) {
                if (isPolicyOfCertType(policy, SSLCertificateConstants.INTERNAL)) {
                    String certificateName = extractValidCertificateName(policy);
                    if (!policy.startsWith("d_")) {
                        if (!StringUtils.isEmpty(certificateName) && !internalCertificateNames.contains(certificateName)) {
                            internalCertificateNames.add(certificateName);
                        }
                    }
                    else {
                        deniedInternalCertificates.add(certificateName);
                    }
                }
                else if (isPolicyOfCertType(policy, SSLCertificateConstants.EXTERNAL)) {
                    String certificateName = extractValidCertificateName(policy);
                    if (!policy.startsWith("d_")) {
                        if (!StringUtils.isEmpty(certificateName) && !externalCertificateNames.contains(certificateName)) {
                            externalCertificateNames.add(certificateName);
                        }
                    }
                    else {
                        deniedExternalCertificates.add(certificateName);
                    }
                }
            }
        }
        internalCertificateNames.removeAll(deniedInternalCertificates);
        externalCertificateNames.removeAll(deniedExternalCertificates);
        Map<String, List<String>> certificateList = new HashMap<>();
        certificateList.put(SSLCertificateConstants.INTERNAL, internalCertificateNames);
        certificateList.put(SSLCertificateConstants.EXTERNAL, externalCertificateNames);
        return certificateList;
    }
private Map < String , List < String > > extractCertificateNameFromPoilcies ( String [ ] policies ) { List < String > internalCertificateNames = new ArrayList < > ( ) ; List < String > externalCertificateNames = new ArrayList < > ( ) ; List < String > deniedInternalCertificates = new ArrayList < > ( ) ; List < String > deniedExternalCertificates = new ArrayList < > ( ) ; if ( policies != null ) { for ( String policy : policies ) { if ( isPolicyOfCertType ( policy , SSLCertificateConstants . INTERNAL ) ) { String certificateName = extractValidCertificateName ( policy ) ; if ( ! policy . startsWith ( "d_" ) ) { if ( ! StringUtils . isEmpty ( certificateName ) && ! internalCertificateNames . contains ( certificateName ) ) { internalCertificateNames . add ( certificateName ) ; } } else { deniedInternalCertificates . add ( certificateName ) ; } } else if ( isPolicyOfCertType ( policy , SSLCertificateConstants . EXTERNAL ) ) { String certificateName = extractValidCertificateName ( policy ) ; if ( ! policy . startsWith ( "d_" ) ) { if ( ! StringUtils . isEmpty ( certificateName ) && ! externalCertificateNames . contains ( certificateName ) ) { externalCertificateNames . add ( certificateName ) ; } } else { deniedExternalCertificates . add ( certificateName ) ; } } } } internalCertificateNames . removeAll ( deniedInternalCertificates ) ; externalCertificateNames . removeAll ( deniedExternalCertificates ) ; Map < String , List < String > > certificateList = new HashMap < > ( ) ; certificateList . put ( SSLCertificateConstants . INTERNAL , internalCertificateNames ) ; certificateList . put ( SSLCertificateConstants . EXTERNAL , externalCertificateNames ) ; return certificateList ; }
To get certificate names from policy list.
To get certificate names from policy list .
// check for internal cert policy // check for external cert policy