org.apache.jetspeed.security
Class SubjectHelper

java.lang.Object
  extended by org.apache.jetspeed.security.SubjectHelper

public class SubjectHelper
extends java.lang.Object

Subject helper.

Version:
$Id: SubjectHelper.java 726976 2008-12-16 07:15:50Z taylor $
Author:
David Sean Taylor

Constructor Summary
SubjectHelper()
           
 
Method Summary
static java.security.Principal getBestPrincipal(java.security.Principal[] principals, java.lang.Class<? extends java.security.Principal> classe)
           Returns the first matching principal of a given type.
static java.security.Principal getBestPrincipal(javax.security.auth.Subject subject, java.lang.Class<? extends java.security.Principal> classe)
           Given a subject, finds the first principal of the given classe for that subject.
static java.security.Principal getPrincipal(javax.security.auth.Subject subject, java.lang.Class<? extends java.security.Principal> classe)
           Given a subject, finds the first principal of the given classe for that subject.
static java.security.Principal getPrincipal(javax.security.auth.Subject subject, java.lang.Class<? extends java.security.Principal> classe, java.lang.String name)
           Given a subject, finds a specific principal by name of the given classe for that subject.
static java.util.List<java.security.Principal> getPrincipals(javax.security.auth.Subject subject, java.lang.Class<? extends java.security.Principal> classe)
           Given a subject, finds all principals of the given classe for that subject.
static java.util.List<JetspeedPrincipal> getPrincipals(javax.security.auth.Subject subject, java.lang.String jptName)
           Given a subject, finds all principals of the given JetspeedPrincipalType(JPT) for that subject.
static UserCredential getUserCredential(javax.security.auth.Subject subject)
           Given a subject, find the (first) UserCredential from the private credentials
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubjectHelper

public SubjectHelper()
Method Detail

getPrincipal

public static java.security.Principal getPrincipal(javax.security.auth.Subject subject,
                                                   java.lang.Class<? extends java.security.Principal> classe)

Given a subject, finds the first principal of the given classe for that subject. If a principal of the given classe is not found, null is returned.

Parameters:
subject - The subject supplying the principals.
classe - A class or interface derived from java.security.InternalPrincipal.
Returns:
The first principal matching a principal classe parameter.

getBestPrincipal

public static java.security.Principal getBestPrincipal(javax.security.auth.Subject subject,
                                                       java.lang.Class<? extends java.security.Principal> classe)

Given a subject, finds the first principal of the given classe for that subject. If a principal of the given classe is not found, then the first other principal is returned. If the list is empty, null is returned.

Parameters:
subject - The subject supplying the principals.
classe - A class or interface derived from java.security.InternalPrincipal.
Returns:
The first principal matching a principal classe parameter.

getBestPrincipal

public static java.security.Principal getBestPrincipal(java.security.Principal[] principals,
                                                       java.lang.Class<? extends java.security.Principal> classe)

Returns the first matching principal of a given type.

Parameters:
principals - The array of pricinpals
classe - The class of Principal
Returns:
The principal.

getPrincipals

public static java.util.List<java.security.Principal> getPrincipals(javax.security.auth.Subject subject,
                                                                    java.lang.Class<? extends java.security.Principal> classe)

Given a subject, finds all principals of the given classe for that subject. If no principals of the given class is not found, null is returned.

Parameters:
subject - The subject supplying the principals.
classe - A class or interface derived from java.security.InternalPrincipal.
Returns:
A List of all principals of type Principal matching a principal classe parameter.

getPrincipals

public static java.util.List<JetspeedPrincipal> getPrincipals(javax.security.auth.Subject subject,
                                                              java.lang.String jptName)

Given a subject, finds all principals of the given JetspeedPrincipalType(JPT) for that subject. If no principals of the given class is not found, null is returned.

Parameters:
subject - The subject supplying the principals.
jptName - the name of the Jetspeed Principal Type
Returns:
A List of all principals of type JetspeedPrincipal matching a JPT name parameter.

getPrincipal

public static java.security.Principal getPrincipal(javax.security.auth.Subject subject,
                                                   java.lang.Class<? extends java.security.Principal> classe,
                                                   java.lang.String name)

Given a subject, finds a specific principal by name of the given classe for that subject.

Parameters:
subject - The subject supplying the principals.
classe - A class or interface derived from java.security.InternalPrincipal.
name - the name of the principal to look for

getUserCredential

public static UserCredential getUserCredential(javax.security.auth.Subject subject)

Given a subject, find the (first) UserCredential from the private credentials

Parameters:
subject - The subject
Returns:
the UserCredential or null if not found.


Copyright © 1999-2011 The Apache Software Foundation. All Rights Reserved.