net.sf.jguard.ext.util
Class SubjectUtils

java.lang.Object
  extended by net.sf.jguard.ext.util.SubjectUtils

public class SubjectUtils
extends java.lang.Object

utility class to query against subject credentials.

Author:
Charles Gay, Maximiliano Batelli

Constructor Summary
SubjectUtils()
           
 
Method Summary
static void addCredentialValue(javax.security.auth.Subject subject, boolean publicVisibility, java.lang.String credentialId, java.lang.Object credentialValue)
          adds new credential value if it does not already exist.
static java.lang.String getCredentialValueAsString(javax.security.auth.Subject subject, boolean publicVisibility, java.lang.String credentialId)
          return credential value from the specified credential set This function assume that credential have only one value return empty string if it is not found
static java.util.Collection getCredentialValues(javax.security.auth.Subject subject, boolean publicVisibility, java.lang.String credentialId)
          return credential values from the specified credential set which are mapped to the specified credentialId.
static java.util.Collection getCredentialValues(javax.security.auth.Subject subject, java.lang.String credentialId)
          return credential values from private and public credential set which are mapped to the specified credentialId.
static java.util.Set getEnabledPrincipals(java.util.Set userPrincipals)
           
static net.sf.jguard.core.authentication.credentials.JGuardCredential getIdentityCredential(javax.security.auth.Subject subject, net.sf.jguard.core.authentication.manager.AuthenticationManager authenticationManager)
          return the {link JGuardCredential identifying uniquely the user.
static java.util.Set getJavaxSecuritySubjects(java.util.Set jguardSubjects)
           
static net.sf.jguard.core.organization.Organization getOrganization(javax.security.auth.Subject subject)
           
static javax.security.auth.Subject getSubject()
          grab the authenticated PersistedSubject in the execution stack.
static void removeCredentialValue(javax.security.auth.Subject subject, boolean publicVisibility, java.lang.String credentialId, java.lang.Object credentialValue)
          remove credential value if it already exists.
static void setCredentialValue(javax.security.auth.Subject subject, boolean publicVisibility, java.lang.String credentialId, java.lang.Object credentialValue, boolean isIdentity)
          Set credential's value, this method assume that credential have only one value If credentialId exists then the value is replaced, else the credential is created
 
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

getCredentialValues

public static java.util.Collection getCredentialValues(javax.security.auth.Subject subject,
                                                       java.lang.String credentialId)
return credential values from private and public credential set which are mapped to the specified credentialId.

Parameters:
subject -
credentialId -
Returns:
Collection of Object credential values

getCredentialValues

public static java.util.Collection getCredentialValues(javax.security.auth.Subject subject,
                                                       boolean publicVisibility,
                                                       java.lang.String credentialId)
return credential values from the specified credential set which are mapped to the specified credentialId.

Parameters:
subject -
publicVisibility - true for publicCredentials, false for private credentials.
credentialId -
Returns:
Collection of Object credential values

getOrganization

public static net.sf.jguard.core.organization.Organization getOrganization(javax.security.auth.Subject subject)

getCredentialValueAsString

public static java.lang.String getCredentialValueAsString(javax.security.auth.Subject subject,
                                                          boolean publicVisibility,
                                                          java.lang.String credentialId)
return credential value from the specified credential set This function assume that credential have only one value return empty string if it is not found

Parameters:
subject -
publicVisibility - true for publicCredentials, false for private credentials.
credentialId -
Returns:
credential value as string

setCredentialValue

public static void setCredentialValue(javax.security.auth.Subject subject,
                                      boolean publicVisibility,
                                      java.lang.String credentialId,
                                      java.lang.Object credentialValue,
                                      boolean isIdentity)
Set credential's value, this method assume that credential have only one value If credentialId exists then the value is replaced, else the credential is created

Parameters:
subject -
publicVisibility - true for publicCredentials, false for private credentials.
credentialId -
credentialValue -
isIdentity - true for identity credential, false otherwise

addCredentialValue

public static void addCredentialValue(javax.security.auth.Subject subject,
                                      boolean publicVisibility,
                                      java.lang.String credentialId,
                                      java.lang.Object credentialValue)
adds new credential value if it does not already exist. Added credential can not be an identity credential.

Parameters:
subject -
publicVisibility -
credentialId -
credentialValue -

getIdentityCredential

public static net.sf.jguard.core.authentication.credentials.JGuardCredential getIdentityCredential(javax.security.auth.Subject subject,
                                                                                                   net.sf.jguard.core.authentication.manager.AuthenticationManager authenticationManager)
return the {link JGuardCredential identifying uniquely the user.

Parameters:
subject -
template -
Returns:
Throws:
net.sf.jguard.core.authentication.AuthenticationException

removeCredentialValue

public static void removeCredentialValue(javax.security.auth.Subject subject,
                                         boolean publicVisibility,
                                         java.lang.String credentialId,
                                         java.lang.Object credentialValue)
remove credential value if it already exists. Removed credential can not be an identity credential.

Parameters:
subject -
publicVisibility -
credentialId -
credentialValue -

getEnabledPrincipals

public static java.util.Set getEnabledPrincipals(java.util.Set userPrincipals)

getSubject

public static javax.security.auth.Subject getSubject()
grab the authenticated PersistedSubject in the execution stack.

Returns:
authenticated PersistedSubject or null if user is not authenticated
Throws:
SecurityExceptionthe - caller does not have the permission to call the subject

getJavaxSecuritySubjects

public static java.util.Set getJavaxSecuritySubjects(java.util.Set jguardSubjects)


Copyright © 2004-2009. All Rights Reserved.