userManager, $id); } else if ($type === PrincipalType::GROUP) { return new GroupPrincipal($this->groupManager, $id); } else if ($type === PrincipalType::ROLE) { [$organizationProviderId, $roleId] = explode(":", $id, 2); if(!(isset($organizationProviderId) && isset($roleId))) { throw new \Exception("Invalid id format for principal of type role"); } return new RolePrincipal($this->organizationProviderManager, $organizationProviderId, $roleId); } else { throw new \Exception("invalid PrincipalType"); } } }