use of org.wso2.carbon.identity.application.mgt.defaultsequence.DefaultAuthSeqMgtException in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method setDefaultAuthenticationSeq.
private void setDefaultAuthenticationSeq(String sequenceName, String tenantDomain, ServiceProvider serviceProvider) throws IdentityApplicationManagementException {
// if "Authentication Type" is "Default", get the tenant wise default authentication sequence if
// available, otherwise the authentication sequence and adaptive script configuration in default SP
DefaultAuthSeqMgtService seqMgtService = DefaultAuthSeqMgtServiceImpl.getInstance();
DefaultAuthenticationSequence sequence;
try {
sequence = seqMgtService.getDefaultAuthenticationSeq(sequenceName, tenantDomain);
} catch (DefaultAuthSeqMgtException e) {
throw new IdentityApplicationManagementException("Error when retrieving default " + "authentication sequence in tenant: " + tenantDomain, e);
}
if (sequence != null && sequence.getContent() != null) {
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(sequence.getContent().getAuthenticationSteps());
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationScriptConfig(sequence.getContent().getAuthenticationScriptConfig());
} else {
ServiceProvider defaultSP = ApplicationManagementServiceComponent.getFileBasedSPs().get(IdentityApplicationConstants.DEFAULT_SP_CONFIG);
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(defaultSP.getLocalAndOutBoundAuthenticationConfig().getAuthenticationSteps());
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationScriptConfig(defaultSP.getLocalAndOutBoundAuthenticationConfig().getAuthenticationScriptConfig());
}
}
use of org.wso2.carbon.identity.application.mgt.defaultsequence.DefaultAuthSeqMgtException in project carbon-identity-framework by wso2.
the class DefaultAuthSeqMgtServiceImpl method doGetDefaultAuthenticationSeqInfo.
private DefaultAuthenticationSequence doGetDefaultAuthenticationSeqInfo(String sequenceName, String tenantDomain) throws DefaultAuthSeqMgtException {
DefaultAuthenticationSequence sequence = getDefaultAuthSeqFromCache(sequenceName, tenantDomain);
if (sequence == null) {
DefaultAuthSeqMgtDAO seqMgtDAO = new DefaultAuthSeqMgtDAOImpl();
sequence = seqMgtDAO.getDefaultAuthenticationSeqInfo(sequenceName, tenantDomain);
}
return sequence;
}
use of org.wso2.carbon.identity.application.mgt.defaultsequence.DefaultAuthSeqMgtException in project carbon-identity-framework by wso2.
the class DefaultAuthSeqMgtServiceImpl method validateAuthSeqConfiguration.
private void validateAuthSeqConfiguration(DefaultAuthenticationSequence sequence, String tenantDomain, String errorMsg) throws DefaultAuthSeqMgtException {
List<String> validationMsg = new ArrayList<>();
LocalAndOutboundAuthenticationConfig authenticationConfig = sequence.getContent();
if (authenticationConfig == null) {
return;
}
AuthenticationStep[] authenticationSteps = authenticationConfig.getAuthenticationSteps();
if (authenticationSteps == null || authenticationSteps.length == 0) {
return;
}
Map<String, Property[]> allLocalAuthenticators;
try {
allLocalAuthenticators = getAllLocalAuthenticators(tenantDomain);
} catch (IdentityApplicationManagementException e) {
throw new DefaultAuthSeqMgtServerException(errorMsg, e);
}
AtomicBoolean isAuthenticatorIncluded = new AtomicBoolean(false);
for (AuthenticationStep authenticationStep : authenticationSteps) {
if (authenticationStep == null || (authenticationStep.getFederatedIdentityProviders() == null && authenticationStep.getLocalAuthenticatorConfigs() == null)) {
validationMsg.add("Some authentication steps do not have authenticators.");
break;
}
for (IdentityProvider idp : authenticationStep.getFederatedIdentityProviders()) {
validateFederatedIdp(idp, isAuthenticatorIncluded, validationMsg, tenantDomain);
}
validateLocalAuthenticatorConfig(validationMsg, allLocalAuthenticators, isAuthenticatorIncluded, authenticationStep);
}
if (!isAuthenticatorIncluded.get()) {
validationMsg.add("No authenticator have been registered in the authentication flow.");
}
if (!validationMsg.isEmpty()) {
log.error(errorMsg + tenantDomain);
for (String msg : validationMsg) {
log.error(msg);
}
throw new DefaultAuthSeqMgtException(validationMsg.toArray(new String[0]));
}
removeUnsupportedConfigurations(authenticationConfig);
}
use of org.wso2.carbon.identity.application.mgt.defaultsequence.DefaultAuthSeqMgtException in project carbon-identity-framework by wso2.
the class DefaultAuthSeqMgtServiceImpl method doGetDefaultAuthSeq.
private DefaultAuthenticationSequence doGetDefaultAuthSeq(String sequenceName, String tenantDomain) throws DefaultAuthSeqMgtException {
if (DefaultAuthSeqMgtCache.getInstance().isEnabled()) {
DefaultAuthSeqMgtCacheEntry entry = DefaultAuthSeqMgtCache.getInstance().getValueFromCache(sequenceName, tenantDomain);
if (entry != null) {
if (log.isDebugEnabled()) {
log.debug("Default authentication sequence of tenant: " + tenantDomain + " is retrieved from cache.");
}
return entry.getSequence();
}
}
DefaultAuthSeqMgtDAO seqMgtDAO = new DefaultAuthSeqMgtDAOImpl();
DefaultAuthenticationSequence sequence = seqMgtDAO.getDefaultAuthenticationSeq(sequenceName, tenantDomain);
if (sequence != null) {
addDefaultAuthSeqToCache(sequence, tenantDomain);
}
return sequence;
}
use of org.wso2.carbon.identity.application.mgt.defaultsequence.DefaultAuthSeqMgtException in project carbon-identity-framework by wso2.
the class DefaultAuthSeqMgtServiceImpl method unmarshalDefaultAuthSeq.
/**
* Convert xml file of default authentication sequence to object.
*
* @param defaultAuthSeq xml string of the default authentication sequence
* @param tenantDomain tenant domain name
* @return LocalAndOutboundAuthenticationConfig instance
* @throws DefaultAuthSeqMgtException Auth Sequence Management Client Exception
*/
private LocalAndOutboundAuthenticationConfig unmarshalDefaultAuthSeq(String defaultAuthSeq, String tenantDomain) throws DefaultAuthSeqMgtException {
if (StringUtils.isEmpty(defaultAuthSeq)) {
throw new DefaultAuthSeqMgtException(new String[] { "Empty default authentication sequence " + "configuration is provided" });
}
try {
JAXBContext jaxbContext = JAXBContext.newInstance(LocalAndOutboundAuthenticationConfig.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
JAXBElement<LocalAndOutboundAuthenticationConfig> root = unmarshaller.unmarshal(new StreamSource(new ByteArrayInputStream(defaultAuthSeq.getBytes(StandardCharsets.UTF_8))), LocalAndOutboundAuthenticationConfig.class);
if (root.getName().getLocalPart().equalsIgnoreCase(LocalAndOutboundAuthenticationConfig.class.getSimpleName())) {
return root.getValue();
}
throw new DefaultAuthSeqMgtException(new String[] { "Syntax error in the provided default " + "authentication sequence" });
} catch (JAXBException e) {
String msg = "Error in reading default authentication sequence configuration in tenant: " + tenantDomain;
log.error(msg, e);
throw new DefaultAuthSeqMgtException(new String[] { msg });
}
}
Aggregations