Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph
Class JaasSecurityContext

    java.lang.Object
      org.modeshape.graph.JaasSecurityContext

All Implemented Interfaces:
  SecurityContext

    @NotThreadSafe
    public class JaasSecurityContext

extends Object
implements SecurityContext

JAAS-based `security context` that provides authentication and authorization through the JAAS `login context`.

Nested Class Summary
`static class` | `JaasSecurityContext.UserPasswordCallbackHandler` A simple `callback handler` implementation that attempts to provide a user ID and password to any callbacks that it handles.

Constructor Summary
`JaasSecurityContext(LoginContext loginContext)` Creates a new JAAS security context based on the given login context.
`JaasSecurityContext(String realmName)` Create a `JaasSecurityContext` with the supplied `application configuration name`.
`JaasSecurityContext(String realmName, CallbackHandler callbackHandler)` Create a `JaasSecurityContext` with the supplied `application configuration name` and the given callback handler.
`JaasSecurityContext(String realmName, String userId, char[] password)` Create a `JaasSecurityContext` with the supplied `application configuration name` and a `JAAS callback handler` to create a new `JAAS login context` with the given user ID and password.
`JaasSecurityContext(String realmName, Subject subject)` Create a `JaasSecurityContext` with the supplied `application configuration name` and a `JAAS subject`.
`JaasSecurityContext(Subject subject)` Creates a new JAAS security context based on the user name and roles from the given subject.

Method Summary
`String` | `getUserName()` Returns the authenticated user's name
`boolean` | `hasRole(String roleName)` Returns whether the authenticated user has the given role.
`void` | `logout()` Logs the user out of the authentication mechanism.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JaasSecurityContext

    public JaasSecurityContext(String realmName)
                        throws LoginException

  Create a `JaasSecurityContext` with the supplied `application configuration name`.

  Parameters:
    `realmName` - the name of the `JAAS application configuration name` ; may not be null
  Throws:
    `IllegalArgumentException` - if the `name` is null
    `LoginException` - if there `name` is invalid (or there is no login context named "other"), or if the default callback handler JAAS property was not set or could not be loaded

### JaasSecurityContext

    public JaasSecurityContext(String realmName,
                               Subject subject)
                        throws LoginException

  Create a `JaasSecurityContext` with the supplied `application configuration name` and a `JAAS subject`.

  Parameters:
    `realmName` - the name of the `JAAS application configuration name`
    `subject` - the subject to authenticate
  Throws:
    `LoginException` - if there `name` is invalid (or there is no login context named "other"), if the default callback handler JAAS property was not set or could not be loaded, or if the `subject` is null or unknown

### JaasSecurityContext

    public JaasSecurityContext(String realmName,
                               String userId,
                               char[] password)
                        throws LoginException

  Create a `JaasSecurityContext` with the supplied `application configuration name` and a `JAAS callback handler` to create a new `JAAS login context` with the given user ID and password.

  Parameters:
    `realmName` - the name of the `JAAS application configuration name`
    `userId` - the user ID to use for authentication
    `password` - the password to use for authentication
  Throws:
    `LoginException` - if there `name` is invalid (or there is no login context named "other"), or if the `callbackHandler` is null

### JaasSecurityContext

    public JaasSecurityContext(String realmName,
                               CallbackHandler callbackHandler)
                        throws LoginException

  Create a `JaasSecurityContext` with the supplied `application configuration name` and the given callback handler.

  Parameters:
    `realmName` - the name of the `JAAS application configuration name` ; may not be null
    `callbackHandler` - the callback handler to use during the login process; may not be null
  Throws:
    `LoginException` - if there `name` is invalid (or there is no login context named "other"), or if the `callbackHandler` is null

### JaasSecurityContext

    public JaasSecurityContext(LoginContext loginContext)
                        throws LoginException

  Creates a new JAAS security context based on the given login context. If `login` has not already been invoked on the login context, this constructor will attempt to invoke it.

  Parameters:
    `loginContext` - the login context to use; may not be null
  Throws:
    `LoginException` - if the context has not already had `its login method` invoked and an error occurs attempting to invoke the login method.
  See Also:
    `LoginContext`

### JaasSecurityContext

    public JaasSecurityContext(Subject subject)

  Creates a new JAAS security context based on the user name and roles from the given subject.

  Parameters:
    `subject` - the subject to use as the provider of the user name and roles for this security context; may not be null

Method Detail

### getUserName

    public String getUserName()

  Returns the authenticated user's name

  Specified by:
    `getUserName` in interface `SecurityContext`
  Returns:
    the authenticated user's name
  See Also:
    `SecurityContext.getUserName()`

### hasRole

    public boolean hasRole(String roleName)

  Returns whether the authenticated user has the given role.

  Specified by:
    `hasRole` in interface `SecurityContext`
  Parameters:
    `roleName` - the name of the role to check
  Returns:
    true if the user has the role and is logged in; false otherwise
  See Also:
    `SecurityContext.hasRole(String)`

### logout

    public void logout()

  Logs the user out of the authentication mechanism.

  For some authentication mechanisms, this will be implemented as a no-op.

  Specified by:
    `logout` in interface `SecurityContext`
  See Also:
    `SecurityContext.logout()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.