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 Server 8.1 API Reference

## weblogic.security
Class SubjectUtils

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

public class SubjectUtils
extends java.lang.Object

This class contains utilities for managing Subjects.

Author:
  Copyright © 2004 BEA Systems, Inc. All Rights Reserved.

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 of the Web application.
`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(weblogic.security.acl.internal.AuthenticatedSubject s, java.lang.String group)` Returns true if the Subject is in the specified group.
`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 of the Web application. This method returns a WLSUser Principal if one exists in the current user. In the case of multiple WLSUser Principals, the method returns the first in the ordering defined by the Subject.getPrincipals().iterator() method. If there are no WLSUser Principals, then the getUserPrincipal method returns the first non-WLSGroup Principal. If there are no Principals or all Principals are of type WLSGroup, this method returns null.

  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`

### isUserInGroup

    public static boolean isUserInGroup(weblogic.security.acl.internal.AuthenticatedSubject s,
                                        java.lang.String group)

  Returns true if the Subject is in the specified group.

  Parameters:
    `s` - AuthenticatedSubject to determin 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/docs81
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD