Merge "Refactor frontend JS"
[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 org.opendaylight.controller.sal.utils.Status;
12
13 /**
14  * Configuration Java Object which represents a Local configured Authorization
15  * for a remote authenticated user for User Manager.
16  */
17 public class AuthorizationConfig extends UserConfig {
18     private static final long serialVersionUID = 1L;
19
20     public AuthorizationConfig() {
21         super();
22     }
23
24     // Constructor may be needed for autocontainer logic
25     public AuthorizationConfig(String user, String role) {
26         super();
27         this.user = user;
28         this.role = role;
29     }
30
31     @Override
32     public Status validate() {
33         return (!isRoleValid().isSuccess() ? isRoleValid() : isUsernameValid());
34     }
35
36     public String getRolesData() {
37         return (role.replace(",", " "));
38     }
39
40     public String toString() {
41         return "AuthorizationConfig=[user: " + user + ", role: " + role + "]";
42     }
43 }