Giter Club home page Giter Club logo

dnc's Introduction

Distinguished Name (DN) Converter Gem Version

Travis CI Dependency Status Test Coverage Code Climate Inline docs

Convert multiple X509 DN strings into a consistent format.

Installation

Add this line to your application's Gemfile:

gem 'dnc'

And then execute:

$ bundle

Or install it yourself with:

$ gem install dnc

Usage

To create a DN instance:

require 'dnc'
dn = DN.new(dn_string: '/C=US/OU=string/O=DN/CN=Some Valid')
# Or:
dn = '/C=US/OU=string/O=DN/CN=Some Valid'.to_dn
dn = '/C=US/OU=string/O=DN/CN=Some Valid'.to_dn!

To return a consistently formatted string:

dn.to_s
#=> 'CN=SOME VALID,O=DN,OU=STRING,C=US'

This is what a basic DN object looks like:

puts dn.to_yaml
#=>
--- !ruby/object:DN
dn_string: CN=SOME VALID/O=DN/OU=STRING/C=US
original_dn: "/C=US/OU=string/O=DN/CN=Some Valid"
logger: !ruby/object:Logging::Logger
  [... snipped ...]
transformation: upcase
delimiter: "/"
cn: SOME VALID
o: DN
ou: STRING
c: US
string_order:
- cn
- l
- st
- o
- ou
- c
- street
- dc
- uid

There are multiple parameters you can pass in to modify the DN's formatting:

  • dn_string: REQUIRED The DN string you want to parse into a DN object.
  • transformation: upcase, downcase, to_s (or any valid String method).
  • delimiter: Custom delimiter, DN auto detects if possible, but this forces it.
  • string_order: DNC returns RDN elements as per LDAP specs (RFC4514), but to customize it you can send an array (of strings) to sort your .to_s results.
    The default order is: %w(cn l st o ou c street dc uid)
  • logger: Custom logger, defaults to Rails logger or Logging gem logger.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/dnc/fork )
  2. Add specs and make them pass (see 3)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

dnc's People

Contributors

stevenhaddox avatar kwauchope avatar esabelhaus avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.