tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
public ResponseEntity<String> removeUserFromCertificate(CertificateUser certificateUser, UserDetails userDetails) {
		
		if(!areCertificateUserInputsValid(certificateUser)) {
   			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
   					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
   					put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_USER_FROM_CERT_MSG).
   					put(LogMessage.MESSAGE, SSLCertificateConstants.INVALID_INPUT_MSG).
   					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
   					build()));
   			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ERRORINVALID);
   		}

        // External certificate disabled check
        if (certificateUser.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.REMOVE_USER_FROM_CERT_MSG)
                    .put(LogMessage.MESSAGE,
                            "Failed to remove user from 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 remove user from external SSL certificate. Operation not allowed.\"]}");
        }
		
		log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
				.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
				.put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_USER_FROM_CERT_MSG)
				.put(LogMessage.MESSAGE, "Trying to delete user from the certificate")
				.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
				.build()));

		String userName = certificateUser.getUsername().toLowerCase();
   		String certificateName = certificateUser.getCertificateName().toLowerCase(); 
   		String certificateType = certificateUser.getCertType();
   		String authToken = null;   		
   		boolean isAuthorized = true;
   		
   		if (!ObjectUtils.isEmpty(userDetails)) {
			if (userDetails.isAdmin()) {
   				authToken = userDetails.getClientToken();   	            
   	        }else {
   	        	authToken = userDetails.getSelfSupportToken();
   	        }
   			SSLCertificateMetadataDetails certificateMetaData = certificateUtils.getCertificateMetaData(authToken, certificateName, certificateType);
   			
   			isAuthorized = certificateUtils.hasAddOrRemovePermission(userDetails, certificateMetaData); 
   		}else {
   			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
   					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
   					put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_USER_FROM_CERT_MSG).
   					put(LogMessage.MESSAGE, "Access denied: No permission to remove user from this certificate").
   					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
   					build()));
   			
   			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Access denied: No permission to remove user from this certificate\"]}");
   		}
		
		if(isAuthorized){
			return checkUserPolicyAndRemoveFromCertificate(userName, certificateName, authToken, certificateType, userDetails, false);
		} else {
			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_USER_FROM_CERT_MSG).
					put(LogMessage.MESSAGE, "Access denied: No permission to remove user from this certificate").
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Access denied: No permission to remove user from this certificate\"]}");
		}
	}
/**
	 * Removes user from certificate
	 * @param token
	 * @param safeUser
	 * @return
	 */
Removes user from certificate
@param token
@param safeUser
@return
Removes user from certificate @param token @param safeUser @return
public ResponseEntity<String> removeUserFromCertificate(CertificateUser certificateUser, UserDetails userDetails) {
		if(!areCertificateUserInputsValid(certificateUser)) {
   			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
   					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
   					put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_USER_FROM_CERT_MSG).
   					put(LogMessage.MESSAGE, SSLCertificateConstants.INVALID_INPUT_MSG).
   					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
   					build()));
   			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ERRORINVALID);
   		}
        if (certificateUser.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.REMOVE_USER_FROM_CERT_MSG)
                    .put(LogMessage.MESSAGE,
                            "Failed to remove user from 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 remove user from external SSL certificate. Operation not allowed.\"]}");
        }
		log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
				.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
				.put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_USER_FROM_CERT_MSG)
				.put(LogMessage.MESSAGE, "Trying to delete user from the certificate")
				.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
				.build()));
		String userName = certificateUser.getUsername().toLowerCase();
   		String certificateName = certificateUser.getCertificateName().toLowerCase(); 
   		String certificateType = certificateUser.getCertType();
   		String authToken = null;   		
   		boolean isAuthorized = true;
   		if (!ObjectUtils.isEmpty(userDetails)) {
			if (userDetails.isAdmin()) {
   				authToken = userDetails.getClientToken();   	            
   	        }else {
   	        	authToken = userDetails.getSelfSupportToken();
   	        }
   			SSLCertificateMetadataDetails certificateMetaData = certificateUtils.getCertificateMetaData(authToken, certificateName, certificateType);
   			isAuthorized = certificateUtils.hasAddOrRemovePermission(userDetails, certificateMetaData); 
   		}else {
   			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
   					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
   					put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_USER_FROM_CERT_MSG).
   					put(LogMessage.MESSAGE, "Access denied: No permission to remove user from this certificate").
   					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
   					build()));
   			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Access denied: No permission to remove user from this certificate\"]}");
   		}
		if(isAuthorized){
			return checkUserPolicyAndRemoveFromCertificate(userName, certificateName, authToken, certificateType, userDetails, false);
		} else {
			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_USER_FROM_CERT_MSG).
					put(LogMessage.MESSAGE, "Access denied: No permission to remove user from this certificate").
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Access denied: No permission to remove user from this certificate\"]}");
		}
	}
public ResponseEntity < String > removeUserFromCertificate ( CertificateUser certificateUser , UserDetails userDetails ) { if ( ! areCertificateUserInputsValid ( certificateUser ) ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . REMOVE_USER_FROM_CERT_MSG ) . put ( LogMessage . MESSAGE , SSLCertificateConstants . INVALID_INPUT_MSG ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( ERRORINVALID ) ; } if ( certificateUser . 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 . REMOVE_USER_FROM_CERT_MSG ) . put ( LogMessage . MESSAGE , "Failed to remove user from 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 remove user from external SSL certificate. Operation not allowed.\"]}" ) ; } log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . REMOVE_USER_FROM_CERT_MSG ) . put ( LogMessage . MESSAGE , "Trying to delete user from the certificate" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; String userName = certificateUser . getUsername ( ) . toLowerCase ( ) ; String certificateName = certificateUser . getCertificateName ( ) . toLowerCase ( ) ; String certificateType = certificateUser . getCertType ( ) ; String authToken = null ; boolean isAuthorized = true ; if ( ! ObjectUtils . isEmpty ( userDetails ) ) { if ( userDetails . isAdmin ( ) ) { authToken = userDetails . getClientToken ( ) ; } else { authToken = userDetails . getSelfSupportToken ( ) ; } SSLCertificateMetadataDetails certificateMetaData = certificateUtils . getCertificateMetaData ( authToken , certificateName , certificateType ) ; isAuthorized = certificateUtils . hasAddOrRemovePermission ( userDetails , certificateMetaData ) ; } else { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . REMOVE_USER_FROM_CERT_MSG ) . put ( LogMessage . MESSAGE , "Access denied: No permission to remove user from this certificate" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"Access denied: No permission to remove user from this certificate\"]}" ) ; } if ( isAuthorized ) { return checkUserPolicyAndRemoveFromCertificate ( userName , certificateName , authToken , certificateType , userDetails , false ) ; } else { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . REMOVE_USER_FROM_CERT_MSG ) . put ( LogMessage . MESSAGE , "Access denied: No permission to remove user from this certificate" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"Access denied: No permission to remove user from this certificate\"]}" ) ; } }
Removes user from certificate
 @param token
 @param safeUser
 @return
Removes user from certificate @param token @param safeUser @return
// External certificate disabled check