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

## BEA WebLogic Server 9.0 API Reference

## weblogic.security
Class SubjectUtils

    java.lang.Object
      weblogic.security.SubjectUtils

public class SubjectUtils
extends Object

This class contains utilities for managing Subjects.

  Copyright © 2005 BEA Systems, Inc. All Rights Reserved.

Constructor Summary
`SubjectUtils()`

Method Summary
`static void` | `checkSubjectNonNull(Object subject)` Throws an IllegalArgumentException if the Subject is null.
`static String` | `displaySubject(Subject subject)` Gives a detailed display of a Subject.
`static Subject` | `getAnonymousUser()` Returns an unmodifiable Subject that corresponds to an anonymous user.
`static Principal` | `getOnePrincipal(Subject subject, Class type)` Quickly return a single Principal of the specified type or return null.
`static String` | `getUsername(Subject s)` Returns a username for the specified Subject.
`static Principal` | `getUserPrincipal(Subject s)` Returns a principal for the specified Subject that represents the current user of the Web application.
`static boolean` | `isUserAnAdministrator(Subject subject)` Returns true if the Subject has Administrator privileges.
`static boolean` | `isUserAnonymous(Subject subject)` Returns true if and only if the user is the anonymous user.
`static boolean` | `isUserInGroup(weblogic.security.acl.internal.AuthenticatedSubject s, String group)` Returns true if the Subject is in the specified group.
`static boolean` | `isUserInGroup(Subject s, 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

### checkSubjectNonNull

    public static void checkSubjectNonNull(Object subject)

  Throws an IllegalArgumentException if the Subject is null.

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

### displaySubject

    public static String displaySubject(Subject subject)

  Gives a detailed display of a Subject.

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

### getAnonymousUser

    public static Subject getAnonymousUser()

  Returns an unmodifiable Subject that corresponds to an anonymous user.

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

### getOnePrincipal

    public static Principal getOnePrincipal(Subject subject,
                                            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

### getUsername

    public static String getUsername(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.

### getUserPrincipal

    public static Principal getUserPrincipal(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`

### isUserAnAdministrator

    public static boolean isUserAnAdministrator(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.

### isUserAnonymous

    public static boolean isUserAnonymous(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.

### isUserInGroup

    public static boolean isUserInGroup(weblogic.security.acl.internal.AuthenticatedSubject s,
                                        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`

### isUserInGroup

    public static boolean isUserInGroup(Subject s,
                                        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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://e-docs.bea.com/wls/docs90 Copyright 2005 BEA Systems Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD