org.apache.jetspeed.security
Class SecurityHelper

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

public class SecurityHelper
extends Object

Security helper.

Version:
$Id: SecurityHelper.java 517121 2007-03-12 07:45:49Z ate $
Author:
David Sean Taylor

Field Summary
private static org.apache.commons.logging.Log log
           
 
Constructor Summary
SecurityHelper()
           
 
Method Summary
static void addPermissions(PermissionCollection perms, PermissionCollection permsToAdd)
           Adds a collection of permsToAdd to a collection of existing permissions.
static Principal createPrincipalFromFullPath(String fullPath)
           
static Subject createSubject(String principalName)
           Utility method to create a subject.
static Principal getBestPrincipal(Principal[] principals, Class classe)
           Returns the first matching principal of a given type.
static Principal getBestPrincipal(Subject subject, Class classe)
           Given a subject, finds the first principal of the given classe for that subject.
static org.apache.jetspeed.security.PasswordCredential getPasswordCredential(Subject subject)
           Given a subject, find the (first) PasswordCredential from the private credentials
static String getPreferencesFullPath(Principal principal)
           Utility method used to retrieve the Preferences API absolute/full path from a given principal.
static Principal getPrincipal(Subject subject, Class classe)
           Given a subject, finds the first principal of the given classe for that subject.
static List getPrincipals(Subject subject, Class classe)
           Given a subject, finds all principals of the given classe for that subject.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log
Constructor Detail

SecurityHelper

public SecurityHelper()
Method Detail

getPrincipal

public static Principal getPrincipal(Subject subject,
                                     Class 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 Principal getBestPrincipal(Subject subject,
                                         Class 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 Principal getBestPrincipal(Principal[] principals,
                                         Class classe)

Returns the first matching principal of a given type.

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

getPreferencesFullPath

public static String getPreferencesFullPath(Principal principal)

Utility method used to retrieve the Preferences API absolute/full path from a given principal.

Parameters:
principal - The principal.
Returns:
The Preferences absolute/full path.

createSubject

public static Subject createSubject(String principalName)

Utility method to create a subject.

Parameters:
principalName - The user principal name.
Returns:
The subject.

getPrincipals

public static List getPrincipals(Subject subject,
                                 Class 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.

getPasswordCredential

public static org.apache.jetspeed.security.PasswordCredential getPasswordCredential(Subject subject)

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

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

addPermissions

public static void addPermissions(PermissionCollection perms,
                                  PermissionCollection permsToAdd)

Adds a collection of permsToAdd to a collection of existing permissions.

Parameters:
perms - The existing permissions.
permsToAdd - The permissions to add.

createPrincipalFromFullPath

public static Principal createPrincipalFromFullPath(String fullPath)


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.