use of org.wso2.carbon.identity.application.mgt.validator.DefaultApplicationValidator in project carbon-identity-framework by wso2.
the class DefaultApplicationValidatorTest method validateAdaptiveAuthScriptTest.
@Test(dataProvider = "validateAdaptiveAuthScriptDataProvider")
public void validateAdaptiveAuthScriptTest(String isValidationFailScenario, String isLoopsAllowed, String script) throws Exception {
DefaultApplicationValidator defaultApplicationValidator = new DefaultApplicationValidator();
Field configuration = IdentityUtil.class.getDeclaredField("configuration");
configuration.setAccessible(true);
Map<String, Object> configMap = new HashMap<>();
configMap.put("AdaptiveAuth.AllowLoops", isLoopsAllowed);
configuration.set(IdentityUtil.class, configMap);
Method validateAdaptiveAuthScript = DefaultApplicationValidator.class.getDeclaredMethod("validateAdaptiveAuthScript", List.class, AuthenticationScriptConfig.class);
validateAdaptiveAuthScript.setAccessible(true);
AuthenticationScriptConfig scriptConfig = new AuthenticationScriptConfig();
scriptConfig.setContent(script);
List<String> validationErrors = new ArrayList<>();
validateAdaptiveAuthScript.invoke(defaultApplicationValidator, validationErrors, scriptConfig);
if (Boolean.parseBoolean(isValidationFailScenario)) {
Assert.assertFalse(validationErrors.isEmpty(), "This is an invalid scenario. There should be " + "validation messages.");
List<String> filtered = validationErrors.stream().filter(error -> StringUtils.containsIgnoreCase(error, "loop")).collect(Collectors.toList());
Assert.assertFalse(filtered.isEmpty(), "There should be a validation message related to loops");
} else {
Assert.assertTrue(validationErrors.isEmpty(), "There are validation messages. This is a valid case " + "there should not be any validation messages. Validation messages: " + String.join("|", validationErrors));
}
}
use of org.wso2.carbon.identity.application.mgt.validator.DefaultApplicationValidator in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceComponent method activate.
@Activate
protected void activate(ComponentContext context) {
try {
buildFileBasedSPList();
if (log.isDebugEnabled()) {
log.debug("File based SP building completed");
}
loadAuthenticationTemplates();
if (log.isDebugEnabled()) {
log.debug("Authentication templates are loaded");
}
bundleContext = context.getBundleContext();
// Registering Application management service as a OSGIService
bundleContext.registerService(ApplicationManagementService.class.getName(), ApplicationManagementServiceImpl.getInstance(), null);
bundleContext.registerService(IdentityProviderMgtListener.class.getName(), new ApplicationIdentityProviderMgtListener(), null);
ApplicationMgtSystemConfig.getInstance();
bundleContext.registerService(ApplicationMgtListener.class.getName(), new ApplicationMgtAuditLogger(), null);
bundleContext.registerService(DefaultAuthSeqMgtService.class.getName(), DefaultAuthSeqMgtServiceImpl.getInstance(), null);
// Register the DefaultApplicationResourceMgtListener.
context.getBundleContext().registerService(ApplicationResourceManagementListener.class, new DefaultApplicationResourceMgtListener(), null);
bundleContext.registerService(DiscoverableApplicationManager.class.getName(), new DiscoverableApplicationManagerImpl(), null);
bundleContext.registerService(ClaimMetadataMgtListener.class.getName(), new ApplicationClaimMgtListener(), null);
// Register the ApplicationValidator.
context.getBundleContext().registerService(ApplicationValidator.class, new DefaultApplicationValidator(), null);
if (log.isDebugEnabled()) {
log.debug("Identity ApplicationManagementComponent bundle is activated");
}
} catch (Exception e) {
log.error("Error while activating ApplicationManagementComponent bundle", e);
}
}
Aggregations