Example #1
0
def step_impl(context, nested_policy):
    policy = context.entity_manager.get_current_auth_policy()
    default_nested_policy = MethodAmountPolicy(2)
    try:
        if nested_policy == "inside":
            ConditionalGeoFencePolicy(inside=policy,
                                      outside=default_nested_policy)
        else:
            ConditionalGeoFencePolicy(inside=default_nested_policy,
                                      outside=policy)
    except Exception as e:
        context.current_exception = e
Example #2
0
def step_impl(context):
    policy = context.entity_manager.get_current_auth_policy()
    try:
        ConditionalGeoFencePolicy(inside=default_cond_geo_policy(),
                                  outside=policy.outside)
    except Exception as e:
        context.current_exception = e
Example #3
0
    def get_advanced_service_policy(self, service_id):
        """
        Retrieves a Service's Security Policy
        :param service_id: Unique Service ID
        :raise: launchkey.exceptions.ServiceNotFound - No Service could be
        found matching the input ID
        :return: ConditionalGeoFencePolicy, FactorsPolicy, MethodAmountPolicy
        or LegacyPolicy
        :raises UnknownPolicyError: in the event an unrecognized policy type
        is received
        :raises InvalidFenceType: in the event an unrecognized fence type is
        received
        """
        response = self._transport.post("{}/policy/item".format(
            self.__service_base_path[0:-1]),
                                        self._subject,
                                        service_id=str(service_id))

        policy_data = self._validate_response(response.data,
                                              ServiceSecurityPolicyValidator)

        if policy_data["type"] == "COND_GEO":
            inside = self.__process_nested_service_policy(
                policy_data["inside"])
            outside = self.__process_nested_service_policy(
                policy_data["outside"])

            policy = ConditionalGeoFencePolicy(
                inside,
                outside,
                deny_rooted_jailbroken=policy_data["deny_rooted_jailbroken"],
                deny_emulator_simulator=policy_data["deny_emulator_simulator"],
                fences=self.__generate_fence_objects_from_policy(policy_data))
        elif policy_data["type"] == "LEGACY":
            ss_policy = ServiceSecurityPolicy()
            ss_policy.set_policy(policy_data)
            policy = self.__service_security_policy_to_legacy_policy(ss_policy)
        elif policy_data["type"] == "METHOD_AMOUNT":
            policy = MethodAmountPolicy(
                deny_rooted_jailbroken=policy_data["deny_rooted_jailbroken"],
                deny_emulator_simulator=policy_data["deny_emulator_simulator"],
                fences=self.__generate_fence_objects_from_policy(policy_data),
                amount=policy_data["amount"])
        elif policy_data["type"] == "FACTORS":
            policy = FactorsPolicy(
                deny_rooted_jailbroken=policy_data["deny_rooted_jailbroken"],
                deny_emulator_simulator=policy_data["deny_emulator_simulator"],
                inherence_required="INHERENCE" in policy_data["factors"],
                knowledge_required="KNOWLEDGE" in policy_data["factors"],
                possession_required="POSSESSION" in policy_data["factors"],
                fences=self.__generate_fence_objects_from_policy(policy_data))
        else:
            raise UnknownPolicyException(
                "The Policy {0} was not a known Policy type".format(
                    policy_data["type"]))

        return policy
def step_impl(context):

    default_nested_policy = FactorsPolicy(knowledge_required=True,
                                          deny_emulator_simulator=None,
                                          deny_rooted_jailbroken=None,
                                          fences=None)

    default_cond_geo_policy = ConditionalGeoFencePolicy(
        inside=default_nested_policy,
        outside=default_nested_policy,
        fences=[TerritoryFence("US", name="test1")])

    context.entity_manager.set_current_organization_service_policy(
        default_cond_geo_policy)
    context.entity_manager.set_current_auth_policy(default_cond_geo_policy)
Example #5
0
def step_impl(context):

    default_nested_policy = FactorsPolicy(
        knowledge_required=True,
        deny_emulator_simulator=None,
        deny_rooted_jailbroken=None,
        fences=None
    )

    default_cond_geo_policy = ConditionalGeoFencePolicy(
        inside=default_nested_policy,
        outside=default_nested_policy,
        fences=[GeoCircleFence(latitude=30, longitude=30, radius=3000,
                               name="cool geofence")]
    )

    context.entity_manager.set_current_directory_service_policy(
        default_cond_geo_policy)
    context.entity_manager.set_current_auth_policy(default_cond_geo_policy)
Example #6
0
def default_cond_geo_policy():
    return ConditionalGeoFencePolicy(inside=default_factors_policy(),
                                     outside=default_factors_policy())