use of org.wso2.carbon.identity.application.common.model.DefaultAuthenticationSequence in project carbon-identity-framework by wso2.
the class DefaultAuthSeqMgtDAOImpl method doGetDefaultAuthSeq.
private DefaultAuthenticationSequence doGetDefaultAuthSeq(String sequenceName, String tenantDomain, JdbcTemplate jdbcTemplate) throws DataAccessException {
return jdbcTemplate.fetchSingleRecord(GET_DEFAULT_SEQ, (resultSet, rowNumber) -> {
DefaultAuthenticationSequence sequence = new DefaultAuthenticationSequence();
sequence.setName(resultSet.getString(1));
sequence.setDescription(resultSet.getString(2));
try {
byte[] requestBytes = resultSet.getBytes(3);
ByteArrayInputStream bais = new ByteArrayInputStream(requestBytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Object objectRead = ois.readObject();
if (objectRead instanceof LocalAndOutboundAuthenticationConfig) {
sequence.setContent((LocalAndOutboundAuthenticationConfig) objectRead);
}
} catch (IOException | ClassNotFoundException e) {
throw new SQLException("Could not get content of default authentication sequence as a " + "Blob.", e);
}
return sequence;
}, (PreparedStatement preparedStatement) -> {
preparedStatement.setString(1, sequenceName);
preparedStatement.setInt(2, getTenantID(tenantDomain));
});
}
use of org.wso2.carbon.identity.application.common.model.DefaultAuthenticationSequence 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.common.model.DefaultAuthenticationSequence 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.common.model.DefaultAuthenticationSequence in project carbon-identity-framework by wso2.
the class DefaultAuthSeqMgtServiceImpl method addDefaultAuthSeqToCache.
private void addDefaultAuthSeqToCache(DefaultAuthenticationSequence sequence, String tenantDomain) {
if (DefaultAuthSeqMgtCache.getInstance().isEnabled()) {
DefaultAuthSeqMgtCacheEntry entry = new DefaultAuthSeqMgtCacheEntry(sequence);
DefaultAuthSeqMgtCache.getInstance().addToCache(sequence.getName(), entry, tenantDomain);
if (log.isDebugEnabled()) {
log.debug("Default authentication sequence for tenant: " + tenantDomain + " is added to cache.");
}
}
}
use of org.wso2.carbon.identity.application.common.model.DefaultAuthenticationSequence 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);
}
Aggregations