Merge branch '1.3.x'
This commit is contained in:
commit
6eeda76af7
|
|
@ -99,7 +99,13 @@ public class UserInfoTokenServices implements ResourceServerTokenServices {
|
||||||
return new OAuth2Authentication(request, token);
|
return new OAuth2Authentication(request, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getPrincipal(Map<String, Object> map) {
|
/**
|
||||||
|
* Return the principal that should be used for the token. The default implementation
|
||||||
|
* looks for well know {@code user*} keys in the map.
|
||||||
|
* @param map the source map
|
||||||
|
* @return the principal or {@literal "unknown"}
|
||||||
|
*/
|
||||||
|
protected Object getPrincipal(Map<String, Object> map) {
|
||||||
for (String key : PRINCIPAL_KEYS) {
|
for (String key : PRINCIPAL_KEYS) {
|
||||||
if (map.containsKey(key)) {
|
if (map.containsKey(key)) {
|
||||||
return map.get(key);
|
return map.get(key);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* 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.
|
||||||
|
|
@ -343,7 +343,7 @@ public class RelaxedDataBinder extends DataBinder {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Object extend = new LinkedHashMap<String, Object>();
|
Object extend = new LinkedHashMap<String, Object>();
|
||||||
if (!elementDescriptor.isMap() && path.isArrayIndex(index + 1)) {
|
if (!elementDescriptor.isMap() && path.isArrayIndex(index)) {
|
||||||
extend = new ArrayList<Object>();
|
extend = new ArrayList<Object>();
|
||||||
}
|
}
|
||||||
wrapper.setPropertyValue(path.prefix(index + 1), extend);
|
wrapper.setPropertyValue(path.prefix(index + 1), extend);
|
||||||
|
|
|
||||||
|
|
@ -643,6 +643,16 @@ public class RelaxedDataBinderTests {
|
||||||
assertThat(target.getFooBaz()).isEqualTo("boo");
|
assertThat(target.getFooBaz()).isEqualTo("boo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIndexBounds() throws Exception {
|
||||||
|
VanillaTarget target = new VanillaTarget();
|
||||||
|
RelaxedDataBinder binder = getBinder(target, "test");
|
||||||
|
MutablePropertyValues values = new MutablePropertyValues();
|
||||||
|
values.add("test.objects[0]", "teststring");
|
||||||
|
binder.bind(values);
|
||||||
|
assertThat(target.getObjects()).containsExactly("teststring");
|
||||||
|
}
|
||||||
|
|
||||||
private void doTestBindCaseInsensitiveEnums(VanillaTarget target) throws Exception {
|
private void doTestBindCaseInsensitiveEnums(VanillaTarget target) throws Exception {
|
||||||
BindingResult result = bind(target, "bingo: THIS");
|
BindingResult result = bind(target, "bingo: THIS");
|
||||||
assertThat(result.getErrorCount()).isEqualTo(0);
|
assertThat(result.getErrorCount()).isEqualTo(0);
|
||||||
|
|
@ -1001,6 +1011,8 @@ public class RelaxedDataBinderTests {
|
||||||
|
|
||||||
private List<Bingo> bingos;
|
private List<Bingo> bingos;
|
||||||
|
|
||||||
|
private List<Object> objects;
|
||||||
|
|
||||||
public char[] getBar() {
|
public char[] getBar() {
|
||||||
return this.bar;
|
return this.bar;
|
||||||
}
|
}
|
||||||
|
|
@ -1056,6 +1068,15 @@ public class RelaxedDataBinderTests {
|
||||||
public void setBingos(List<Bingo> bingos) {
|
public void setBingos(List<Bingo> bingos) {
|
||||||
this.bingos = bingos;
|
this.bingos = bingos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Object> getObjects() {
|
||||||
|
return this.objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setObjects(List<Object> objects) {
|
||||||
|
this.objects = objects;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Bingo {
|
enum Bingo {
|
||||||
|
|
@ -1076,4 +1097,5 @@ public class RelaxedDataBinderTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue