tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
public ResponseEntity<String> addGroupToCertificate(UserDetails userDetails, String userToken, CertificateGroup certificateGroup) {
   		String authToken = null;
   		boolean isAuthorized = true;
        certificateGroup.setCertificateName(certificateGroup.getCertificateName().toLowerCase());
		log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
				.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
				.put(LogMessage.ACTION, SSLCertificateConstants.ADD_GROUP_TO_CERT_MSG)
				.put(LogMessage.MESSAGE, "Trying to add group to Certificate folder")
				.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
				.build()));
   		if(!ControllerUtil.arecertificateGroupInputsValid(certificateGroup)) {
   			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
	   					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
	   					put(LogMessage.ACTION, SSLCertificateConstants.ADD_GROUP_TO_CERT_MSG).
	   					put(LogMessage.MESSAGE, "Invalid input values").
	   					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
	   					build()));
   			
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ERRORINVALID);
		}

   		// External certificate disabled check
        if (certificateGroup.getCertType().equalsIgnoreCase(SSLCertificateConstants.EXTERNAL) && !isExternalCertEnabled){
            log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
                    .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
                    .put(LogMessage.ACTION, SSLCertificateConstants.ADD_GROUP_TO_CERT_MSG)
                    .put(LogMessage.MESSAGE,
                            "Failed to add group to external SSL certificate. Operation not allowed.")
                    .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
            return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(
                    "{\"errors\":[\"Failed to add group to external SSL certificate. Operation not allowed.\"]}");
        }

   		if (!ObjectUtils.isEmpty(userDetails)) {
			if (userDetails.isAdmin()) {
   				authToken = userDetails.getClientToken();
   	        }else {
   	        	authToken = userDetails.getSelfSupportToken();
   	        }
   			isAuthorized=isAuthorized(userDetails, certificateGroup.getCertificateName(), certificateGroup.getCertType());
   			if(isAuthorized){
   	   			return addingGroupToCertificate(authToken, certificateGroup, userDetails);
   	   		}else{
   	   			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
   	   					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
   	   					put(LogMessage.ACTION, SSLCertificateConstants.ADD_GROUP_TO_CERT_MSG).
   	   					put(LogMessage.MESSAGE, "Access denied: No permission to add groups to this certificate").
   	   					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
   	   					build()));

   	   			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Access denied: No permission to add groups to this certificate\"]}");
   	   		}

   		}
   		return ResponseEntity.status(HttpStatus.OK).body("{\"messages\\\":[\"Group is successfully associated with Certificate\"]}");
	}
/**
	 * Adds a group to a certificate
	 * @param userDetails
	 * @param userToken
	 * @param certificateGroup
	 * @return
	 */
Adds a group to a certificate
@param userDetails
@param userToken
@param certificateGroup
@return
Adds a group to a certificate @param userDetails @param userToken @param certificateGroup @return
public ResponseEntity<String> addGroupToCertificate(UserDetails userDetails, String userToken, CertificateGroup certificateGroup) {
   		String authToken = null;
   		boolean isAuthorized = true;
        certificateGroup.setCertificateName(certificateGroup.getCertificateName().toLowerCase());
		log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
				.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
				.put(LogMessage.ACTION, SSLCertificateConstants.ADD_GROUP_TO_CERT_MSG)
				.put(LogMessage.MESSAGE, "Trying to add group to Certificate folder")
				.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
				.build()));
   		if(!ControllerUtil.arecertificateGroupInputsValid(certificateGroup)) {
   			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
	   					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
	   					put(LogMessage.ACTION, SSLCertificateConstants.ADD_GROUP_TO_CERT_MSG).
	   					put(LogMessage.MESSAGE, "Invalid input values").
	   					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
	   					build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ERRORINVALID);
		}
        if (certificateGroup.getCertType().equalsIgnoreCase(SSLCertificateConstants.EXTERNAL) && !isExternalCertEnabled){
            log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
                    .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
                    .put(LogMessage.ACTION, SSLCertificateConstants.ADD_GROUP_TO_CERT_MSG)
                    .put(LogMessage.MESSAGE,
                            "Failed to add group to external SSL certificate. Operation not allowed.")
                    .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
            return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(
                    "{\"errors\":[\"Failed to add group to external SSL certificate. Operation not allowed.\"]}");
        }
   		if (!ObjectUtils.isEmpty(userDetails)) {
			if (userDetails.isAdmin()) {
   				authToken = userDetails.getClientToken();
   	        }else {
   	        	authToken = userDetails.getSelfSupportToken();
   	        }
   			isAuthorized=isAuthorized(userDetails, certificateGroup.getCertificateName(), certificateGroup.getCertType());
   			if(isAuthorized){
   	   			return addingGroupToCertificate(authToken, certificateGroup, userDetails);
   	   		}else{
   	   			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
   	   					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
   	   					put(LogMessage.ACTION, SSLCertificateConstants.ADD_GROUP_TO_CERT_MSG).
   	   					put(LogMessage.MESSAGE, "Access denied: No permission to add groups to this certificate").
   	   					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
   	   					build()));
   	   			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Access denied: No permission to add groups to this certificate\"]}");
   	   		}
   		}
   		return ResponseEntity.status(HttpStatus.OK).body("{\"messages\\\":[\"Group is successfully associated with Certificate\"]}");
	}
public ResponseEntity < String > addGroupToCertificate ( UserDetails userDetails , String userToken , CertificateGroup certificateGroup ) { String authToken = null ; boolean isAuthorized = true ; certificateGroup . setCertificateName ( certificateGroup . getCertificateName ( ) . toLowerCase ( ) ) ; log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . ADD_GROUP_TO_CERT_MSG ) . put ( LogMessage . MESSAGE , "Trying to add group to Certificate folder" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; if ( ! ControllerUtil . arecertificateGroupInputsValid ( certificateGroup ) ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . ADD_GROUP_TO_CERT_MSG ) . put ( LogMessage . MESSAGE , "Invalid input values" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( ERRORINVALID ) ; } if ( certificateGroup . getCertType ( ) . equalsIgnoreCase ( SSLCertificateConstants . EXTERNAL ) && ! isExternalCertEnabled ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . ADD_GROUP_TO_CERT_MSG ) . put ( LogMessage . MESSAGE , "Failed to add group to external SSL certificate. Operation not allowed." ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . UNPROCESSABLE_ENTITY ) . body ( "{\"errors\":[\"Failed to add group to external SSL certificate. Operation not allowed.\"]}" ) ; } if ( ! ObjectUtils . isEmpty ( userDetails ) ) { if ( userDetails . isAdmin ( ) ) { authToken = userDetails . getClientToken ( ) ; } else { authToken = userDetails . getSelfSupportToken ( ) ; } isAuthorized = isAuthorized ( userDetails , certificateGroup . getCertificateName ( ) , certificateGroup . getCertType ( ) ) ; if ( isAuthorized ) { return addingGroupToCertificate ( authToken , certificateGroup , userDetails ) ; } else { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . ADD_GROUP_TO_CERT_MSG ) . put ( LogMessage . MESSAGE , "Access denied: No permission to add groups to this certificate" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"Access denied: No permission to add groups to this certificate\"]}" ) ; } } return ResponseEntity . status ( HttpStatus . OK ) . body ( "{\"messages\\\":[\"Group is successfully associated with Certificate\"]}" ) ; }
Adds a group to a certificate
 @param userDetails
 @param userToken
 @param certificateGroup
 @return
Adds a group to a certificate @param userDetails @param userToken @param certificateGroup @return
// External certificate disabled check