try {
try {
int priority = AuthenticationSchemeResourceType.getAuthenticationSchemePriority(getSessionInfo(request));
defaultAuthenticationScheme = SystemDatabaseFactory.getInstance().createAuthenticationSchemeSequence(
getSessionInfo(request).getUser().getRealm().getRealmID(), name, description,
selectedModules.asArray(), true, priority);
CoreEvent evt = new ResourceChangeEvent(this, CoreEventConstants.CREATE_AUTHENTICATION_SCHEME, defaultAuthenticationScheme, getSessionInfo(request), CoreEvent.STATE_SUCCESSFUL);
int authCounter = 1;
for (Iterator i = selectedModules.iterator(); i.hasNext();) {
AuthenticationSchemeResourceType.addAuthenticationModule(evt, (String) i.next(), authCounter);
authCounter++;