Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.27 KB

README.md

File metadata and controls

43 lines (32 loc) · 1.27 KB

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