private CredentialsProvider buildCredential( final Map<String, ?> env ) {
if ( env != null ) {
if ( env.containsKey( USER_NAME ) ) {
if ( env.containsKey( PASSWORD ) ) {
return new UsernamePasswordCredentialsProvider( env.get( USER_NAME ).toString(), env.get( PASSWORD ).toString() );
}
return new UsernamePasswordCredentialsProvider( env.get( USER_NAME ).toString(), "" );
}
}
return CredentialsProvider.getDefault();
}