mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-29 15:22:15 +00:00
SEC-123: Remove exception from no-arg constructor.
This commit is contained in:
parent
ea182f73fe
commit
82be52cea0
@ -1,4 +1,4 @@
|
|||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -41,16 +41,8 @@ public class GrantedAuthorityImpl implements GrantedAuthority, Serializable {
|
|||||||
this.role = role;
|
this.role = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected GrantedAuthorityImpl() {
|
|
||||||
throw new IllegalArgumentException("Cannot use default constructor");
|
|
||||||
}
|
|
||||||
|
|
||||||
//~ Methods ================================================================
|
//~ Methods ================================================================
|
||||||
|
|
||||||
public String getAuthority() {
|
|
||||||
return this.role;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
return obj.equals(this.role);
|
return obj.equals(this.role);
|
||||||
@ -65,6 +57,10 @@ public class GrantedAuthorityImpl implements GrantedAuthority, Serializable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAuthority() {
|
||||||
|
return this.role;
|
||||||
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return this.role.hashCode();
|
return this.role.hashCode();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -37,21 +37,12 @@ public class GrantedAuthorityImplTests extends TestCase {
|
|||||||
|
|
||||||
//~ Methods ================================================================
|
//~ Methods ================================================================
|
||||||
|
|
||||||
public final void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
junit.textui.TestRunner.run(GrantedAuthorityImplTests.class);
|
junit.textui.TestRunner.run(GrantedAuthorityImplTests.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNoArgsConstructor() {
|
public final void setUp() throws Exception {
|
||||||
try {
|
super.setUp();
|
||||||
new GrantedAuthorityImpl();
|
|
||||||
fail("Should have thrown IllegalArgumentException");
|
|
||||||
} catch (IllegalArgumentException expected) {
|
|
||||||
assertTrue(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testObjectEquals() throws Exception {
|
public void testObjectEquals() throws Exception {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user