mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-25 13:32:30 +00:00
Added support for locking user accounts in namespace <user-service> "user" elements (for use in testing).
This commit is contained in:
parent
2343577fec
commit
d3f26f09b6
@ -28,8 +28,10 @@ public class UserServiceBeanDefinitionParser extends AbstractUserDetailsServiceB
|
|||||||
static final String ELT_USER = "user";
|
static final String ELT_USER = "user";
|
||||||
static final String ATT_AUTHORITIES = "authorities";
|
static final String ATT_AUTHORITIES = "authorities";
|
||||||
static final String ATT_PROPERTIES = "properties";
|
static final String ATT_PROPERTIES = "properties";
|
||||||
|
static final String ATT_DISABLED = "disabled";
|
||||||
|
static final String ATT_LOCKED = "locked";
|
||||||
|
|
||||||
protected Class getBeanClass(Element element) {
|
protected Class getBeanClass(Element element) {
|
||||||
return InMemoryDaoImpl.class;
|
return InMemoryDaoImpl.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +59,10 @@ public class UserServiceBeanDefinitionParser extends AbstractUserDetailsServiceB
|
|||||||
Element userElt = (Element) i.next();
|
Element userElt = (Element) i.next();
|
||||||
String userName = userElt.getAttribute(ATT_NAME);
|
String userName = userElt.getAttribute(ATT_NAME);
|
||||||
String password = userElt.getAttribute(ATT_PASSWORD);
|
String password = userElt.getAttribute(ATT_PASSWORD);
|
||||||
|
boolean locked = "true".equals(userElt.getAttribute(ATT_LOCKED));
|
||||||
|
boolean disabled = "true".equals(userElt.getAttribute(ATT_DISABLED));
|
||||||
|
|
||||||
users.addUser(new User(userName, password, true, true, true, true,
|
users.addUser(new User(userName, password, !disabled, true, true, !locked,
|
||||||
AuthorityUtils.commaSeparatedStringToAuthorityArray(userElt.getAttribute(ATT_AUTHORITIES))));
|
AuthorityUtils.commaSeparatedStringToAuthorityArray(userElt.getAttribute(ATT_AUTHORITIES))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,6 +302,10 @@ user.attlist &=
|
|||||||
user.attlist &=
|
user.attlist &=
|
||||||
## One of more authorities granted to the user. Separate authorities with a comma (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR"
|
## One of more authorities granted to the user. Separate authorities with a comma (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR"
|
||||||
attribute authorities {xsd:string}
|
attribute authorities {xsd:string}
|
||||||
|
user.attlist &=
|
||||||
|
## Can be set to "true" to mark an account as locked and unusable.
|
||||||
|
attribute locked {"true" | "false"}?
|
||||||
|
|
||||||
|
|
||||||
jdbc-user-service =
|
jdbc-user-service =
|
||||||
## Causes creation of a JDBC-based UserDetailsService.
|
## Causes creation of a JDBC-based UserDetailsService.
|
||||||
|
@ -705,6 +705,17 @@
|
|||||||
<xs:documentation>One of more authorities granted to the user. Separate authorities with a comma (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR"</xs:documentation>
|
<xs:documentation>One of more authorities granted to the user. Separate authorities with a comma (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR"</xs:documentation>
|
||||||
</xs:annotation>
|
</xs:annotation>
|
||||||
</xs:attribute>
|
</xs:attribute>
|
||||||
|
<xs:attribute name="locked">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>Can be set to "true" to mark an account as locked and unusable.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
<xs:simpleType>
|
||||||
|
<xs:restriction base="xs:token">
|
||||||
|
<xs:enumeration value="true"/>
|
||||||
|
<xs:enumeration value="false"/>
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
</xs:attribute>
|
||||||
</xs:attributeGroup>
|
</xs:attributeGroup>
|
||||||
<xs:element name="jdbc-user-service">
|
<xs:element name="jdbc-user-service">
|
||||||
<xs:annotation>
|
<xs:annotation>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user