Merge branch '1.3.x'

This commit is contained in:
Phillip Webb 2016-04-12 14:49:06 -07:00
commit 6eeda76af7
3 changed files with 31 additions and 3 deletions

View File

@ -99,7 +99,13 @@ public class UserInfoTokenServices implements ResourceServerTokenServices {
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) {
if (map.containsKey(key)) {
return map.get(key);

View File

@ -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");
* you may not use this file except in compliance with the License.
@ -343,7 +343,7 @@ public class RelaxedDataBinder extends DataBinder {
return;
}
Object extend = new LinkedHashMap<String, Object>();
if (!elementDescriptor.isMap() && path.isArrayIndex(index + 1)) {
if (!elementDescriptor.isMap() && path.isArrayIndex(index)) {
extend = new ArrayList<Object>();
}
wrapper.setPropertyValue(path.prefix(index + 1), extend);

View File

@ -643,6 +643,16 @@ public class RelaxedDataBinderTests {
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 {
BindingResult result = bind(target, "bingo: THIS");
assertThat(result.getErrorCount()).isEqualTo(0);
@ -1001,6 +1011,8 @@ public class RelaxedDataBinderTests {
private List<Bingo> bingos;
private List<Object> objects;
public char[] getBar() {
return this.bar;
}
@ -1056,6 +1068,15 @@ public class RelaxedDataBinderTests {
public void setBingos(List<Bingo> bingos) {
this.bingos = bingos;
}
public List<Object> getObjects() {
return this.objects;
}
public void setObjects(List<Object> objects) {
this.objects = objects;
}
}
enum Bingo {
@ -1076,4 +1097,5 @@ public class RelaxedDataBinderTests {
}
}
}