2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 import org.onap.policy.apex.examples.aadm.concepts.IMSIStatus;
22 logger.debug(subject.id + ":" + subject.taskName + " execution logic");
23 logger.debug(inFields);
25 if (inFields["IMSI"] == null) {
26 outFields["IMSI"] = 0;
29 outFields["IMSI"] = inFields["IMSI"];
32 if (outFields["IMSI"] == 0 && inFields["IMSI_IP"] != null && inFields["IMSI_IP"].equals("0")) {
34 outFields["IMSI"] = 0;
35 outFields["PROFILE"] = "none";
36 outFields["BLACKLIST_ON"] = false;
37 outFields["PROBE_ON"] = false;
41 IMSIStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]);
42 logger.debug(imsiStatus);
44 if (imsiStatus.getBlockingCount() > 1) {
45 outFields["IMSI"] = 0;
46 outFields["PROFILE"] = "none";
47 outFields["BLACKLIST_ON"] = false;
48 outFields["PROBE_ON"] = false;
53 if (imsiStatus.getBlockingCount() > 0 && imsiStatus.getBlacklistedTime() != 0) {
54 outFields["IMSI"] = 0;
55 outFields["PROFILE"] = "none";
56 outFields["BLACKLIST_ON"] = false;
57 outFields["PROBE_ON"] = false;
62 imsiStatus.incrementBlockingCount();
63 imsiStatus.setBlacklistedTime(System.currentTimeMillis());
65 logger.debug("Bocking count for IMSI: " + imsiStatus.getIMSI() + " is: " + imsiStatus.getBlockingCount());
66 getContextAlbum("IMSIStatusAlbum").put(imsiStatus.getIMSI(), imsiStatus);
68 outFields["PROFILE"] = "ServiceA";
69 outFields["BLACKLIST_ON"] = true;
70 outFields["PROBE_ON"] = false;
72 if (imsiStatus.getBlockingCount() > 1) {
73 logger.debug("POLICY SAPCPolicy - blacklisting imsi: " + outFields["IMSI"] + " permanently");
76 logger.debug("POLICY SAPCPolicy - blacklisting imsi: " + outFields["IMSI"] + " temporary for 120000 ms");