org.apache.jetspeed.security.impl
Class BasePrincipalImpl

java.lang.Object
  extended by org.apache.jetspeed.security.impl.BasePrincipalImpl
All Implemented Interfaces:
java.io.Serializable, java.security.Principal, BasePrincipal
Direct Known Subclasses:
GroupPrincipalImpl, RolePrincipalImpl, UserPrincipalImpl

public abstract class BasePrincipalImpl
extends java.lang.Object
implements BasePrincipal

BasePrincipal interface implementation.

Author:
David Le Strat
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.jetspeed.security.BasePrincipal
PREFS_GROUP_ROOT, PREFS_ROLE_ROOT, PREFS_USER_ROOT
 
Constructor Summary
BasePrincipalImpl(java.lang.String name, java.lang.String prefsRoot, boolean hiearchicalNames)
           Principal constructor given a name and preferences root.
BasePrincipalImpl(java.lang.String name, java.lang.String prefsRoot, boolean hiearchicalNames, boolean isEnabled, boolean isMapping)
           
 
Method Summary
 java.lang.String getFullPath()
          Provides the principal full path prepending PREFS_{PRINCPAL}_ROOT if not prepended.
static java.lang.String getFullPathFromPrincipalName(java.lang.String name, java.lang.String prefsRoot, boolean hiearchicalNames)
           Gets the principal implementation full path from the principal name.
 java.lang.String getName()
           
static java.lang.String getPrincipalNameFromFullPath(java.lang.String fullPath, java.lang.String prefsRoot, boolean hiearchicalNames)
           Gets the principal name from the principal implementation full path.
 int hashCode()
           
 boolean isEnabled()
          Getter for the enabled state
 boolean isMapping()
          is this principal a security principal mapping or a real principal
 void setEnabled(boolean enabled)
          Setter for the enabled state
 java.lang.String toString()
           Returns a string representation of this principal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.security.Principal
equals
 

Constructor Detail

BasePrincipalImpl

public BasePrincipalImpl(java.lang.String name,
                         java.lang.String prefsRoot,
                         boolean hiearchicalNames)

Principal constructor given a name and preferences root.

Parameters:
name - The principal name.
prefsRoot - The preferences root node.

BasePrincipalImpl

public BasePrincipalImpl(java.lang.String name,
                         java.lang.String prefsRoot,
                         boolean hiearchicalNames,
                         boolean isEnabled,
                         boolean isMapping)
Method Detail

getFullPath

public java.lang.String getFullPath()
Description copied from interface: BasePrincipal

Provides the principal full path prepending PREFS_{PRINCPAL}_ROOT if not prepended.

Specified by:
getFullPath in interface BasePrincipal
Returns:
The principal full path.
See Also:
BasePrincipal.getFullPath()

getName

public java.lang.String getName()
Specified by:
getName in interface java.security.Principal
See Also:
Principal.getName()

hashCode

public int hashCode()
Specified by:
hashCode in interface java.security.Principal
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

toString

public java.lang.String toString()

Returns a string representation of this principal.

Specified by:
toString in interface java.security.Principal
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this principal.

getFullPathFromPrincipalName

public static java.lang.String getFullPathFromPrincipalName(java.lang.String name,
                                                            java.lang.String prefsRoot,
                                                            boolean hiearchicalNames)

Gets the principal implementation full path from the principal name.

Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used as the separator for hierarchical elements.

The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.

Parameters:
name - The principal name.
prefsRoot - The preferences root node.
hiearchicalNames - indicator if hierarchy encoding (replacing '.' with '/') should be done
Returns:
The preferences full path / principal name.

getPrincipalNameFromFullPath

public static java.lang.String getPrincipalNameFromFullPath(java.lang.String fullPath,
                                                            java.lang.String prefsRoot,
                                                            boolean hiearchicalNames)

Gets the principal name from the principal implementation full path.

Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used as the separator for hierarchical elements.

The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.

Parameters:
fullPath - The principal full path.
prefsRoot - The preferences root node.
hiearchicalNames - indicator if hierarchical decoding (replacing '/' with '.') should be done
Returns:
The principal name.

isEnabled

public boolean isEnabled()
Description copied from interface: BasePrincipal

Getter for the enabled state

Specified by:
isEnabled in interface BasePrincipal
Returns:
true if enabled
See Also:
BasePrincipal.isEnabled()

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: BasePrincipal
Setter for the enabled state

Specified by:
setEnabled in interface BasePrincipal
Parameters:
enabled - The enabled state
See Also:
BasePrincipal.setEnabled(boolean)

isMapping

public boolean isMapping()
Description copied from interface: BasePrincipal

is this principal a security principal mapping or a real principal

Specified by:
isMapping in interface BasePrincipal
Returns:
true if is a mapping


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