2 * Copyright (c) 2013 Cisco 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
10 package org.opendaylight.controller.web;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14 import org.springframework.security.core.userdetails.UserDetails;
15 import org.springframework.security.core.userdetails.UserDetailsService;
16 import org.springframework.security.core.userdetails.UsernameNotFoundException;
18 import org.opendaylight.controller.sal.utils.ServiceHelper;
19 import org.opendaylight.controller.usermanager.IUserManager;
22 public class ControllerUserDetailsService implements UserDetailsService {
24 private static final Logger logger = LoggerFactory
25 .getLogger(ControllerUserDetailsService.class);
27 ControllerUserDetailsService() {
31 public UserDetails loadUserByUsername(String username)
32 throws UsernameNotFoundException {
33 return getUserManagerRef().loadUserByUsername(username);
36 private IUserManager getUserManagerRef() {
37 IUserManager userManager = (IUserManager) ServiceHelper
38 .getGlobalInstance(IUserManager.class, this);
39 if (userManager != null) {
42 logger.error("UserManager Ref is null. ");
43 throw new RuntimeException("UserManager Ref is null. ");