Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weblogic.security
Class SubjectUtils

    java.lang.Object
      |
      +--weblogic.security.SubjectUtils

public class SubjectUtils
extends java.lang.Object

This class contains utilities for managing Subjects.

Constructor Summary
`SubjectUtils()`

Method Summary
`static void` | `checkSubjectNonNull(java.lang.Object subject)` Throws an IllegalArgumentException if the Subject is null.
`static java.lang.String` | `displaySubject(javax.security.auth.Subject subject)` Gives a detailed display of a Subject.
`static javax.security.auth.Subject` | `getAnonymousUser()` Returns an unmodifiable Subject that corresponds to an anonymous user.
`static java.security.Principal` | `getOnePrincipal(javax.security.auth.Subject subject, java.lang.Class type)` Quickly return a single Principal of the specified type or return null.
`static java.lang.String` | `getUsername(javax.security.auth.Subject s)` Returns a username for the specified Subject.
`static java.security.Principal` | `getUserPrincipal(javax.security.auth.Subject s)` Returns a principal for the specified Subject that represents the current user.
`static boolean` | `isUserAnAdministrator(javax.security.auth.Subject subject)` Returns true if the Subject has Administrator privileges.
`static boolean` | `isUserAnonymous(javax.security.auth.Subject subject)` Returns true if and only if the user is the anonymous user.
`static boolean` | `isUserInGroup(javax.security.auth.Subject s, java.lang.String group)` Returns true if the Subject is in the specified group.

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

Constructor Detail

### SubjectUtils

    public SubjectUtils()

Method Detail

### getUserPrincipal

    public static java.security.Principal getUserPrincipal(javax.security.auth.Subject s)

  Returns a principal for the specified Subject that represents the current user. This will always return a WLSUser if there is one, if not, it will return any Principal that is not a WLSGroup. If there are no Principals or all Principals are WLSGroups then this will return null.

  Note: No check is done to see if there are multiple WLSUser Principals in the Subject. The first is simply returned.

  Parameters:
    `s` - the Subject to extract the user from
  Returns:
    a Principal representing the user for the Subject or null
  See Also:
    `WLSUser`, `WLSGroup`

### getUsername

    public static java.lang.String getUsername(javax.security.auth.Subject s)

  Returns a username for the specified Subject. Simply a utility to call getUserPrincipal() then getName() on the returned Principal.

  Parameters:
    `s` - the Subject to extract the user name from.
  Returns:
    the name of the Subject or null.

### displaySubject

    public static java.lang.String displaySubject(javax.security.auth.Subject subject)

  Gives a detailed display of a Subject.

  Parameters:
    `subject` - Subject to display.
  Returns:
    detailed display of Subject.

### getOnePrincipal

    public static java.security.Principal getOnePrincipal(javax.security.auth.Subject subject,
                                                          java.lang.Class type)

  Quickly return a single Principal of the specified type or return null. This is not as functional as Subject.getPrincipal(type) but it is faster since it doesn't need to create a Set.

  Parameters:
    `subject` - Subject to search
    `type` - Principal type to search for
  Returns:
    the first Principal that matches or null if none match

### isUserInGroup

    public static boolean isUserInGroup(javax.security.auth.Subject s,
                                        java.lang.String group)

  Returns true if the Subject is in the specified group. This method knows how to handle both WLSGroup's and RealmAdapter groups as well.

  Parameters:
    `s` - Subject to determine if the user is in the group.
    `group` - name of group to compare.
  Returns:
    true if the user is in the group, false otherwise.
  See Also:
    `WLSGroup`

### getAnonymousUser

    public static javax.security.auth.Subject getAnonymousUser()

  Returns an unmodifiable Subject that corresponds to an anonymous user.

  Returns:
    the anonymous user. It is set Read Only.

### isUserAnonymous

    public static boolean isUserAnonymous(javax.security.auth.Subject subject)

  Returns true if and only if the user is the anonymous user.

  Parameters:
    `subject` - the subject.
  Returns:
    true if and only if the user is the anonymous user.

### isUserAnAdministrator

    public static boolean isUserAnAdministrator(javax.security.auth.Subject subject)

  Returns true if the Subject has Administrator privileges.

  Parameters:
    `subject` - subject to test for Administrator privileges.
  Returns:
    true if subject has Administrator privileges, false otherwise.

### checkSubjectNonNull

    public static void checkSubjectNonNull(java.lang.Object subject)

  Throws an IllegalArgumentException if the Subject is null.

  Parameters:
    `subject` - the subject to check.
  Throws:
    java.lang.IllegalArgumentException - if subject is null.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://e-docs.bea.com/wls/docs70
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 BEA Systems, Inc. All Rights Reserved.
WebLogic Server 7.0 API Reference