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

        try {
            if(credential.getSource() != null && credential.getSourceType() != null) {
                fideliusService.putCredentialWithMetadata(credential.getShortKey(), credential.getSecret(),
                        credential.getApplication(), credential.getEnvironment(), credential.getComponent(),
                        credential.getSource(), credential.getSourceType(), tableName, user, kmsKey);

            } else {
                fideliusService.putCredential(credential.getShortKey(), credential.getSecret(),
                        credential.getApplication(), credential.getEnvironment(), credential.getComponent(), tableName, user, kmsKey);

            }
            credential.setLastUpdatedBy(user);
            credential.setSecret(null);
        } catch (Exception e) {
            this.logger.info("Credential not created " + e.toString());
            return null;
        }

        return credential;
    }
/**
     * Add new Credential or Update an existing Credential
     *
     * @param credential Credential to be created
     * @return Credential created
     */
Add new Credential or Update an existing Credential
@param credential Credential to be created
@return Credential created
Add new Credential or Update an existing Credential @param credential Credential to be created @return Credential created
@PreAuthorize("@fideliusRoleService.isAuthorized(#credential.application, #credential.account)")
    public Credential putCredential(Credential credential) {
        setFideliusEnvironment(credential.getAccount(), credential.getRegion());
        String user = fideliusRoleService.getUserProfile().getUserId();
        try {
            if(credential.getSource() != null && credential.getSourceType() != null) {
                fideliusService.putCredentialWithMetadata(credential.getShortKey(), credential.getSecret(),
                        credential.getApplication(), credential.getEnvironment(), credential.getComponent(),
                        credential.getSource(), credential.getSourceType(), tableName, user, kmsKey);
            } else {
                fideliusService.putCredential(credential.getShortKey(), credential.getSecret(),
                        credential.getApplication(), credential.getEnvironment(), credential.getComponent(), tableName, user, kmsKey);
            }
            credential.setLastUpdatedBy(user);
            credential.setSecret(null);
        } catch (Exception e) {
            this.logger.info("Credential not created " + e.toString());
            return null;
        }
        return credential;
    }
@ PreAuthorize ( "@fideliusRoleService.isAuthorized(#credential.application, #credential.account)" ) public Credential putCredential ( Credential credential ) { setFideliusEnvironment ( credential . getAccount ( ) , credential . getRegion ( ) ) ; String user = fideliusRoleService . getUserProfile ( ) . getUserId ( ) ; try { if ( credential . getSource ( ) != null && credential . getSourceType ( ) != null ) { fideliusService . putCredentialWithMetadata ( credential . getShortKey ( ) , credential . getSecret ( ) , credential . getApplication ( ) , credential . getEnvironment ( ) , credential . getComponent ( ) , credential . getSource ( ) , credential . getSourceType ( ) , tableName , user , kmsKey ) ; } else { fideliusService . putCredential ( credential . getShortKey ( ) , credential . getSecret ( ) , credential . getApplication ( ) , credential . getEnvironment ( ) , credential . getComponent ( ) , tableName , user , kmsKey ) ; } credential . setLastUpdatedBy ( user ) ; credential . setSecret ( null ) ; } catch ( Exception e ) { this . logger . info ( "Credential not created " + e . toString ( ) ) ; return null ; } return credential ; }
Add new Credential or Update an existing Credential
 @param credential Credential to be created
 @return Credential created
Add new Credential or Update an existing Credential @param credential Credential to be created @return Credential created