[Minor] Code cleanup
This commit is contained in:
parent
d5491e4f0d
commit
461eef4b23
|
@ -1,4 +1,4 @@
|
||||||
target/
|
target/
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
.settings/
|
.settings/
|
||||||
|
|
|
@ -677,7 +677,7 @@ public class DefaultPrivilegeHandler implements PrivilegeHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create new user
|
// create new user
|
||||||
Set<String> newRoles = new HashSet<String>(currentRoles);
|
Set<String> newRoles = new HashSet<>(currentRoles);
|
||||||
newRoles.remove(roleName);
|
newRoles.remove(roleName);
|
||||||
User newUser = new User(existingUser.getUserId(), existingUser.getUsername(), existingUser.getPassword(),
|
User newUser = new User(existingUser.getUserId(), existingUser.getUsername(), existingUser.getPassword(),
|
||||||
existingUser.getFirstname(), existingUser.getLastname(), existingUser.getUserState(), newRoles,
|
existingUser.getFirstname(), existingUser.getLastname(), existingUser.getUserState(), newRoles,
|
||||||
|
@ -973,7 +973,7 @@ public class DefaultPrivilegeHandler implements PrivilegeHandler {
|
||||||
|
|
||||||
// create new set of privileges with out the to removed privilege
|
// create new set of privileges with out the to removed privilege
|
||||||
Set<String> privilegeNames = existingRole.getPrivilegeNames();
|
Set<String> privilegeNames = existingRole.getPrivilegeNames();
|
||||||
Map<String, IPrivilege> newPrivileges = new HashMap<String, IPrivilege>(privilegeNames.size() - 1);
|
Map<String, IPrivilege> newPrivileges = new HashMap<>(privilegeNames.size() - 1);
|
||||||
for (String name : privilegeNames) {
|
for (String name : privilegeNames) {
|
||||||
IPrivilege privilege = existingRole.getPrivilege(name);
|
IPrivilege privilege = existingRole.getPrivilege(name);
|
||||||
if (!privilege.getName().equals(privilegeName))
|
if (!privilege.getName().equals(privilegeName))
|
||||||
|
@ -1053,8 +1053,8 @@ public class DefaultPrivilegeHandler implements PrivilegeHandler {
|
||||||
List<Certificate> sessions = this.privilegeContextMap.values().stream().map(p -> p.getCertificate())
|
List<Certificate> sessions = this.privilegeContextMap.values().stream().map(p -> p.getCertificate())
|
||||||
.filter(c -> !c.getUserState().isSystem()).collect(Collectors.toList());
|
.filter(c -> !c.getUserState().isSystem()).collect(Collectors.toList());
|
||||||
|
|
||||||
try (OutputStream outputStream = AesCryptoHelper.wrapEncrypt(this.secretKey,
|
try (FileOutputStream fout = new FileOutputStream(this.persistSessionsPath);
|
||||||
new FileOutputStream(this.persistSessionsPath))) {
|
OutputStream outputStream = AesCryptoHelper.wrapEncrypt(this.secretKey, fout)) {
|
||||||
|
|
||||||
CertificateStubsDomWriter writer = new CertificateStubsDomWriter(sessions, outputStream);
|
CertificateStubsDomWriter writer = new CertificateStubsDomWriter(sessions, outputStream);
|
||||||
writer.write();
|
writer.write();
|
||||||
|
@ -1083,8 +1083,8 @@ public class DefaultPrivilegeHandler implements PrivilegeHandler {
|
||||||
"Sessions data file is not a file but exists at " + this.persistSessionsPath.getAbsolutePath());
|
"Sessions data file is not a file but exists at " + this.persistSessionsPath.getAbsolutePath());
|
||||||
|
|
||||||
List<CertificateStub> certificateStubs;
|
List<CertificateStub> certificateStubs;
|
||||||
try (InputStream inputStream = AesCryptoHelper.wrapDecrypt(this.secretKey,
|
try (FileInputStream fin = new FileInputStream(this.persistSessionsPath);
|
||||||
new FileInputStream(this.persistSessionsPath))) {
|
InputStream inputStream = AesCryptoHelper.wrapDecrypt(this.secretKey, fin)) {
|
||||||
|
|
||||||
CertificateStubsSaxReader reader = new CertificateStubsSaxReader(inputStream);
|
CertificateStubsSaxReader reader = new CertificateStubsSaxReader(inputStream);
|
||||||
certificateStubs = reader.read();
|
certificateStubs = reader.read();
|
||||||
|
@ -1199,8 +1199,8 @@ public class DefaultPrivilegeHandler implements PrivilegeHandler {
|
||||||
private PrivilegeContext buildPrivilegeContext(Certificate certificate, User user) {
|
private PrivilegeContext buildPrivilegeContext(Certificate certificate, User user) {
|
||||||
|
|
||||||
Set<String> userRoles = user.getRoles();
|
Set<String> userRoles = user.getRoles();
|
||||||
Map<String, IPrivilege> privileges = new HashMap<String, IPrivilege>();
|
Map<String, IPrivilege> privileges = new HashMap<>();
|
||||||
Map<String, PrivilegePolicy> policies = new HashMap<String, PrivilegePolicy>();
|
Map<String, PrivilegePolicy> policies = new HashMap<>();
|
||||||
|
|
||||||
// get a cache of the privileges and policies for this user
|
// get a cache of the privileges and policies for this user
|
||||||
for (String roleName : userRoles) {
|
for (String roleName : userRoles) {
|
||||||
|
|
|
@ -58,14 +58,14 @@ public class XmlPersistenceHandler implements PersistenceHandler {
|
||||||
@Override
|
@Override
|
||||||
public List<User> getAllUsers() {
|
public List<User> getAllUsers() {
|
||||||
synchronized (this.userMap) {
|
synchronized (this.userMap) {
|
||||||
return new LinkedList<User>(this.userMap.values());
|
return new LinkedList<>(this.userMap.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Role> getAllRoles() {
|
public List<Role> getAllRoles() {
|
||||||
synchronized (this.roleMap) {
|
synchronized (this.roleMap) {
|
||||||
return new LinkedList<Role>(this.roleMap.values());
|
return new LinkedList<>(this.roleMap.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ public class XmlPersistenceHandler implements PersistenceHandler {
|
||||||
public void initialize(Map<String, String> paramsMap) {
|
public void initialize(Map<String, String> paramsMap) {
|
||||||
|
|
||||||
// copy parameter map
|
// copy parameter map
|
||||||
this.parameterMap = Collections.unmodifiableMap(new HashMap<String, String>(paramsMap));
|
this.parameterMap = Collections.unmodifiableMap(new HashMap<>(paramsMap));
|
||||||
|
|
||||||
// get and validate base bath
|
// get and validate base bath
|
||||||
String basePath = this.parameterMap.get(XmlConstants.XML_PARAM_BASE_PATH);
|
String basePath = this.parameterMap.get(XmlConstants.XML_PARAM_BASE_PATH);
|
||||||
|
|
|
@ -77,9 +77,9 @@ public class BootstrapConfigurationHelper {
|
||||||
throw new RuntimeException("Could not create path " + pathF.getAbsolutePath());
|
throw new RuntimeException("Could not create path " + pathF.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> parameterMap = new HashMap<String, String>();
|
Map<String, String> parameterMap = new HashMap<>();
|
||||||
Map<String, String> encryptionHandlerParameterMap = new HashMap<String, String>();
|
Map<String, String> encryptionHandlerParameterMap = new HashMap<>();
|
||||||
Map<String, String> persistenceHandlerParameterMap = new HashMap<String, String>();
|
Map<String, String> persistenceHandlerParameterMap = new HashMap<>();
|
||||||
|
|
||||||
// TODO ask other questions...
|
// TODO ask other questions...
|
||||||
parameterMap.put("autoPersistOnPasswordChange", "true");
|
parameterMap.put("autoPersistOnPasswordChange", "true");
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class PasswordCreaterUI {
|
||||||
JLabel hash = new JLabel("Hash:", SwingConstants.RIGHT);
|
JLabel hash = new JLabel("Hash:", SwingConstants.RIGHT);
|
||||||
|
|
||||||
String[] digests = new String[] { "MD2", "MD5", "SHA-1", "SHA-256", "SHA-384", "SHA-512" };
|
String[] digests = new String[] { "MD2", "MD5", "SHA-1", "SHA-256", "SHA-384", "SHA-512" };
|
||||||
final JComboBox<String> digestCombo = new JComboBox<String>(digests);
|
final JComboBox<String> digestCombo = new JComboBox<>(digests);
|
||||||
digestCombo.setSelectedIndex(3);
|
digestCombo.setSelectedIndex(3);
|
||||||
final JPasswordField passwordField = new JPasswordField();
|
final JPasswordField passwordField = new JPasswordField();
|
||||||
final JTextField hashField = new JTextField(150);
|
final JTextField hashField = new JTextField(150);
|
||||||
|
|
|
@ -59,8 +59,8 @@ public class PrivilegeInitializationHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// delegate using input stream
|
// delegate using input stream
|
||||||
try {
|
try (FileInputStream fin = new FileInputStream(privilegeXmlFile)) {
|
||||||
return initializeFromXml(new FileInputStream(privilegeXmlFile));
|
return initializeFromXml(fin);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String msg = "Failed to load configuration from {0}"; //$NON-NLS-1$
|
String msg = "Failed to load configuration from {0}"; //$NON-NLS-1$
|
||||||
msg = MessageFormat.format(msg, privilegeXmlFile.getAbsolutePath());
|
msg = MessageFormat.format(msg, privilegeXmlFile.getAbsolutePath());
|
||||||
|
|
|
@ -51,8 +51,8 @@ public class PrivilegeContext {
|
||||||
Map<String, PrivilegePolicy> policies) {
|
Map<String, PrivilegePolicy> policies) {
|
||||||
this.userRep = userRep;
|
this.userRep = userRep;
|
||||||
this.certificate = certificate;
|
this.certificate = certificate;
|
||||||
this.privileges = Collections.unmodifiableMap(new HashMap<String, IPrivilege>(privileges));
|
this.privileges = Collections.unmodifiableMap(new HashMap<>(privileges));
|
||||||
this.policies = Collections.unmodifiableMap(new HashMap<String, PrivilegePolicy>(policies));
|
this.policies = Collections.unmodifiableMap(new HashMap<>(policies));
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserRep getUserRep() {
|
public UserRep getUserRep() {
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class PrivilegeContainerModel {
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
public PrivilegeContainerModel() {
|
public PrivilegeContainerModel() {
|
||||||
this.policies = new HashMap<String, Class<PrivilegePolicy>>();
|
this.policies = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -109,8 +109,8 @@ public final class PrivilegeImpl implements IPrivilege {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PrivilegeRep asPrivilegeRep() {
|
public PrivilegeRep asPrivilegeRep() {
|
||||||
return new PrivilegeRep(this.name, this.policy, this.allAllowed, new HashSet<String>(this.denyList),
|
return new PrivilegeRep(this.name, this.policy, this.allAllowed, new HashSet<>(this.denyList),
|
||||||
new HashSet<String>(this.allowList));
|
new HashSet<>(this.allowList));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -86,7 +86,7 @@ public final class Role {
|
||||||
}
|
}
|
||||||
|
|
||||||
// build privileges from rep
|
// build privileges from rep
|
||||||
Map<String, IPrivilege> privilegeMap = new HashMap<String, IPrivilege>(roleRep.getPrivileges().size());
|
Map<String, IPrivilege> privilegeMap = new HashMap<>(roleRep.getPrivileges().size());
|
||||||
for (PrivilegeRep privilege : roleRep.getPrivileges()) {
|
for (PrivilegeRep privilege : roleRep.getPrivileges()) {
|
||||||
privilegeMap.put(privilege.getName(), new PrivilegeImpl(privilege));
|
privilegeMap.put(privilege.getName(), new PrivilegeImpl(privilege));
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public final class Role {
|
||||||
* @return a {@link RoleRep} which is a representation of this object used to serialize and view on clients
|
* @return a {@link RoleRep} which is a representation of this object used to serialize and view on clients
|
||||||
*/
|
*/
|
||||||
public RoleRep asRoleRep() {
|
public RoleRep asRoleRep() {
|
||||||
List<PrivilegeRep> privileges = new ArrayList<PrivilegeRep>();
|
List<PrivilegeRep> privileges = new ArrayList<>();
|
||||||
for (Entry<String, IPrivilege> entry : this.privilegeMap.entrySet()) {
|
for (Entry<String, IPrivilege> entry : this.privilegeMap.entrySet()) {
|
||||||
privileges.add(entry.getValue().asPrivilegeRep());
|
privileges.add(entry.getValue().asPrivilegeRep());
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ public final class User {
|
||||||
if (roles == null)
|
if (roles == null)
|
||||||
this.roles = Collections.emptySet();
|
this.roles = Collections.emptySet();
|
||||||
else
|
else
|
||||||
this.roles = Collections.unmodifiableSet(new HashSet<String>(roles));
|
this.roles = Collections.unmodifiableSet(new HashSet<>(roles));
|
||||||
|
|
||||||
if (locale == null)
|
if (locale == null)
|
||||||
this.locale = Locale.getDefault();
|
this.locale = Locale.getDefault();
|
||||||
|
@ -126,7 +126,7 @@ public final class User {
|
||||||
if (propertyMap == null)
|
if (propertyMap == null)
|
||||||
this.propertyMap = Collections.emptyMap();
|
this.propertyMap = Collections.emptyMap();
|
||||||
else
|
else
|
||||||
this.propertyMap = Collections.unmodifiableMap(new HashMap<String, String>(propertyMap));
|
this.propertyMap = Collections.unmodifiableMap(new HashMap<>(propertyMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -234,7 +234,7 @@ public final class User {
|
||||||
*/
|
*/
|
||||||
public UserRep asUserRep() {
|
public UserRep asUserRep() {
|
||||||
return new UserRep(this.userId, this.username, this.firstname, this.lastname, this.userState,
|
return new UserRep(this.userId, this.username, this.firstname, this.lastname, this.userState,
|
||||||
new HashSet<String>(this.roles), this.locale, new HashMap<String, String>(this.propertyMap));
|
new HashSet<>(this.roles), this.locale, new HashMap<>(this.propertyMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,7 +32,7 @@ import ch.eitchnet.privilege.model.internal.PrivilegeContainerModel;
|
||||||
*/
|
*/
|
||||||
public class PrivilegeConfigSaxReader extends DefaultHandler {
|
public class PrivilegeConfigSaxReader extends DefaultHandler {
|
||||||
|
|
||||||
private Deque<ElementParser> buildersStack = new ArrayDeque<ElementParser>();
|
private Deque<ElementParser> buildersStack = new ArrayDeque<>();
|
||||||
|
|
||||||
private PrivilegeContainerModel containerModel;
|
private PrivilegeContainerModel containerModel;
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ public class PrivilegeConfigSaxReader extends DefaultHandler {
|
||||||
|
|
||||||
// <Parameter name="autoPersistOnPasswordChange" value="true" />
|
// <Parameter name="autoPersistOnPasswordChange" value="true" />
|
||||||
|
|
||||||
private Map<String, String> parameterMap = new HashMap<String, String>();
|
private Map<String, String> parameterMap = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class PrivilegeModelSaxReader extends DefaultHandler {
|
||||||
|
|
||||||
protected static final Logger logger = LoggerFactory.getLogger(PrivilegeModelSaxReader.class);
|
protected static final Logger logger = LoggerFactory.getLogger(PrivilegeModelSaxReader.class);
|
||||||
|
|
||||||
private Deque<ElementParser> buildersStack = new ArrayDeque<ElementParser>();
|
private Deque<ElementParser> buildersStack = new ArrayDeque<>();
|
||||||
|
|
||||||
private List<User> users;
|
private List<User> users;
|
||||||
private List<Role> roles;
|
private List<Role> roles;
|
||||||
|
@ -55,8 +55,8 @@ public class PrivilegeModelSaxReader extends DefaultHandler {
|
||||||
private boolean insideUser;
|
private boolean insideUser;
|
||||||
|
|
||||||
public PrivilegeModelSaxReader() {
|
public PrivilegeModelSaxReader() {
|
||||||
this.users = new ArrayList<User>();
|
this.users = new ArrayList<>();
|
||||||
this.roles = new ArrayList<Role>();
|
this.roles = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,7 +147,7 @@ public class PrivilegeModelSaxReader extends DefaultHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
this.privileges = new HashMap<String, IPrivilege>();
|
this.privileges = new HashMap<>();
|
||||||
|
|
||||||
this.text = null;
|
this.text = null;
|
||||||
|
|
||||||
|
@ -155,8 +155,8 @@ public class PrivilegeModelSaxReader extends DefaultHandler {
|
||||||
this.privilegeName = null;
|
this.privilegeName = null;
|
||||||
this.privilegePolicy = null;
|
this.privilegePolicy = null;
|
||||||
this.allAllowed = false;
|
this.allAllowed = false;
|
||||||
this.denyList = new HashSet<String>();
|
this.denyList = new HashSet<>();
|
||||||
this.allowList = new HashSet<String>();
|
this.allowList = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -201,8 +201,8 @@ public class PrivilegeModelSaxReader extends DefaultHandler {
|
||||||
this.privilegeName = null;
|
this.privilegeName = null;
|
||||||
this.privilegePolicy = null;
|
this.privilegePolicy = null;
|
||||||
this.allAllowed = false;
|
this.allAllowed = false;
|
||||||
this.denyList = new HashSet<String>();
|
this.denyList = new HashSet<>();
|
||||||
this.allowList = new HashSet<String>();
|
this.allowList = new HashSet<>();
|
||||||
|
|
||||||
} else if (qName.equals(XmlConstants.XML_ROLE)) {
|
} else if (qName.equals(XmlConstants.XML_ROLE)) {
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ public class PrivilegeModelSaxReader extends DefaultHandler {
|
||||||
Map<String, String> parameters;
|
Map<String, String> parameters;
|
||||||
|
|
||||||
public UserParser() {
|
public UserParser() {
|
||||||
this.userRoles = new HashSet<String>();
|
this.userRoles = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -307,7 +307,7 @@ public class PrivilegeModelSaxReader extends DefaultHandler {
|
||||||
|
|
||||||
// <Property name="organizationalUnit" value="Development" />
|
// <Property name="organizationalUnit" value="Development" />
|
||||||
|
|
||||||
public Map<String, String> parameterMap = new HashMap<String, String>();
|
public Map<String, String> parameterMap = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||||
|
|
|
@ -622,7 +622,7 @@ public class PrivilegeTest extends AbstractPrivilegeTest {
|
||||||
// testAddUserTedAsBob
|
// testAddUserTedAsBob
|
||||||
login(BOB, ArraysHelper.copyOf(PASS_BOB));
|
login(BOB, ArraysHelper.copyOf(PASS_BOB));
|
||||||
// let's add a new user ted
|
// let's add a new user ted
|
||||||
HashSet<String> roles = new HashSet<String>();
|
HashSet<String> roles = new HashSet<>();
|
||||||
roles.add(ROLE_USER);
|
roles.add(ROLE_USER);
|
||||||
userRep = new UserRep(null, TED, "Ted", "Newman", UserState.ENABLED, roles, null,
|
userRep = new UserRep(null, TED, "Ted", "Newman", UserState.ENABLED, roles, null,
|
||||||
new HashMap<String, String>());
|
new HashMap<String, String>());
|
||||||
|
@ -738,7 +738,7 @@ public class PrivilegeTest extends AbstractPrivilegeTest {
|
||||||
|
|
||||||
// let's add a new user bob
|
// let's add a new user bob
|
||||||
UserRep userRep = new UserRep(null, BOB, "Bob", "Newman", UserState.NEW,
|
UserRep userRep = new UserRep(null, BOB, "Bob", "Newman", UserState.NEW,
|
||||||
new HashSet<String>(Arrays.asList(ROLE_MY)), null, new HashMap<String, String>());
|
new HashSet<>(Arrays.asList(ROLE_MY)), null, new HashMap<String, String>());
|
||||||
Certificate certificate = this.ctx.getCertificate();
|
Certificate certificate = this.ctx.getCertificate();
|
||||||
privilegeHandler.addUser(certificate, userRep, null);
|
privilegeHandler.addUser(certificate, userRep, null);
|
||||||
logger.info("Added user " + BOB);
|
logger.info("Added user " + BOB);
|
||||||
|
|
|
@ -131,9 +131,9 @@ public class XmlTest {
|
||||||
@Test
|
@Test
|
||||||
public void canWriteConfig() {
|
public void canWriteConfig() {
|
||||||
|
|
||||||
Map<String, String> parameterMap = new HashMap<String, String>();
|
Map<String, String> parameterMap = new HashMap<>();
|
||||||
Map<String, String> encryptionHandlerParameterMap = new HashMap<String, String>();
|
Map<String, String> encryptionHandlerParameterMap = new HashMap<>();
|
||||||
Map<String, String> persistenceHandlerParameterMap = new HashMap<String, String>();
|
Map<String, String> persistenceHandlerParameterMap = new HashMap<>();
|
||||||
|
|
||||||
parameterMap.put("autoPersistOnPasswordChange", "true");
|
parameterMap.put("autoPersistOnPasswordChange", "true");
|
||||||
encryptionHandlerParameterMap.put("hashAlgorithm", "SHA-256");
|
encryptionHandlerParameterMap.put("hashAlgorithm", "SHA-256");
|
||||||
|
@ -189,7 +189,7 @@ public class XmlTest {
|
||||||
assertEquals("en_gb", admin.getLocale().toString());
|
assertEquals("en_gb", admin.getLocale().toString());
|
||||||
assertThat(admin.getRoles(), containsInAnyOrder("PrivilegeAdmin", "AppUser"));
|
assertThat(admin.getRoles(), containsInAnyOrder("PrivilegeAdmin", "AppUser"));
|
||||||
Map<String, String> properties = admin.getProperties();
|
Map<String, String> properties = admin.getProperties();
|
||||||
assertEquals(new HashSet<String>(Arrays.asList("organization", "organizationalUnit")), properties.keySet());
|
assertEquals(new HashSet<>(Arrays.asList("organization", "organizationalUnit")), properties.keySet());
|
||||||
assertEquals("eitchnet.ch", properties.get("organization"));
|
assertEquals("eitchnet.ch", properties.get("organization"));
|
||||||
assertEquals("Development", properties.get("organizationalUnit"));
|
assertEquals("Development", properties.get("organizationalUnit"));
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ public class XmlTest {
|
||||||
// AppUser
|
// AppUser
|
||||||
Role appUser = findRole("AppUser", roles);
|
Role appUser = findRole("AppUser", roles);
|
||||||
assertEquals("AppUser", appUser.getName());
|
assertEquals("AppUser", appUser.getName());
|
||||||
assertEquals(new HashSet<String>(Arrays.asList("ch.eitchnet.privilege.test.model.TestRestrictable")),
|
assertEquals(new HashSet<>(Arrays.asList("ch.eitchnet.privilege.test.model.TestRestrictable")),
|
||||||
appUser.getPrivilegeNames());
|
appUser.getPrivilegeNames());
|
||||||
|
|
||||||
IPrivilege testRestrictable = appUser.getPrivilege("ch.eitchnet.privilege.test.model.TestRestrictable");
|
IPrivilege testRestrictable = appUser.getPrivilege("ch.eitchnet.privilege.test.model.TestRestrictable");
|
||||||
|
@ -320,31 +320,31 @@ public class XmlTest {
|
||||||
Set<String> userRoles;
|
Set<String> userRoles;
|
||||||
Map<String, IPrivilege> privilegeMap;
|
Map<String, IPrivilege> privilegeMap;
|
||||||
|
|
||||||
List<User> users = new ArrayList<User>();
|
List<User> users = new ArrayList<>();
|
||||||
propertyMap = new HashMap<String, String>();
|
propertyMap = new HashMap<>();
|
||||||
propertyMap.put("prop1", "value1");
|
propertyMap.put("prop1", "value1");
|
||||||
userRoles = new HashSet<String>();
|
userRoles = new HashSet<>();
|
||||||
userRoles.add("role1");
|
userRoles.add("role1");
|
||||||
users.add(new User("1", "user1", "blabla", "Bob", "White", UserState.DISABLED, userRoles, Locale.ENGLISH,
|
users.add(new User("1", "user1", "blabla", "Bob", "White", UserState.DISABLED, userRoles, Locale.ENGLISH,
|
||||||
propertyMap));
|
propertyMap));
|
||||||
|
|
||||||
propertyMap = new HashMap<String, String>();
|
propertyMap = new HashMap<>();
|
||||||
propertyMap.put("prop2", "value2");
|
propertyMap.put("prop2", "value2");
|
||||||
userRoles = new HashSet<String>();
|
userRoles = new HashSet<>();
|
||||||
userRoles.add("role2");
|
userRoles.add("role2");
|
||||||
users.add(new User("2", "user2", "haha", "Leonard", "Sheldon", UserState.ENABLED, userRoles, Locale.ENGLISH,
|
users.add(new User("2", "user2", "haha", "Leonard", "Sheldon", UserState.ENABLED, userRoles, Locale.ENGLISH,
|
||||||
propertyMap));
|
propertyMap));
|
||||||
|
|
||||||
List<Role> roles = new ArrayList<Role>();
|
List<Role> roles = new ArrayList<>();
|
||||||
Set<String> list = Collections.emptySet();
|
Set<String> list = Collections.emptySet();
|
||||||
privilegeMap = new HashMap<String, IPrivilege>();
|
privilegeMap = new HashMap<>();
|
||||||
privilegeMap.put("priv1", new PrivilegeImpl("priv1", "DefaultPrivilege", true, list, list));
|
privilegeMap.put("priv1", new PrivilegeImpl("priv1", "DefaultPrivilege", true, list, list));
|
||||||
roles.add(new Role("role1", privilegeMap));
|
roles.add(new Role("role1", privilegeMap));
|
||||||
|
|
||||||
privilegeMap = new HashMap<String, IPrivilege>();
|
privilegeMap = new HashMap<>();
|
||||||
Set<String> denyList = new HashSet<String>();
|
Set<String> denyList = new HashSet<>();
|
||||||
denyList.add("myself");
|
denyList.add("myself");
|
||||||
Set<String> allowList = new HashSet<String>();
|
Set<String> allowList = new HashSet<>();
|
||||||
allowList.add("other");
|
allowList.add("other");
|
||||||
privilegeMap.put("priv2", new PrivilegeImpl("priv2", "DefaultPrivilege", false, denyList, allowList));
|
privilegeMap.put("priv2", new PrivilegeImpl("priv2", "DefaultPrivilege", false, denyList, allowList));
|
||||||
roles.add(new Role("role2", privilegeMap));
|
roles.add(new Role("role2", privilegeMap));
|
||||||
|
|
Loading…
Reference in New Issue