UserManagement.java
001 /*
002  *  Licensed to the Apache Software Foundation (ASF) under one
003  *  or more contributor license agreements.  See the NOTICE file
004  *  distributed with this work for additional information
005  *  regarding copyright ownership.  The ASF licenses this file
006  *  to you under the Apache License, Version 2.0 (the
007  *  "License"); you may not use this file except in compliance
008  *  with the License.  You may obtain a copy of the License at
009  *
010  *    http://www.apache.org/licenses/LICENSE-2.0
011  *
012  *  Unless required by applicable law or agreed to in writing,
013  *  software distributed under the License is distributed on an
014  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015  *  KIND, either express or implied.  See the License for the
016  *  specific language governing permissions and limitations
017  *  under the License.    
018  *
019  
020  */
021 package org.apache.qpid.server.security.access.management;
022 
023 import org.apache.qpid.server.management.MBeanOperation;
024 import org.apache.qpid.server.management.MBeanOperationParameter;
025 import org.apache.qpid.server.management.MBeanAttribute;
026 import org.apache.qpid.AMQException;
027 
028 import javax.management.openmbean.TabularData;
029 import javax.management.openmbean.CompositeData;
030 import javax.management.JMException;
031 import javax.management.MBeanOperationInfo;
032 import java.io.IOException;
033 
034 public interface UserManagement
035 {
036     String TYPE = "UserManagement";
037 
038     //********** Operations *****************//
039     /**
040      * set password for user
041      *
042      @param username The username to create
043      @param password The password for the user
044      *
045      @return The result of the operation
046      */
047     @MBeanOperation(name = "setPassword", description = "Set password for user.",
048                     impact = MBeanOperationInfo.ACTION)
049     boolean setPassword(@MBeanOperationParameter(name = "username", description = "Username")String username,
050                         @MBeanOperationParameter(name = "password", description = "Password")char[] password);
051 
052     /**
053      * set rights for users with given details
054      *
055      @param username The username to create
056      @param read     The set of permission to give the new user
057      @param write    The set of permission to give the new user
058      @param admin    The set of permission to give the new user
059      *
060      @return The result of the operation
061      */
062     @MBeanOperation(name = "setRights", description = "Set access rights for user.",
063                     impact = MBeanOperationInfo.ACTION)
064     boolean setRights(@MBeanOperationParameter(name = "username", description = "Username")String username,
065                       @MBeanOperationParameter(name = "read", description = "Administration read")boolean read,
066                       @MBeanOperationParameter(name = "readAndWrite", description = "Administration write")boolean write,
067                       @MBeanOperationParameter(name = "admin", description = "Administration rights")boolean admin);
068 
069     /**
070      * Create users with given details
071      *
072      @param username The username to create
073      @param password The password for the user
074      @param read     The set of permission to give the new user
075      @param write    The set of permission to give the new user
076      @param admin    The set of permission to give the new user
077      *
078      @return The result of the operation
079      */
080     @MBeanOperation(name = "createUser", description = "Create new user from system.",
081                     impact = MBeanOperationInfo.ACTION)
082     boolean createUser(@MBeanOperationParameter(name = "username", description = "Username")String username,
083                        @MBeanOperationParameter(name = "password", description = "Password")char[] password,
084                        @MBeanOperationParameter(name = "read", description = "Administration read")boolean read,
085                        @MBeanOperationParameter(name = "readAndWrite", description = "Administration write")boolean write,
086                        @MBeanOperationParameter(name = "admin", description = "Administration rights")boolean admin);
087 
088     /**
089      * View users returns all the users that are currently available to the system.
090      *
091      @param username The user to delete
092      *
093      @return The result of the operation
094      */
095     @MBeanOperation(name = "deleteUser", description = "Delete user from system.",
096                     impact = MBeanOperationInfo.ACTION)
097     boolean deleteUser(@MBeanOperationParameter(name = "username", description = "Username")String username);
098 
099 
100     /**
101      * Reload the date from disk
102      *
103      @return The result of the operation
104      */
105     @MBeanOperation(name = "reloadData", description = "Reload the authentication file from disk.",
106                     impact = MBeanOperationInfo.ACTION)
107     boolean reloadData();
108 
109     /**
110      * View users returns all the users that are currently available to the system.
111      *
112      @return a table of users data (Username, read, write, admin)
113      */
114     @MBeanOperation(name = "viewUsers", description = "All users with access rights to the system.",
115                     impact = MBeanOperationInfo.INFO)
116     TabularData viewUsers();
117 
118 }