if (attribute.getName().equals("email")) { email = attribute.getValues().get(0); if (attribute.getName().equals("firstname")) { firstName = attribute.getValues().get(0); if (attribute.getName().equals("lastname")) { lastName = attribute.getValues().get(0); if (attribute.getName().equals("fullname")) { fullName = attribute.getValues().get(0);
List<String> values = fetchResp.getAttributeValues(attr.getName()); if (!values.isEmpty()) { OpenIDAttribute fetched = new OpenIDAttribute(attr.getName(), attr.getType(), values); fetched.setRequired(attr.isRequired()); attributes.add(fetched);
for (OpenIDAttribute attr : attributesToFetch) { if (logger.isDebugEnabled()) { logger.debug("Adding attribute " + attr.getType() + " to fetch request"); fetchRequest.addAttribute(attr.getName(), attr.getType(), attr.isRequired(), attr.getCount());
/** * A list of OpenID attributes to send in a request. * @param identifier a user identifier * @return a list of attributes */ public List<OpenIDAttribute> createAttributeList(String identifier) { List<OpenIDAttribute> list = new LinkedList<>(); if (identifier != null && identifier.matches("https://www.google.com/.*")) { OpenIDAttribute email = new OpenIDAttribute("email", "http://axschema.org/contact/email"); OpenIDAttribute first = new OpenIDAttribute("firstname", "http://axschema.org/namePerson/first"); OpenIDAttribute last = new OpenIDAttribute("lastname", "http://axschema.org/namePerson/last"); email.setCount(1); email.setRequired(true); first.setRequired(true); last.setRequired(true); list.add(email); list.add(first); list.add(last); } return list; } }
@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); }
/** * A list of OpenID attributes to send in a request. * @param identifier a user identifier * @return a list of attributes */ public List<OpenIDAttribute> createAttributeList(String identifier) { List<OpenIDAttribute> list = new LinkedList<>(); if (identifier != null && identifier.matches("https://www.google.com/.*")) { OpenIDAttribute email = new OpenIDAttribute("email", "http://axschema.org/contact/email"); OpenIDAttribute first = new OpenIDAttribute("firstname", "http://axschema.org/namePerson/first"); OpenIDAttribute last = new OpenIDAttribute("lastname", "http://axschema.org/namePerson/last"); email.setCount(1); email.setRequired(true); first.setRequired(true); last.setRequired(true); list.add(email); list.add(first); list.add(last); } return list; } }
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; }
List<String> values = fetchResp.getAttributeValues(attr.getName()); if (!values.isEmpty()) { OpenIDAttribute fetched = new OpenIDAttribute(attr.getName(), attr.getType(), values); fetched.setRequired(attr.isRequired()); attributes.add(fetched);
for (OpenIDAttribute attr : attributesToFetch) { if (logger.isDebugEnabled()) { logger.debug("Adding attribute " + attr.getType() + " to fetch request"); fetchRequest.addAttribute(attr.getName(), attr.getType(), attr.isRequired(), attr.getCount());
/** * A list of OpenID attributes to send in a request. * @param identifier a user identifier * @return a list of attributes */ public List<OpenIDAttribute> createAttributeList(String identifier) { List<OpenIDAttribute> list = new LinkedList<OpenIDAttribute>(); if (identifier != null && identifier.matches("https://www.google.com/.*")) { OpenIDAttribute email = new OpenIDAttribute("email", "http://axschema.org/contact/email"); OpenIDAttribute first = new OpenIDAttribute("firstname", "http://axschema.org/namePerson/first"); OpenIDAttribute last = new OpenIDAttribute("lastname", "http://axschema.org/namePerson/last"); email.setCount(1); email.setRequired(true); first.setRequired(true); last.setRequired(true); list.add(email); list.add(first); list.add(last); } return list; } }
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; }
String displayName = null; 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);
if (attribute.getName().equals("email")) { email = attribute.getValues().get(0); if (attribute.getName().equals("firstname")) { firstName = attribute.getValues().get(0); if (attribute.getName().equals("lastname")) { lastName = attribute.getValues().get(0); if (attribute.getName().equals("fullname")) { fullName = attribute.getValues().get(0);
if (attribute.getName().equals("email")) { email = attribute.getValues().get(0); if (attribute.getName().equals("firstname")) { firstName = attribute.getValues().get(0); if (attribute.getName().equals("lastname")) { lastName = attribute.getValues().get(0); if (attribute.getName().equals("fullname")) { fullName = attribute.getValues().get(0);
if (attribute.getName().equals("email")) { email = attribute.getValues().get(0); if (attribute.getName().equals("firstname")) { firstName = attribute.getValues().get(0); if (attribute.getName().equals("lastname")) { lastName = attribute.getValues().get(0); if (attribute.getName().equals("fullname")) { fullName = attribute.getValues().get(0);