public abstract class RealmBase extends Object implements Lifecycle, Realm, MBeanRegistration
Modifier and Type | Class and Description |
---|---|
protected static class |
RealmBase.AllRolesMode |
Modifier and Type | Field and Description |
---|---|
protected RealmBase.AllRolesMode |
allRolesMode
The all role mode.
|
protected Container |
container
The Container with which this Realm is associated.
|
protected org.jboss.logging.Logger |
containerLog
Container log
|
protected ObjectName |
controller |
protected String |
digest
Digest algorithm used in storing passwords in a non-plaintext format.
|
protected String |
digestEncoding
The encoding charset for the digest.
|
protected String |
domain |
protected String |
host |
protected static String |
info
Descriptive information about this Realm implementation.
|
protected boolean |
initialized |
protected LifecycleSupport |
lifecycle
The lifecycle event support for this component.
|
protected MessageDigest |
md
The MessageDigest object for digesting user credentials (passwords).
|
protected static MD5Encoder |
md5Encoder
The MD5 helper object for this class.
|
protected static MessageDigest |
md5Helper
MD5 message digest provider.
|
protected MBeanServer |
mserver |
protected ObjectName |
oname |
protected String |
path |
protected String |
realmPath |
protected boolean |
started
Has this component been started?
|
protected PropertyChangeSupport |
support
The property change support for this component.
|
protected String |
type |
protected boolean |
validate
Should we validate client certificate chains when they are presented?
|
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
Constructor and Description |
---|
RealmBase() |
Modifier and Type | Method and Description |
---|---|
void |
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.
|
Principal |
authenticate(String username,
byte[] credentials)
Return the Principal associated with the specified username and
credentials, if there is one; otherwise return
null . |
Principal |
authenticate(String username,
String credentials)
Return the Principal associated with the specified username and
credentials, if there is one; otherwise return
null . |
Principal |
authenticate(String username,
String clientDigest,
String nOnce,
String nc,
String cnonce,
String qop,
String realm,
String md5a2)
Return the Principal associated with the specified username, which
matches the digest calculated using the given parameters using the
method described in RFC 2069; otherwise return
null . |
Principal |
authenticate(X509Certificate[] certs)
Return the Principal associated with the specified chain of X509
client certificates.
|
void |
backgroundProcess()
Execute a periodic task, such as reloading, etc.
|
void |
destroy() |
protected String |
digest(String credentials)
Digest the password using the specified algorithm and
convert the result to a corresponding hexadecimal string.
|
static String |
Digest(String credentials,
String algorithm,
String encoding)
Digest password using the algorithm especificied and
convert the result to a corresponding hex string.
|
LifecycleListener[] |
findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle.
|
SecurityConstraint[] |
findSecurityConstraints(Request request,
Context context)
Return the SecurityConstraints configured to guard the request URI for
this request, or
null if there is no such constraint. |
String |
getAllRolesMode()
Return the all roles mode.
|
Container |
getContainer()
Return the Container with which this Realm has been associated.
|
ObjectName |
getController() |
String |
getDigest()
Return the digest algorithm used for storing credentials.
|
protected String |
getDigest(String username,
String realmName)
Return the digest associated with given principal's user name.
|
String |
getDigestEncoding()
Returns the digest encoding charset.
|
String |
getDomain() |
String |
getInfo()
Return descriptive information about this Realm implementation and
the corresponding version number, in the format
<description>/<version> . |
protected abstract String |
getName()
Return a short name for this Realm implementation, for use in
log messages.
|
ObjectName |
getObjectName() |
protected abstract String |
getPassword(String username)
Return the password associated with the given principal's user name.
|
protected abstract Principal |
getPrincipal(String username)
Return the Principal associated with the given user name.
|
protected Principal |
getPrincipal(X509Certificate usercert)
Return the Principal associated with the given certificate.
|
String |
getRealmPath() |
protected String |
getRealmSuffix() |
protected Server |
getServer()
Return the Server object that is the ultimate parent for the container
with which this Realm is associated.
|
String |
getType() |
boolean |
getValidate()
Return the "validate certificate chains" flag.
|
protected boolean |
hasMessageDigest() |
boolean |
hasResourcePermission(Request request,
Response response,
SecurityConstraint[] constraints,
Context context)
Perform access control based on the specified authorization constraint.
|
boolean |
hasRole(Principal principal,
String role)
Return
true if the specified Principal has the specified
security role, within the context of this Realm; otherwise return
false . |
boolean |
hasUserDataPermission(Request request,
Response response,
SecurityConstraint[] constraints)
Enforce any user data constraint required by the security constraint
guarding this request URI.
|
void |
init() |
static void |
main(String[] args)
Digest password using the algorithm especificied and
convert the result to a corresponding hex string.
|
void |
postDeregister() |
void |
postRegister(Boolean registrationDone) |
void |
preDeregister() |
ObjectName |
preRegister(MBeanServer server,
ObjectName name) |
void |
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.
|
void |
setAllRolesMode(String allRolesMode)
Set the all roles mode.
|
void |
setContainer(Container container)
Set the Container with which this Realm has been associated.
|
void |
setController(ObjectName controller) |
void |
setDigest(String digest)
Set the digest algorithm used for storing credentials.
|
void |
setDigestEncoding(String charset)
Sets the digest encoding charset.
|
void |
setRealmPath(String theRealmPath) |
void |
setValidate(boolean validate)
Set the "validate certificate chains" flag.
|
void |
start()
Prepare for the beginning of active use of the public methods of this
component.
|
void |
stop()
Gracefully terminate the active use of the public methods of this
component.
|
protected Container container
protected org.jboss.logging.Logger containerLog
protected String digest
null
if no digesting should
be performed.protected String digestEncoding
protected static final String info
protected LifecycleSupport lifecycle
protected MessageDigest md
protected static final MD5Encoder md5Encoder
protected static MessageDigest md5Helper
protected boolean started
protected PropertyChangeSupport support
protected boolean validate
protected RealmBase.AllRolesMode allRolesMode
protected String type
protected String domain
protected String host
protected String path
protected String realmPath
protected ObjectName oname
protected ObjectName controller
protected MBeanServer mserver
protected boolean initialized
public Container getContainer()
getContainer
in interface Realm
public void setContainer(Container container)
setContainer
in interface Realm
container
- The associated Containerpublic String getAllRolesMode()
public void setAllRolesMode(String allRolesMode)
public String getDigest()
public void setDigest(String digest)
digest
- The new digest algorithmpublic String getDigestEncoding()
public void setDigestEncoding(String charset)
charset
- The charset (null for platform default)public String getInfo()
<description>/<version>
.public boolean getValidate()
public void setValidate(boolean validate)
validate
- The new validate certificate chains flagpublic void addPropertyChangeListener(PropertyChangeListener listener)
addPropertyChangeListener
in interface Realm
listener
- The listener to addpublic Principal authenticate(String username, String credentials)
null
.authenticate
in interface Realm
username
- Username of the Principal to look upcredentials
- Password or other credentials to use in
authenticating this usernamepublic Principal authenticate(String username, byte[] credentials)
null
.authenticate
in interface Realm
username
- Username of the Principal to look upcredentials
- Password or other credentials to use in
authenticating this usernamepublic Principal authenticate(String username, String clientDigest, String nOnce, String nc, String cnonce, String qop, String realm, String md5a2)
null
.authenticate
in interface Realm
username
- Username of the Principal to look upclientDigest
- Digest which has been submitted by the clientnOnce
- Unique (or supposedly unique) token which has been used
for this requestrealm
- Realm namemd5a2
- Second MD5 digest used to calculate the digest :
MD5(Method + ":" + uri)public Principal authenticate(X509Certificate[] certs)
null
.authenticate
in interface Realm
certs
- Array of client certificates, with the first one in
the array being the certificate of the client itself.public void backgroundProcess()
backgroundProcess
in interface Realm
public SecurityConstraint[] findSecurityConstraints(Request request, Context context)
null
if there is no such constraint.findSecurityConstraints
in interface Realm
request
- Request we are processingcontext
- Context the Request is mapped topublic boolean hasResourcePermission(Request request, Response response, SecurityConstraint[] constraints, Context context) throws IOException
true
if this constraint is satisfied and processing
should continue, or false
otherwise.hasResourcePermission
in interface Realm
request
- Request we are processingresponse
- Response we are creatingconstraints
- Security constraint we are enforcingcontext
- The Context to which client of this class is attached.IOException
- if an input/output error occurspublic boolean hasRole(Principal principal, String role)
true
if the specified Principal has the specified
security role, within the context of this Realm; otherwise return
false
. This method can be overridden by Realm
implementations, but the default is adequate when an instance of
GenericPrincipal
is used to represent authenticated
Principals from this Realm.public boolean hasUserDataPermission(Request request, Response response, SecurityConstraint[] constraints) throws IOException
true
if this constraint
was not violated and processing should continue, or false
if we have created a response already.hasUserDataPermission
in interface Realm
request
- Request we are processingresponse
- Response we are creatingconstraints
- Security constraint being checkedIOException
- if an input/output error occurspublic void removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener
in interface Realm
listener
- The listener to removepublic void addLifecycleListener(LifecycleListener listener)
addLifecycleListener
in interface Lifecycle
listener
- The listener to addpublic LifecycleListener[] findLifecycleListeners()
findLifecycleListeners
in interface Lifecycle
public void removeLifecycleListener(LifecycleListener listener)
removeLifecycleListener
in interface Lifecycle
listener
- The listener to removepublic void start() throws LifecycleException
start
in interface Lifecycle
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedpublic void stop() throws LifecycleException
stop
in interface Lifecycle
LifecycleException
- if this component detects a fatal error
that needs to be reportedpublic void destroy()
protected String digest(String credentials)
credentials
- Password or other credentials to use in
authenticating this usernameprotected boolean hasMessageDigest()
protected String getDigest(String username, String realmName)
protected abstract String getName()
protected abstract String getPassword(String username)
protected Principal getPrincipal(X509Certificate usercert)
protected abstract Principal getPrincipal(String username)
protected Server getServer()
null
is
returned.public static final String Digest(String credentials, String algorithm, String encoding)
credentials
- Password or other credentials to use in
authenticating this usernamealgorithm
- Algorithm used to do the digestencoding
- Character encoding of the string to digestpublic static void main(String[] args)
public ObjectName getController()
public void setController(ObjectName controller)
public ObjectName getObjectName()
public String getDomain()
public String getType()
public String getRealmPath()
public void setRealmPath(String theRealmPath)
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister
in interface MBeanRegistration
Exception
public void postRegister(Boolean registrationDone)
postRegister
in interface MBeanRegistration
public void preDeregister() throws Exception
preDeregister
in interface MBeanRegistration
Exception
public void postDeregister()
postDeregister
in interface MBeanRegistration
public void init()
protected String getRealmSuffix()
Copyright © 2014 JBoss by Red Hat. All Rights Reserved.