[Minor] code cleanup
This commit is contained in:
parent
901c2c86f2
commit
e3dab98b3f
|
@ -40,7 +40,7 @@ public interface EncryptionHandler {
|
||||||
* @return the hash of the string after converting
|
* @return the hash of the string after converting
|
||||||
*/
|
*/
|
||||||
public String convertToHash(String string);
|
public String convertToHash(String string);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a given byte array, e.g. a password to a hash which is defined by the concrete implementation
|
* Converts a given byte array, e.g. a password to a hash which is defined by the concrete implementation
|
||||||
*
|
*
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class XmlPersistenceHandler implements PersistenceHandler {
|
||||||
// validate that role exists
|
// validate that role exists
|
||||||
if (getRole(roleName) == null) {
|
if (getRole(roleName) == null) {
|
||||||
String msg = "Role {0} does not exist referenced by user {1}";
|
String msg = "Role {0} does not exist referenced by user {1}";
|
||||||
msg = MessageFormat.format(msg, roleName, user.getUsername()); //$NON-NLS-1$
|
msg = MessageFormat.format(msg, roleName, user.getUsername());
|
||||||
throw new PrivilegeException(msg);
|
throw new PrivilegeException(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public enum UserState {
|
||||||
* the user has automatically expired through a predefined time
|
* the user has automatically expired through a predefined time
|
||||||
*/
|
*/
|
||||||
EXPIRED,
|
EXPIRED,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the System user state which is special and thus exempted from normal uses
|
* This is the System user state which is special and thus exempted from normal uses
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -78,8 +78,8 @@ public final class User {
|
||||||
* @param propertyMap
|
* @param propertyMap
|
||||||
* a {@link Map} containing string value pairs of properties for this user
|
* a {@link Map} containing string value pairs of properties for this user
|
||||||
*/
|
*/
|
||||||
public User(String userId, String username, String password, String firstname, String lastname, UserState userState,
|
public User(String userId, String username, String password, String firstname, String lastname,
|
||||||
Set<String> roles, Locale locale, Map<String, String> propertyMap) {
|
UserState userState, Set<String> roles, Locale locale, Map<String, String> propertyMap) {
|
||||||
|
|
||||||
if (StringHelper.isEmpty(userId)) {
|
if (StringHelper.isEmpty(userId)) {
|
||||||
throw new PrivilegeException("No UserId defined!"); //$NON-NLS-1$
|
throw new PrivilegeException("No UserId defined!"); //$NON-NLS-1$
|
||||||
|
|
|
@ -185,8 +185,8 @@ public class PrivilegeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFailAuthenticationNOk() throws Exception {
|
public void testFailAuthenticationNOk() throws Exception {
|
||||||
exception.expect(AccessDeniedException.class);
|
this.exception.expect(AccessDeniedException.class);
|
||||||
exception.expectMessage("blabla");
|
this.exception.expectMessage("blabla");
|
||||||
try {
|
try {
|
||||||
login(ADMIN, ArraysHelper.copyOf(PASS_BAD));
|
login(ADMIN, ArraysHelper.copyOf(PASS_BAD));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -195,8 +195,8 @@ public class PrivilegeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFailAuthenticationPWNull() throws Exception {
|
public void testFailAuthenticationPWNull() throws Exception {
|
||||||
exception.expect(PrivilegeException.class);
|
this.exception.expect(PrivilegeException.class);
|
||||||
exception.expectMessage("blabla");
|
this.exception.expectMessage("blabla");
|
||||||
try {
|
try {
|
||||||
login(ADMIN, null);
|
login(ADMIN, null);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -250,8 +250,8 @@ public class PrivilegeTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testPerformSystemRestrictableFailPrivilege() throws Exception {
|
public void testPerformSystemRestrictableFailPrivilege() throws Exception {
|
||||||
exception.expect(PrivilegeException.class);
|
this.exception.expect(PrivilegeException.class);
|
||||||
exception
|
this.exception
|
||||||
.expectMessage("User system_admin does not have Privilege ch.eitchnet.privilege.test.model.TestSystemUserActionDeny");
|
.expectMessage("User system_admin does not have Privilege ch.eitchnet.privilege.test.model.TestSystemUserActionDeny");
|
||||||
try {
|
try {
|
||||||
// create the action to be performed as a system user
|
// create the action to be performed as a system user
|
||||||
|
@ -269,8 +269,9 @@ public class PrivilegeTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testPerformSystemRestrictableFailNoAdditionalPrivilege() throws Exception {
|
public void testPerformSystemRestrictableFailNoAdditionalPrivilege() throws Exception {
|
||||||
exception.expect(PrivilegeException.class);
|
this.exception.expect(PrivilegeException.class);
|
||||||
exception.expectMessage("User system_admin2 does not have Privilege ch.eitchnet.privilege.test.model.TestRestrictable");
|
this.exception
|
||||||
|
.expectMessage("User system_admin2 does not have Privilege ch.eitchnet.privilege.test.model.TestRestrictable");
|
||||||
try {
|
try {
|
||||||
// create the action to be performed as a system user
|
// create the action to be performed as a system user
|
||||||
TestSystemUserActionDeny action = new TestSystemUserActionDeny();
|
TestSystemUserActionDeny action = new TestSystemUserActionDeny();
|
||||||
|
@ -287,8 +288,8 @@ public class PrivilegeTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoginSystemUser() throws Exception {
|
public void testLoginSystemUser() throws Exception {
|
||||||
exception.expect(AccessDeniedException.class);
|
this.exception.expect(AccessDeniedException.class);
|
||||||
exception.expectMessage("User system_admin is a system user and may not login!");
|
this.exception.expectMessage("User system_admin is a system user and may not login!");
|
||||||
try {
|
try {
|
||||||
login(SYSTEM_USER_ADMIN, SYSTEM_USER_ADMIN.getBytes());
|
login(SYSTEM_USER_ADMIN, SYSTEM_USER_ADMIN.getBytes());
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue