BUG 2302 : odl-clustering-test-app should not be part of the odl-restconf-all feature set
[controller.git] / opendaylight / adsal / karaf-tomcat-security / src / main / java / org / opendaylight / controller / karafsecurity / ControllerCustomRealm.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.karafsecurity;
9
10 import java.security.Principal;
11 import java.util.ArrayList;
12 import java.util.List;
13
14 import org.apache.catalina.realm.GenericPrincipal;
15 import org.apache.catalina.realm.RealmBase;
16
17 public class ControllerCustomRealm  extends RealmBase {
18
19     private static final String name = "ControllerCustomRealm";
20
21     @Override
22     protected String getName() {
23         return name;
24     }
25
26     @Override
27     protected String getPassword(String username) {
28         return "admin";
29     }
30
31     @Override
32     protected Principal getPrincipal(String username) {
33         List<String> controllerRoles = new ArrayList<String>();
34         controllerRoles.add("System-Admin");
35         return new GenericPrincipal(username, "", controllerRoles);
36     }
37
38     @Override
39     public Principal authenticate(String username, String credentials) {
40         return this.getPrincipal(username);
41     }
42 }