tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
private CertResponse prepareResponseWithTemplateSelectionId(CertResponse response,String keyUsageValue){
        Gson gson = new GsonBuilder().setLenient().create();
        JsonObject json = gson.fromJson(response.getResponse(),JsonObject.class);
        JsonParser jsonParser = new JsonParser();
        JsonObject jsonObject = (JsonObject) jsonParser.parse(json.toString());
        JsonObject jsonObject1 = jsonObject.getAsJsonObject("template");
        JsonArray jsonArray = jsonObject1.getAsJsonArray("items");
        JsonObject jsonObject2 = null;
        int selectedId = 0;

        for (int i = 0; i < jsonArray.size(); i++) {
            jsonObject2 = jsonArray.get(i).getAsJsonObject();
            if (keyUsageValue.equalsIgnoreCase(SSLCertificateConstants.KEYUSAGE_VALUE_BOTH)) {
                if (jsonObject2.get("displayName").getAsString().equals(SSLCertificateConstants.CLIENT_SERVER_TEMPLATE_NAME)) {
                    selectedId = Integer.parseInt(jsonObject2.get("policyLinkId").getAsString());
                    break;
                }
            } else  {
                if (jsonObject2.get("displayName").getAsString().equals(SSLCertificateConstants.CLIENT_TEMPLATE_NAME)) {
                    selectedId = Integer.parseInt(jsonObject2.get("policyLinkId").getAsString());
                    break;
                }
            }
        }

        jsonObject1.addProperty("selectedId",selectedId);
        response.setResponse(jsonObject.toString());
        return response;
    }
/**
     * Thi method will be used to update the template id based on selected extended key usage (client/server/both)
     * @param response
     * @param keyUsageValue
     * @return
     */
Thi method will be used to update the template id based on selected extended key usage (client/server/both)
@param response
@param keyUsageValue
@return
Thi method will be used to update the template id based on selected extended key usage ( client / server / both ) @param response @param keyUsageValue @return
private CertResponse prepareResponseWithTemplateSelectionId(CertResponse response,String keyUsageValue){
        Gson gson = new GsonBuilder().setLenient().create();
        JsonObject json = gson.fromJson(response.getResponse(),JsonObject.class);
        JsonParser jsonParser = new JsonParser();
        JsonObject jsonObject = (JsonObject) jsonParser.parse(json.toString());
        JsonObject jsonObject1 = jsonObject.getAsJsonObject("template");
        JsonArray jsonArray = jsonObject1.getAsJsonArray("items");
        JsonObject jsonObject2 = null;
        int selectedId = 0;
        for (int i = 0; i < jsonArray.size(); i++) {
            jsonObject2 = jsonArray.get(i).getAsJsonObject();
            if (keyUsageValue.equalsIgnoreCase(SSLCertificateConstants.KEYUSAGE_VALUE_BOTH)) {
                if (jsonObject2.get("displayName").getAsString().equals(SSLCertificateConstants.CLIENT_SERVER_TEMPLATE_NAME)) {
                    selectedId = Integer.parseInt(jsonObject2.get("policyLinkId").getAsString());
                    break;
                }
            } else  {
                if (jsonObject2.get("displayName").getAsString().equals(SSLCertificateConstants.CLIENT_TEMPLATE_NAME)) {
                    selectedId = Integer.parseInt(jsonObject2.get("policyLinkId").getAsString());
                    break;
                }
            }
        }
        jsonObject1.addProperty("selectedId",selectedId);
        response.setResponse(jsonObject.toString());
        return response;
    }
private CertResponse prepareResponseWithTemplateSelectionId ( CertResponse response , String keyUsageValue ) { Gson gson = new GsonBuilder ( ) . setLenient ( ) . create ( ) ; JsonObject json = gson . fromJson ( response . getResponse ( ) , JsonObject . class ) ; JsonParser jsonParser = new JsonParser ( ) ; JsonObject jsonObject = ( JsonObject ) jsonParser . parse ( json . toString ( ) ) ; JsonObject jsonObject1 = jsonObject . getAsJsonObject ( "template" ) ; JsonArray jsonArray = jsonObject1 . getAsJsonArray ( "items" ) ; JsonObject jsonObject2 = null ; int selectedId = 0 ; for ( int i = 0 ; i < jsonArray . size ( ) ; i ++ ) { jsonObject2 = jsonArray . get ( i ) . getAsJsonObject ( ) ; if ( keyUsageValue . equalsIgnoreCase ( SSLCertificateConstants . KEYUSAGE_VALUE_BOTH ) ) { if ( jsonObject2 . get ( "displayName" ) . getAsString ( ) . equals ( SSLCertificateConstants . CLIENT_SERVER_TEMPLATE_NAME ) ) { selectedId = Integer . parseInt ( jsonObject2 . get ( "policyLinkId" ) . getAsString ( ) ) ; break ; } } else { if ( jsonObject2 . get ( "displayName" ) . getAsString ( ) . equals ( SSLCertificateConstants . CLIENT_TEMPLATE_NAME ) ) { selectedId = Integer . parseInt ( jsonObject2 . get ( "policyLinkId" ) . getAsString ( ) ) ; break ; } } } jsonObject1 . addProperty ( "selectedId" , selectedId ) ; response . setResponse ( jsonObject . toString ( ) ) ; return response ; }
Thi method will be used to update the template id based on selected extended key usage (client/server/both)
 @param response
 @param keyUsageValue
 @return
Thi method will be used to update the template id based on selected extended key usage ( client / server / both ) @param response @param keyUsageValue @return