fidelius-service/src/main/java/org/finra/fidelius/services/CredentialsService.java
@PreAuthorize("@fideliusRoleService.isAuthorizedToDelete(#credential.getApplication(), #credential.getAccount())")
    public Credential deleteCredential(Credential credential) {
        setFideliusEnvironment(credential.getAccount(), credential.getRegion());
        String user = fideliusRoleService.getUserProfile().getUserId();

        try {
            if (credential.getComponent() == null || credential.getComponent().equals("null")) {
                credential.setComponent(null);
            }
            Metadata metadata = getMetadata(credential.getAccount(), credential.getRegion(), credential.getApplication(), credential.getEnvironment(), credential.getComponent(), credential.getShortKey());
            if(metadata.getSource() != null && metadata.getSourceType() != null ) {
                fideliusService.deleteCredentialWithMetadata(credential.getShortKey(), credential.getApplication(),
                        credential.getEnvironment(), credential.getComponent(), tableName, user);
            } else {
                fideliusService.deleteCredential(credential.getShortKey(), credential.getApplication(),
                        credential.getEnvironment(), credential.getComponent(), tableName, user);
            }
        } catch (Exception e) {
            this.logger.info("Credential not deleted " + e.toString());
            return null;
        }

        return credential;
    }
/**
     * Deletes an existing Credential.
     *
     * @param credential Credential to be deleted
     * @return Credential deleted
     */
Deletes an existing Credential.
@param credential Credential to be deleted
@return Credential deleted
Deletes an existing Credential . @param credential Credential to be deleted @return Credential deleted
@PreAuthorize("@fideliusRoleService.isAuthorizedToDelete(#credential.getApplication(), #credential.getAccount())")
    public Credential deleteCredential(Credential credential) {
        setFideliusEnvironment(credential.getAccount(), credential.getRegion());
        String user = fideliusRoleService.getUserProfile().getUserId();
        try {
            if (credential.getComponent() == null || credential.getComponent().equals("null")) {
                credential.setComponent(null);
            }
            Metadata metadata = getMetadata(credential.getAccount(), credential.getRegion(), credential.getApplication(), credential.getEnvironment(), credential.getComponent(), credential.getShortKey());
            if(metadata.getSource() != null && metadata.getSourceType() != null ) {
                fideliusService.deleteCredentialWithMetadata(credential.getShortKey(), credential.getApplication(),
                        credential.getEnvironment(), credential.getComponent(), tableName, user);
            } else {
                fideliusService.deleteCredential(credential.getShortKey(), credential.getApplication(),
                        credential.getEnvironment(), credential.getComponent(), tableName, user);
            }
        } catch (Exception e) {
            this.logger.info("Credential not deleted " + e.toString());
            return null;
        }
        return credential;
    }
@ PreAuthorize ( "@fideliusRoleService.isAuthorizedToDelete(#credential.getApplication(), #credential.getAccount())" ) public Credential deleteCredential ( Credential credential ) { setFideliusEnvironment ( credential . getAccount ( ) , credential . getRegion ( ) ) ; String user = fideliusRoleService . getUserProfile ( ) . getUserId ( ) ; try { if ( credential . getComponent ( ) == null || credential . getComponent ( ) . equals ( "null" ) ) { credential . setComponent ( null ) ; } Metadata metadata = getMetadata ( credential . getAccount ( ) , credential . getRegion ( ) , credential . getApplication ( ) , credential . getEnvironment ( ) , credential . getComponent ( ) , credential . getShortKey ( ) ) ; if ( metadata . getSource ( ) != null && metadata . getSourceType ( ) != null ) { fideliusService . deleteCredentialWithMetadata ( credential . getShortKey ( ) , credential . getApplication ( ) , credential . getEnvironment ( ) , credential . getComponent ( ) , tableName , user ) ; } else { fideliusService . deleteCredential ( credential . getShortKey ( ) , credential . getApplication ( ) , credential . getEnvironment ( ) , credential . getComponent ( ) , tableName , user ) ; } } catch ( Exception e ) { this . logger . info ( "Credential not deleted " + e . toString ( ) ) ; return null ; } return credential ; }
Deletes an existing Credential.
Deletes an existing Credential .