@Test public void fetchAttributesReturnsExpectedValues() throws Exception { OpenID4JavaConsumer consumer = new OpenID4JavaConsumer( new NullAxFetchListFactory()); Message msg = mock(Message.class); FetchResponse fr = mock(FetchResponse.class); when(msg.hasExtension(AxMessage.OPENID_NS_AX)).thenReturn(true); when(msg.getExtension(AxMessage.OPENID_NS_AX)).thenReturn(fr); when(fr.getAttributeValues("a")).thenReturn(Arrays.asList("x", "y")); List<OpenIDAttribute> fetched = consumer.fetchAxAttributes(msg, attributes); assertThat(fetched).hasSize(1); assertThat(fetched.get(0).getValues()).hasSize(2); }
public Builder withAuthenticationToken(OpenIDAuthenticationToken token) { this.username = token.getIdentityUrl(); for (OpenIDAttribute attribute : token.getAttributes()) { if (attribute.getName().equals("email")) { this.email = attribute.getValues().get(0); } if (attribute.getName().equals("firstname")) { this.firstname = attribute.getValues().get(0); } if (attribute.getName().equals("lastname")) { this.lastname = attribute.getValues().get(0); } if (attribute.getName().equals("fullname")) { this.fullname = attribute.getValues().get(0); } } return this; }
private String getAttribute(List<OpenIDAttribute> attributes, String attributeName) { String attributeValue = ""; for (OpenIDAttribute attribute : attributes) { if (attribute.getName() != null && (attribute.getName().equals("ax" + attributeName) || attribute.getName().equals("ae" + attributeName))) { attributeValue = attribute.getValues().get(0); } } return attributeValue; }
for (OpenIDAttribute attribute : attributes) { if ("email".equals(attribute.getName()) && !attribute.getValues().isEmpty()) { email = attribute.getValues().get(0); } else if ("firstname".equals(attribute.getName()) && !attribute.getValues().isEmpty()) { firstName = attribute.getValues().get(0); } else if ("lastname".equals(attribute.getName()) && !attribute.getValues().isEmpty()) { lastName = attribute.getValues().get(0); } else if ("fullname".equals(attribute.getName()) && !attribute.getValues().isEmpty()) { displayName = attribute.getValues().get(0);
for (OpenIDAttribute attribute : token.getAttributes()) { if (attribute.getName().equals("email")) { return attribute.getValues().get(0);