001 /*
002 * Copyright 2009 Red Hat, Inc.
003 * Red Hat licenses this file to you under the Apache License, version
004 * 2.0 (the "License"); you may not use this file except in compliance
005 * with the License. You may obtain a copy of the License at
006 * http://www.apache.org/licenses/LICENSE-2.0
007 * Unless required by applicable law or agreed to in writing, software
008 * distributed under the License is distributed on an "AS IS" BASIS,
009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
010 * implied. See the License for the specific language governing
011 * permissions and limitations under the License.
012 */
013
014 package org.hornetq.spi.core.security;
015
016 import java.util.Set;
017
018 import org.hornetq.core.security.CheckType;
019 import org.hornetq.core.security.Role;
020 import org.hornetq.core.server.HornetQComponent;
021
022 /**
023 * USe to validate whether a user has is valid to connect to the server and perform certain functions
024 * @author <a href="ataylor@redhat.com">Andy Taylor</a>
025 */
026 public interface HornetQSecurityManager extends HornetQComponent
027 {
028 /**
029 * is this a valid user.
030 * @param user the user
031 * @param password the users password
032 * @return true if a valid user
033 */
034 boolean validateUser(String user, String password);
035
036 /**
037 * is this a valid user and do they have the correct role
038 *
039 * @param user the user
040 * @param password the users password
041 * @param roles the roles the user has
042 * @param checkType the type of check to perform
043 * @return true if the user is valid and they have the correct roles
044 */
045 boolean validateUserAndRole(String user, String password, Set<Role> roles, CheckType checkType);
046
047 /**
048 * adds a new user
049 * @param user the user to add
050 * @param password theusers password
051 */
052 void addUser(String user, String password);
053
054 /**
055 * removes a user and any roles they may have.
056 * @param user the user to remove
057 */
058 void removeUser(String user);
059
060 /**
061 * adds a new role for a user.
062 * @param user the user
063 * @param role the role to add
064 */
065 void addRole(String user, String role);
066
067 /**
068 * removes a role from a user
069 * @param user the user
070 * @param role the role to remove
071 */
072 void removeRole(String user, String role);
073
074 /*
075 * set the default user for null users
076 */
077 void setDefaultUser(String username);
078 }