public class AllowedPeerConfiguration extends Object
Container for configuration, in the "config + factory" pattern that DropWizard likes
This configuration can behave in a couple different ways, depending on what properties are set:
users="bob;alice" and passwords="foo;bar" then
the list of allowed peers would contain "user bob with password foo" and "user alice with password bar"If a cachePolicy is set, then the Authenticator that is registered with Jersey upon calling registerAuthenticator
will be a CachingAuthenticator. Otherwise, it'll be an instance of AllowedPeerAuthenticator
| Constructor and Description |
|---|
AllowedPeerConfiguration() |
| Modifier and Type | Method and Description |
|---|---|
io.dropwizard.auth.Authenticator<io.dropwizard.auth.basic.BasicCredentials,Peer> |
createAuthenticator()
If a credentialFile is provided, this method will use that file to populate the list of Peers the Authenticator
checks during request processing.
|
io.dropwizard.auth.CachingAuthenticator<io.dropwizard.auth.basic.BasicCredentials,Peer> |
createCachingAuthenticator(com.codahale.metrics.MetricRegistry metrics) |
com.google.common.cache.CacheBuilderSpec |
getCachePolicy() |
String |
getCredentialFile() |
String |
getDelimiter() |
String |
getPasswords() |
String |
getRealm() |
String |
getUsers() |
void |
registerAuthenticator(io.dropwizard.setup.Environment environment)
This method registers the authenticator configured in this Configuration class with Jersey.
|
void |
setCachePolicy(com.google.common.cache.CacheBuilderSpec cachePolicy) |
void |
setCredentialFile(String credentialFile) |
void |
setDelimiter(String delimiter) |
void |
setPasswords(String passwords) |
void |
setRealm(String realm) |
void |
setUsers(String users) |
public String getRealm()
public void setRealm(String realm)
realm - BasicAuth Realm (name not really important; just needed for response
http://tools.ietf.org/html/rfc2617#section-3.2.1). If not set, it defaults to "peers"public String getCredentialFile()
public void setCredentialFile(String credentialFile)
credentialFile - The classpath-relative name of a properties file holding (user=password) pairs that will count as
authorized users of your service. Example value "peers/allowed-peers.properties".public com.google.common.cache.CacheBuilderSpec getCachePolicy()
public void setCachePolicy(com.google.common.cache.CacheBuilderSpec cachePolicy)
cachePolicy - A String conforming to Guava's CacheBuilderSpec that is used if/when returning a CachingAuthenticator.public String getUsers()
public void setUsers(String users)
users - A delimiter-separated list of users who are authorized peers of your Dropwizard service.public String getPasswords()
users. There must be 1 password for each
userpublic void setPasswords(String passwords)
passwords - A delimiter-separated list of passwords associated to the users. There must be 1 password for
each userpublic String getDelimiter()
users and passwords strings.
This defaults to the semi-colon (";")public void setDelimiter(String delimiter)
delimiter - The string that separates each user and each password in the users and passwords
strings. This defaults to the semi-colon (";")public io.dropwizard.auth.Authenticator<io.dropwizard.auth.basic.BasicCredentials,Peer> createAuthenticator()
If a credentialFile is provided, this method will use that file to populate the list of Peers the Authenticator checks during request processing. If instead the "users" and "passwords" Strings are provided, this method will use those to populate the list of Peers.
public io.dropwizard.auth.CachingAuthenticator<io.dropwizard.auth.basic.BasicCredentials,Peer> createCachingAuthenticator(com.codahale.metrics.MetricRegistry metrics)
metrics - A metrics registrycreateAuthenticator directly, but wrapped in the Dropwizard
CachingAuthenticator proxy with this configuration object's cachePolicy applied to it.public void registerAuthenticator(io.dropwizard.setup.Environment environment)
environment - A DropWizard environmentCopyright © 2015. All rights reserved.