|
17 | 17 | import com.axway.apim.adapter.apis.APIFilter.Builder.APIType; |
18 | 18 | import com.axway.apim.adapter.clientApps.ClientAppFilter; |
19 | 19 | import com.axway.apim.api.API; |
| 20 | +import com.axway.apim.api.model.DeviceType; |
| 21 | +import com.axway.apim.api.model.InboundProfile; |
20 | 22 | import com.axway.apim.api.model.OutboundProfile; |
21 | 23 | import com.axway.apim.api.model.Policy; |
| 24 | +import com.axway.apim.api.model.SecurityDevice; |
| 25 | +import com.axway.apim.api.model.SecurityProfile; |
22 | 26 | import com.axway.apim.lib.errorHandling.AppException; |
| 27 | +import com.axway.apim.lib.utils.Utils; |
23 | 28 |
|
24 | 29 | public class APIFilter { |
25 | 30 |
|
@@ -435,20 +440,43 @@ public boolean filter(API api) throws AppException { |
435 | 440 | } |
436 | 441 | } |
437 | 442 | if(this.getPolicyName()!=null) { |
438 | | - Pattern pattern = Pattern.compile(this.getPolicyName().replace("*", ".*")); |
439 | | - Iterator<OutboundProfile> it = api.getOutboundProfiles().values().iterator(); |
440 | 443 | boolean requestedPolicyUsed = false; |
441 | | - while(it.hasNext()) { |
442 | | - OutboundProfile profile = it.next(); |
443 | | - for(Policy policy : profile.getAllPolices()) { |
444 | | - if(policy.getName()==null) { |
445 | | - LOG.warn("Cannot check policy: "+policy+" as policy name is empty."); |
446 | | - continue; |
| 444 | + Pattern pattern = Pattern.compile(this.getPolicyName().replace("*", ".*")); |
| 445 | + if(api.getOutboundProfiles()!=null) { |
| 446 | + Iterator<OutboundProfile> it = api.getOutboundProfiles().values().iterator(); |
| 447 | + while(it.hasNext()) { |
| 448 | + OutboundProfile profile = it.next(); |
| 449 | + for(Policy policy : profile.getAllPolices()) { |
| 450 | + if(policy.getName()==null) { |
| 451 | + LOG.warn("Cannot check policy: "+policy+" as policy name is empty."); |
| 452 | + continue; |
| 453 | + } |
| 454 | + Matcher matcher = pattern.matcher(policy.getName()); |
| 455 | + if(matcher.matches()) { |
| 456 | + requestedPolicyUsed = true; |
| 457 | + break; |
| 458 | + } |
447 | 459 | } |
448 | | - Matcher matcher = pattern.matcher(policy.getName()); |
449 | | - if(matcher.matches()) { |
450 | | - requestedPolicyUsed = true; |
451 | | - break; |
| 460 | + } |
| 461 | + } |
| 462 | + if(api.getInboundProfiles()!=null) { |
| 463 | + Iterator<InboundProfile> it = api.getInboundProfiles().values().iterator(); |
| 464 | + while(it.hasNext()) { |
| 465 | + InboundProfile profile = it.next(); |
| 466 | + if(profile.getSecurityProfile()!=null) { |
| 467 | + for(SecurityProfile securityProfile : api.getSecurityProfiles()) { |
| 468 | + if(securityProfile.getName().equals(profile.getSecurityProfile())) { |
| 469 | + for(SecurityDevice device : securityProfile.getDevices()) { |
| 470 | + if(device.getType()!=DeviceType.authPolicy) continue; |
| 471 | + String securityPolicy = device.getProperties().get("authenticationPolicy"); |
| 472 | + Matcher matcher = pattern.matcher(Utils.getExternalPolicyName(securityPolicy)); |
| 473 | + if(matcher.matches()) { |
| 474 | + requestedPolicyUsed = true; |
| 475 | + break; |
| 476 | + } |
| 477 | + } |
| 478 | + } |
| 479 | + } |
452 | 480 | } |
453 | 481 | } |
454 | 482 | } |
|
0 commit comments