org.ff4j.test.security.DefaultAuthorisationManager Maven / Gradle / Ivy
package org.ff4j.test.security;
/*
* #%L
* ff4j-test
* %%
* Copyright (C) 2013 - 2016 FF4J
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.HashSet;
import java.util.Set;
import org.ff4j.security.AuthorizationsManager;
/**
* Helper to test {@link DefaultAuthorisationManager} interface.
*
* @author Cedrick Lunven (@clunven)
*/
public class DefaultAuthorisationManager implements AuthorizationsManager {
/** Current userName. */
private String userName;
/** All definitions. */
private Set userDef = new HashSet();
/** All definitions. */
private Set < String > allDef = new HashSet();
/**
* Constructor for manager.
*/
public DefaultAuthorisationManager() {
}
/**
* Constructor for manager.
* @param user
* user permissions
* @param all
* all permissions.
*/
public DefaultAuthorisationManager(Set user, Set all) {
this.userDef = user;
this.allDef = all;
}
/**
* Constructor for manager.
*
* @param user
* user permissions
* @param all
* all permissions.
*/
public DefaultAuthorisationManager(Set user, Set all, String userName) {
this(user, all);
this.userName = userName;
}
/** {@inheritDoc} */
public String getCurrentUserName() {
return userName;
}
/** {@inheritDoc} */
public Set getCurrentUserPermissions() {
return userDef;
}
/** {@inheritDoc} */
public void setCurrentUserPermissions(Set user) {
this.userDef = user;
}
/** {@inheritDoc} */
public Set listAllPermissions() {
return allDef;
}
/** {@inheritDoc} */
public void setAllPermissions(Set all) {
this.allDef = all;
}
/** {@inheritDoc} */
public String toJson() {
return DefaultAuthorisationManager.class.getName();
}
}