Merge "HostTracker Bundle Separation"
[controller.git] / opendaylight / usermanager / src / main / java / org / opendaylight / controller / usermanager / internal / AuthorizationConfig.java
1 /*
2  * Copyright (c) 2013 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
9 package org.opendaylight.controller.usermanager.internal;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14 import org.opendaylight.controller.sal.utils.Status;
15
16 /**
17  * Configuration Java Object which represents a Local configured Authorization
18  * for a remote authenticated user for User Manager.
19  */
20 public class AuthorizationConfig extends UserConfig {
21     private static final long serialVersionUID = 1L;
22
23     public AuthorizationConfig() {
24         super();
25     }
26
27     // Constructor may be needed for autocontainer logic
28     public AuthorizationConfig(String user, List<String> roles) {
29         super();
30         this.user = user;
31         this.roles = (roles == null) ? new ArrayList<String>()
32                 : new ArrayList<String>(roles);
33     }
34
35     @Override
36     public Status validate() {
37         Status status = validateUsername();
38         if (status.isSuccess()) {
39             status = validateRoles();
40         }
41         return status;
42     }
43
44     public String toString() {
45         return "AuthorizationConfig=[user: " + user + ", roles: " + roles + "]";
46     }
47 }