Top Description Fields Constructors Methods
waffle.servlet

public Class WindowsPrincipal

extends Object
implements Principal, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.security.Principal
Known Direct Subclasses
waffle.servlet.AutoDisposableWindowsPrincipal
Imports
java.io.Serializable, java.security.Principal, java.util.ArrayList, .HashMap, .List, .Map, waffle.windows.auth.IWindowsAccount, .IWindowsIdentity, .PrincipalFormat, .WindowsAccount

A Windows Principal.
Author
dblock[at]dblock[dot]org

Field Summary

Modifier and TypeField and Description
private final String
fqn

The fqn.

private final Map<String, WindowsAccount>
groups

The groups.

private transient IWindowsIdentity
identity

The identity.

private final List<String>
roles

The roles.

private static final long
serialVersionUID

The Constant serialVersionUID.

private final byte[]
sid

The sid.

private final String
sidString

The sid string.

Constructor Summary

AccessConstructor and Description
public
WindowsPrincipal(final IWindowsIdentity
Windows identity.
windowsIdentity
)

A windows principal.

public
WindowsPrincipal(final IWindowsIdentity
Windows identity.
windowsIdentity
,
final PrincipalFormat
Principal format.
principalFormat
,
final PrincipalFormat
Role format.
roleFormat
)

A windows principal.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
Principal to compare with.
o
)

Overrides java.lang.Object.equals.

Implements java.security.Principal.equals.

Compares this Principal to the specified object.
private static Map<String, WindowsAccount>

Returns:

the groups
getGroups
(final IWindowsAccount[]
the groups
groups
)

Gets the groups.

public Map<String, WindowsAccount>

Returns:

A map of group names to groups.
getGroups
()

Windows groups that the user is a member of.

public IWindowsIdentity

Returns:

String.
getIdentity
()

Underlying identity.

public String

Returns:

String.
getName
()

Implements java.security.Principal.getName.

Fully qualified name.
private static List<String>

Returns:

A list of user principal objects.
getPrincipalNames
(final IWindowsIdentity
Windows identity.
windowsIdentity
,
final PrincipalFormat
Principal format.
principalFormat
)

Returns a list of user principal objects.

private static List<String>

Returns:

List of role principal objects.
getRoleNames
(final IWindowsAccount
Windows group.
group
,
final PrincipalFormat
Principal format.
principalFormat
)

Returns a list of role principal objects.

private static List<String>

Returns:

the roles
getRoles
(final IWindowsIdentity
the windows identity
windowsIdentity
,
final PrincipalFormat
the principal format
principalFormat
,
final PrincipalFormat
the role format
roleFormat
)

Gets the roles.

public String

Returns:

Role1, Role2, ...
getRolesString
()

Get an array of roles as a string.

public byte[]

Returns:

Array of bytes.
getSid
()

Byte representation of the SID.

public String

Returns:

String.
getSidString
()

String representation of the SID.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.security.Principal.hashCode.

Returns a hashcode for this Principal.
public boolean

Returns:

True if the principal has a role, false otherwise.
hasRole
(final String
Role name.
role
)

Checks whether the principal has a given role.

public String
toString()

Overrides java.lang.Object.toString.

Implements java.security.Principal.toString.

Returns a string representation of this Principal.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

fqnback to summary
private final String fqn

The fqn.

groupsback to summary
private final Map<String, WindowsAccount> groups

The groups.

identityback to summary
private transient IWindowsIdentity identity

The identity.

rolesback to summary
private final List<String> roles

The roles.

serialVersionUIDback to summary
private static final long serialVersionUID

The Constant serialVersionUID.

sidback to summary
private final byte[] sid

The sid.

sidStringback to summary
private final String sidString

The sid string.

Constructor Detail

WindowsPrincipalback to summary
public WindowsPrincipal(final IWindowsIdentity windowsIdentity)

A windows principal.

Parameters
windowsIdentity:IWindowsIdentity

Windows identity.

WindowsPrincipalback to summary
public WindowsPrincipal(final IWindowsIdentity windowsIdentity, final PrincipalFormat principalFormat, final PrincipalFormat roleFormat)

A windows principal.

Parameters
windowsIdentity:IWindowsIdentity

Windows identity.

principalFormat:PrincipalFormat

Principal format.

roleFormat:PrincipalFormat

Role format.

Method Detail

equalsback to summary
public boolean equals(final Object o)

Overrides java.lang.Object.equals.

Implements java.security.Principal.equals.

Doc from java.security.Principal.equals.

Compares this Principal to the specified object. Returns true if the object passed in matches the Principal represented by the implementation of this interface.

Parameters
o:Object

Principal to compare with.

Returns:boolean

true if the Principal passed in is the same as that encapsulated by this Principal, and false otherwise.

Annotations
@Override
getGroupsback to summary
private static Map<String, WindowsAccount> getGroups(final IWindowsAccount[] groups)

Gets the groups.

Parameters
groups:IWindowsAccount[]

the groups

Returns:Map<String, WindowsAccount>

the groups

getGroupsback to summary
public Map<String, WindowsAccount> getGroups()

Windows groups that the user is a member of.

Returns:Map<String, WindowsAccount>

A map of group names to groups.

getIdentityback to summary
public IWindowsIdentity getIdentity()

Underlying identity.

Returns:IWindowsIdentity

String.

getNameback to summary
public String getName()

Implements java.security.Principal.getName.

Fully qualified name.

Returns:String

String.

Annotations
@Override
getPrincipalNamesback to summary
private static List<String> getPrincipalNames(final IWindowsIdentity windowsIdentity, final PrincipalFormat principalFormat)

Returns a list of user principal objects.

Parameters
windowsIdentity:IWindowsIdentity

Windows identity.

principalFormat:PrincipalFormat

Principal format.

Returns:List<String>

A list of user principal objects.

getRoleNamesback to summary
private static List<String> getRoleNames(final IWindowsAccount group, final PrincipalFormat principalFormat)

Returns a list of role principal objects.

Parameters
group:IWindowsAccount

Windows group.

principalFormat:PrincipalFormat

Principal format.

Returns:List<String>

List of role principal objects.

getRolesback to summary
private static List<String> getRoles(final IWindowsIdentity windowsIdentity, final PrincipalFormat principalFormat, final PrincipalFormat roleFormat)

Gets the roles.

Parameters
windowsIdentity:IWindowsIdentity

the windows identity

principalFormat:PrincipalFormat

the principal format

roleFormat:PrincipalFormat

the role format

Returns:List<String>

the roles

getRolesStringback to summary
public String getRolesString()

Get an array of roles as a string.

Returns:String

Role1, Role2, ...

getSidback to summary
public byte[] getSid()

Byte representation of the SID.

Returns:byte[]

Array of bytes.

getSidStringback to summary
public String getSidString()

String representation of the SID.

Returns:String

String.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.security.Principal.hashCode.

Doc from java.security.Principal.hashCode.

Returns a hashcode for this Principal.

Returns:int

a hashcode for this Principal.

Annotations
@Override
hasRoleback to summary
public boolean hasRole(final String role)

Checks whether the principal has a given role.

Parameters
role:String

Role name.

Returns:boolean

True if the principal has a role, false otherwise.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements java.security.Principal.toString.

Doc from java.security.Principal.toString.

Returns a string representation of this Principal.

Returns:String

a string representation of this Principal.

Annotations
@Override