public static IAuthorizationPrincipal principalFromUser ( final IPerson user ) { Validate . notNull ( user , "Cannot determine an authorization principal for null user." ) ; final EntityIdentifier userEntityIdentifier = user . getEntityIdentifier ( ) ; Validate . notNull ( user , "The user object is defective: lacks entity identifier." ) ; final String userEntityKey = userEntityIdentifier . getKey ( ) ; Validate . notNull ( userEntityKey , "The user object is defective: lacks entity key." ) ; final Class userEntityType = userEntityIdentifier . getType ( ) ; Validate . notNull ( userEntityType , "The user object is defective: lacks entity type." ) ; final IAuthorizationPrincipal principal = AuthorizationServiceFacade . instance ( ) . newPrincipal ( userEntityKey , userEntityType ) ; return principal ; }
Convenience method for converting an IPerson to an IAuthorizationPrincipal .