项目作者: burakdede

项目描述 :
Dropwizard bundle for Stormpath integration
高级语言: Java
项目地址: git://github.com/burakdede/dropwizard-stormpath.git
创建时间: 2016-03-03T15:34:08Z
项目社区:https://github.com/burakdede/dropwizard-stormpath

开源协议:Apache License 2.0

下载


Dropwizard Stormpath Bundle

dropwizard-stormpath is easy to use bundle around stormpath api for dropwizard applications.

Documentation

Setting up

Config.yaml

  1. stormpath:
  2. apiKeyId: "your api key id"
  3. apiKeySecret: "your api key secret"
  4. apiRestUrl: "your stormpath rest api url"

We need to add stormpath configuration factory to our main configuration factory

You need stormpath client factory in your main configuration factory

  1. @NotNull
  2. @Valid
  3. private StormpathClientFactory stormpathClientFactory;
  4. public ServiceConfiguration(@JsonProperty("stormpath") StormpathClientFactory stormpathClientFactory) {
  5. this.stormpathClientFactory = stormpathClientFactory;
  6. }
  7. @JsonProperty("stormpath")
  8. public StormpathClientFactory getStormpathClientFactory() {
  9. return stormpathClientFactory;
  10. }

Create stormpath bundle

On dropwizard App class create your stormpath bundle

  1. private StormpathBundle<ServiceConfiguration> stormpathBundle =
  2. new StormpathBundle<ServiceConfiguration>() {
  3. @Override
  4. public Optional<StormpathClientFactory> getStormpathClientFactory(Configuration configuration) {
  5. return Optional.fromNullable(((ServiceConfiguration) configuration).getStormpathClientFactory());
  6. }
  7. };

Register bundle

Add bundle to boostrap

  1. bootstrap.addBundle(stormpathBundle);

Use api or extend

Use or extend StormpathApi with static methods

  1. Stormpathapi.authenticate("username", "pass");

Basic Auth

Have builtin basic authenticator you can use with stormpath Account class

  1. BasicAuthFactory basicAuthFactory = new BasicAuthFactory(new BasicAuthenticator(), "HTTP AUTH", Account.class);
  2. env.jersey().register(AuthFactory.binder(basicAuthFactory));

Download

Maven dependency

  1. <dependency>
  2. <groupId>com.burakdede</groupId>
  3. <artifactId>dropwizard-stormpath</artifactId>
  4. <version>0.0.7</version>
  5. </dependency>

If above dep. fails also include bintray

  1. <repositories>
  2. <repository>
  3. <id>bintray</id>
  4. <url>https://dl.bintray.com/burakdd/maven/</url>
  5. </repository>
  6. </repositories>

License

  1. Copyright (C) Burak Dede.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.