2 * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.aaa.shiro.realm;
10 import org.apache.shiro.realm.jdbc.JdbcRealm;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
15 * Wraps the generic <code>JdbcRealm</code> provided by Shiro. This allows for
16 * enhanced logging as well as isolation of all realms in a single package,
17 * <code>org.opendaylight.aaa.shiro.realm</code>, which enables easier import
18 * by consuming servlets. JdbcRealm allows integration of AAA with a generic
19 * JDBC-supporting data source. This can ease deployment with existing OSS
22 * To enabled the <code>ODLJdbcRealm</code>, modify the realms declaration in
23 * <code>etc/shiro.ini</code> as follows:
25 * ds = com.mysql.jdbc.Driver
26 * ds.serverName = localhost
28 * ds.password = password
29 * ds.databaseName = db_name
30 * jdbcRealm = org.opendaylight.aaa.shiro.realm.ODLJdbcRealm
31 * jdbcRealm.dataSource = $ds
32 * jdbcRealm.authenticationQuery = "SELECT password FROM users WHERE user_name = ?"
33 * jdbcRealm.userRolesQuery = "SELECT role_name FROM user_rolesWHERE user_name = ?"
35 * securityManager.realms = $tokenAuthRealm, $jdbcRealm
37 * Note that the values you use for these fields will likely differ from the
38 * ones provided above based on your particular deployment scenario.
40 * @author Ryan Goulding (ryandgoulding@gmail.com)
42 public class ODLJdbcRealm extends JdbcRealm {
44 private static final Logger LOG = LoggerFactory.getLogger(ODLJdbcRealm.class);
46 public ODLJdbcRealm() {
47 LOG.debug("Creating an instance of ODLJdbcRealm to use with AAA");