List<String> values = fetchResp.getAttributeValues(attr.getName()); if (!values.isEmpty()) { OpenIDAttribute fetched = new OpenIDAttribute(attr.getName(),
FetchRequest fetchRequest = FetchRequest.createFetchRequest(); for (OpenIDAttribute attr : attributesToFetch) { if (logger.isDebugEnabled()) { + " to fetch request"); fetchRequest.addAttribute(attr.getName(), attr.getType(), attr.isRequired(), attr.getCount());
/** * Constructs a Fetch Response with an empty parameter list. */ public static FetchResponse createFetchResponse() { return new FetchResponse(); }
/** * Adds an attribute to the fetch request, with a default value-count of 1. * * @see #addAttribute(String, String, boolean, int) */ public void addAttribute(String alias, String typeUri, boolean required) throws MessageException { addAttribute(alias, typeUri, required, 1); }
/** * Adds an attribute to the fetch request, with a default value-count of 1. * An alias is generated for the provided type URI. * * @see #addAttribute(String, String, boolean, int) */ public String addAttribute(String typeUri, boolean required) throws MessageException { String alias = generateAlias(); addAttribute(alias, typeUri, required, 1); return alias; }
/** * Returns a list with the attribute value(s) associated for the specified * attribute type URI. * * @param typeUri The attribute type URI. * @return List of attribute values. */ public List getAttributeValuesByTypeUri(String typeUri) { return getAttributeValues(getAttributeAlias(typeUri)); }
/** * Gets the (first) value for the specified attribute type URI. * * @param typeUri * @return */ public String getAttributeValueByTypeUri(String typeUri) { return getAttributeValue(getAttributeAlias(typeUri)); }
/** * Constructs a Store Request with an empty parameter list. */ public static StoreRequest createStoreRequest() { return new StoreRequest(); }
/** * Constructs a Fetch Request with an empty parameter list. */ public static FetchRequest createFetchRequest() { return new FetchRequest(); }
/** * Constructs a Store Response with an empty parameter list. */ public static StoreResponse createStoreResponse() { return new StoreResponse(); }
protected String authRequest(String userSuppliedString, String returnToUrl) throws IOException { ... // Attribute Exchange example: fetching the 'email' attribute FetchRequest fetch = FetchRequest.createFetchRequest(); fetch.addAttribute("email", "http://schema.openid.net/contact/email", // type URI true); // required
@Test(expected = OpenIDConsumerException.class) public void messageExceptionFetchingAttributesRaisesOpenIDException() 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)) .thenThrow(new MessageException("")); when(fr.getAttributeValues("a")).thenReturn(Arrays.asList("x", "y")); consumer.fetchAxAttributes(msg, attributes); }
/** * Returns a list with the attribute value(s) associated for the specified * attribute type URI. * * @param typeUri The attribute type URI. * @return List of attribute values. */ public List getAttributeValuesByTypeUri(String typeUri) { return getAttributeValues(getAttributeAlias(typeUri)); }
/** * Constructs a Fetch Response with an empty parameter list. */ public static FetchResponse createFetchResponse() { return new FetchResponse(); }
/** * Constructs a Store Request with an empty parameter list. */ public static StoreRequest createStoreRequest() { return new StoreRequest(); }
/** * Constructs a Fetch Request with an empty parameter list. */ public static FetchRequest createFetchRequest() { return new FetchRequest(); }
@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); }
/** * Constructs a Fetch Response with an empty parameter list. */ public static FetchResponse createFetchResponse() { return new FetchResponse(); }
/** * Constructs a Store Request with an empty parameter list. */ public static StoreRequest createStoreRequest() { return new StoreRequest(); }
/** * Constructs a Fetch Response with an empty parameter list. */ public static FetchResponse createFetchResponse() { return new FetchResponse(); }