Giter Site home page Giter Site logo

zuul-spring-client's Introduction

Build Status

Zuul Spring Client

This project provides Spring helpers and namespaces for integrating with the web services provided by the Zuul Project.

Starting with v 1.4 of the zuul-spring-client, the namespace has been refactored to allow for PGP and PBE key configuration. The older versions will still work but do not support PGP.

Maven Dependency

<groupId>org.devnull</groupId>
<artifactId>zuul-spring-client</artifactId>
<version>1.5.1</version>

Download Jar

Simple Usage Example

context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:zuul="http://www.devnull.org/schema/zuul-spring-client"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.devnull.org/schema/zuul-spring-client http://www.devnull.org/schema/zuul-spring-client.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">


    <context:property-placeholder properties-ref="appDataConfig"/>
    <zuul:properties id="appDataConfig" config="app-data-config" environment="prod">
        <zuul:file-store/>
        <zuul:pbe-decryptor password="secret" algorithm="PBEWITHSHA256AND128BITAES-CBC-BC"/>
        <!-- or use the pgp decryptor
           <zuul:pgp-decryptor password="#{environment['GNUPGPASSWD']}" secret-key-ring="#{environment['GNUPGHOME']}/secring.gpg"/>
        -->
    </zuul:properties>
</beans>

Dynamic Configuration of Environment, etc.

Spring Profiles

Utilize spring profiles to enable configuration by profile.

    <beans profile="prod">
        <context:property-placeholder properties-ref="appDataConfig"/>
        <zuul:properties id="appDataConfig" host="zuul.acme.com" config="foo-config" environment="prod">
            <zuul:pbe-decryptor algorithm="PBEWITHSHA256AND128BITAES-CBC-BC" password="I like cake!"/>
        </zuul:properties>
    </beans>
    <beans profile="qa">
        <context:property-placeholder properties-ref="appDataConfig"/>
        <zuul:properties id="appDataConfig" host="zuul.acme.com" config="foo-config"environment="qa"/>
    </beans>
    <beans profile="dev">
        <context:property-placeholder properties-ref="appDataConfig"/>
        <zuul:properties id="appDataConfig" host="zuul.acme.com" config="foo-config" environment="dev"/>
    </beans>

Spring Expression Language

Use environment variables to read in the password and environment:

    <context:property-placeholder properties-ref="appDataConfig"/>
    <zuul:properties id="appDataConfig" config="app-data-config" environment="#{environment['ZUUL_ENVIRONMENT']}">
        <zuul:file-store/>
        <zuul:pbe-decryptor password="#{environment['ZUUL_PASSWORD']}" algorithm="PBEWITHSHA256AND128BITAES-CBC-BC"/>
    </zuul:properties>

Spring Namespace Reference

zuul:properties

Attribute Description Default Required
config Name of the configuration to render n/a true
host DNS or IP address of the zuul server localhost false
port TCP port where the server is running 80 false
context URI path to the root zuul application /zuul false
environment Which environment set to retrieve dev false
ssl Set to true if zuul endpoints are hosted via HTTPS false false
http-client-ref Reference to a custom httpcomponents http-client A default client is created by default. You can override if needed false

zuul:file-store

The zuul:file-store element is optional. It caches copies of the files (with encrypted values) to the local filesystem. If configured, it will be used as a backup strategy if the zuul web services are unavailable.

If left un-configured, the application will throw an exception upon startup if the service is not available.

Attribute Description Default Required
path File Resource to contain the cached files. Uses the java.io.tmp system property by default false

  • zuul:pbe-decryptor
Use this option if your configuration in Zuul has encrypted values from a PBE (password base encryption) key such as AES, TripleDES, etc.
Attribute Description Default Required
algorithm

Provide an encryption algorithm which matches the Zuul key. Available values:

  • PBEWITHSHA256AND128BITAES-CBC-BC (AES Bouncy Castle)
  • PBEWithSHAAnd2-KeyTripleDES-CBC (Triple DES Bouncy Castle)
  • PBEWithMD5AndTripleDES (Triple DES JCE)
  • PBEWithMD5AndDES (DES JCE)

See the following for more information:

null true
password Shared, private password used to decrypt the values null true

  • zuul:pgp-decryptor
Use this option if your configuration in Zuul has encrypted values from a PGP key.
Attribute Description Default Required
secretKeyRing File resource representing the PGP secret key ring (secring.gpg) null true
password Password used to unlock the secret key ring (if encrypted) empty false

Using Without Spring

Eventually, I'll separate out the code for a POJO client. Until then, you can utilze the decryption functionality directly from the PropertyDecryptor interfaces.

  • org.devnull.client.spring.crypto.PropertiesDecryptor
  • org.devnull.client.spring.crypto.PgpPropertiesDecryptor
  • org.devnull.client.spring.crypto.PbePropertiesDecryptor

The PbePropertiesDecryptor is really just a wrapper around Jasypt so you're probably better off just using it instead. The PgpPropertiesDecryptor may be of use to you.

License

Copyright 2012 Mike Cantrell

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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.