Skip to content

Class to support extraction of credentials from a .netrc file.

Notifications You must be signed in to change notification settings

cdjones32/java-netrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-netrc parser

A simple, lightweight component to provide .netrc file parsing in Java applications. Has no dependencies, just a single parser class and Credentials POJO.

I have required this in numerous projects, both simple and complex, so I extracted it from larger libraries for simple use.

Usage

import co.cdjones.security.auth.NetrcParser;
import co.cdjones.security.auth.Credentials;

public class Test {
    public static void main(String[] args) {
        NetrcParser netrc = NetrcParser.getInstance();
        Credentials credentials = netrc.getCredentials("localhost");

        System.out.println(credentials.user());
    }
}

Getting it

The artifacts are provided by JitPack. Example usage for Gradle:

allprojects {
    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    compile "com.github.cdjones32:java-netrc:1.0.1"
}

History

1.0.1 - Fixed an issue where comments which were not at the start of a line would still be parsed.

Credits

The source for this was taken almost verbatim from the OpenSource Jenkins git-client-plugin

About

Class to support extraction of credentials from a .netrc file.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages