View | Details | Raw Unified | Return to bug 60202
Collapse All | Expand All

(-)java/org/apache/catalina/Realm.java (+9 lines)
Lines 231-234 Link Here
231
     * @return principal roles
231
     * @return principal roles
232
     */
232
     */
233
    public String[] getRoles(Principal principal);
233
    public String[] getRoles(Principal principal);
234
235
236
    /**
237
     * Return the availability of the realm for authentication.
238
     * @return <code>true</code> if the realm is able to perform authentication
239
     */
240
    default public boolean isAvailable() {
241
        return true;
242
    }
234
}
243
}
(-)java/org/apache/catalina/realm/CombinedRealm.java (+11 lines)
Lines 418-421 Link Here
418
        throw uoe;
418
        throw uoe;
419
    }
419
    }
420
420
421
422
    @Override
423
    public boolean isAvailable() {
424
        for (Realm realm : realms) {
425
            if (!realm.isAvailable()) {
426
                return false;
427
            }
428
        }
429
        return true;
430
    }
431
421
}
432
}
(-)java/org/apache/catalina/realm/JNDIRealm.java (+6 lines)
Lines 2379-2384 Link Here
2379
2379
2380
    }
2380
    }
2381
2381
2382
    @Override
2383
    public boolean isAvailable() {
2384
        // Simple best effort check
2385
        return (context != null);
2386
    }
2387
2382
    private DirContext createDirContext(Hashtable<String, String> env) throws NamingException {
2388
    private DirContext createDirContext(Hashtable<String, String> env) throws NamingException {
2383
        if (useStartTls) {
2389
        if (useStartTls) {
2384
            return createTlsDirContext(env);
2390
            return createTlsDirContext(env);
(-)java/org/apache/catalina/realm/DataSourceRealm.java (-1 / +15 lines)
Lines 107-112 Link Here
107
    protected String userTable = null;
107
    protected String userTable = null;
108
108
109
109
110
    /**
111
     * Last connection attempt.
112
     */
113
    private volatile boolean connectionSuccess = true;
114
115
110
    // ------------------------------------------------------------- Properties
116
    // ------------------------------------------------------------- Properties
111
117
112
118
Lines 270-275 Link Here
270
    }
276
    }
271
277
272
278
279
    @Override
280
    public boolean isAvailable() {
281
        return connectionSuccess;
282
    }
283
273
    // -------------------------------------------------------- Package Methods
284
    // -------------------------------------------------------- Package Methods
274
285
275
286
Lines 378-385 Link Here
378
                context = getServer().getGlobalNamingContext();
389
                context = getServer().getGlobalNamingContext();
379
            }
390
            }
380
            DataSource dataSource = (DataSource)context.lookup(dataSourceName);
391
            DataSource dataSource = (DataSource)context.lookup(dataSourceName);
381
        return dataSource.getConnection();
392
            Connection connection = dataSource.getConnection();
393
            connectionSuccess = true;
394
            return connection;
382
        } catch (Exception e) {
395
        } catch (Exception e) {
396
            connectionSuccess = false; 
383
            // Log the problem for posterity
397
            // Log the problem for posterity
384
            containerLog.error(sm.getString("dataSourceRealm.exception"), e);
398
            containerLog.error(sm.getString("dataSourceRealm.exception"), e);
385
        }
399
        }
(-)java/org/apache/catalina/realm/LockOutRealm.java (-1 / +1 lines)
Lines 212-218 Link Here
212
     */
212
     */
213
    private Principal filterLockedAccounts(String username, Principal authenticatedUser) {
213
    private Principal filterLockedAccounts(String username, Principal authenticatedUser) {
214
        // Register all failed authentications
214
        // Register all failed authentications
215
        if (authenticatedUser == null) {
215
        if (authenticatedUser == null && isAvailable()) {
216
            registerAuthFailure(username);
216
            registerAuthFailure(username);
217
        }
217
        }
218
218
(-)java/org/apache/catalina/realm/JDBCRealm.java (+6 lines)
Lines 414-419 Link Here
414
    }
414
    }
415
415
416
416
417
    @Override
418
    public boolean isAvailable() {
419
        return (dbConnection != null);
420
    }
421
422
417
    /**
423
    /**
418
     * Close the specified database connection.
424
     * Close the specified database connection.
419
     *
425
     *

Return to bug 60202