authReq = consumerManager.authenticate(information, returnToUrl, realm);
@SuppressWarnings("deprecation") @Test public void beginConsumptionCreatesExpectedSessionData() throws Exception { ConsumerManager mgr = mock(ConsumerManager.class); AuthRequest authReq = mock(AuthRequest.class); DiscoveryInformation di = mock(DiscoveryInformation.class); when(mgr.authenticate(any(DiscoveryInformation.class), any(), any())) .thenReturn(authReq); when(mgr.associate(any())).thenReturn(di); OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new MockAttributesFactory()); MockHttpServletRequest request = new MockHttpServletRequest(); consumer.beginConsumption(request, "", "", ""); assertThat(request.getSession().getAttribute( "SPRING_SECURITY_OPEN_ID_ATTRIBUTES_FETCH_LIST")).isEqualTo(attributes); assertThat( request.getSession().getAttribute(DiscoveryInformation.class.getName())).isEqualTo(di); // Check with empty attribute fetch list consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory()); request = new MockHttpServletRequest(); consumer.beginConsumption(request, "", "", ""); }
@Test public void messageOrConsumerAuthenticationExceptionRaisesOpenIDException() throws Exception { ConsumerManager mgr = mock(ConsumerManager.class); OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory()); when(mgr.authenticate(ArgumentMatchers.<DiscoveryInformation>any(), any(), any())) .thenThrow(new MessageException("msg"), new ConsumerException("msg")); try { consumer.beginConsumption(new MockHttpServletRequest(), "", "", ""); fail("OpenIDConsumerException was not thrown"); } catch (OpenIDConsumerException expected) { } try { consumer.beginConsumption(new MockHttpServletRequest(), "", "", ""); fail("OpenIDConsumerException was not thrown"); } catch (OpenIDConsumerException expected) { } }
/** * Builds a authentication request message for the user specified in the * discovery information provided as a parameter. * * @param discovered A DiscoveryInformation endpoint from the list * obtained by performing dicovery on the * User-supplied OpenID identifier. * @param returnToUrl The URL on the Consumer site where the OpenID * Provider will return the user after generating * the authentication response. <br> * Null if the Consumer does not with to for the * End User to be returned to it (something else * useful will have been performed via an * extension). <br> * Must not be null in OpenID 1.x compatibility * mode. * @return Authentication request message to be sent to the * OpenID Provider. */ public AuthRequest authenticate(DiscoveryInformation discovered, String returnToUrl) throws MessageException, ConsumerException { return authenticate(discovered, returnToUrl, returnToUrl); }
/** * Builds a authentication request message for the user specified in the * discovery information provided as a parameter. * * @param discovered A DiscoveryInformation endpoint from the list * obtained by performing dicovery on the * User-supplied OpenID identifier. * @param returnToUrl The URL on the Consumer site where the OpenID * Provider will return the user after generating * the authentication response. <br> * Null if the Consumer does not with to for the * End User to be returned to it (something else * useful will have been performed via an * extension). <br> * Must not be null in OpenID 1.x compatibility * mode. * @return Authentication request message to be sent to the * OpenID Provider. */ public AuthRequest authenticate(DiscoveryInformation discovered, String returnToUrl) throws MessageException, ConsumerException { return authenticate(discovered, returnToUrl, returnToUrl); }
/** * Builds a authentication request message for the user specified in the * discovery information provided as a parameter. * * @param discovered A DiscoveryInformation endpoint from the list * obtained by performing dicovery on the * User-supplied OpenID identifier. * @param returnToUrl The URL on the Consumer site where the OpenID * Provider will return the user after generating * the authentication response. <br> * Null if the Consumer does not with to for the * End User to be returned to it (something else * useful will have been performed via an * extension). <br> * Must not be null in OpenID 1.x compatibility * mode. * @return Authentication request message to be sent to the * OpenID Provider. */ public AuthRequest authenticate(DiscoveryInformation discovered, String returnToUrl) throws MessageException, ConsumerException { return authenticate(discovered, returnToUrl, returnToUrl); }
/** * Builds a authentication request message for the user specified in the * discovery information provided as a parameter. * * @param discovered A DiscoveryInformation endpoint from the list * obtained by performing dicovery on the * User-supplied OpenID identifier. * @param returnToUrl The URL on the Consumer site where the OpenID * Provider will return the user after generating * the authentication response. <br> * Null if the Consumer does not with to for the * End User to be returned to it (something else * useful will have been performed via an * extension). <br> * Must not be null in OpenID 1.x compatibility * mode. * @return Authentication request message to be sent to the * OpenID Provider. */ public AuthRequest authenticate(DiscoveryInformation discovered, String returnToUrl) throws MessageException, ConsumerException { return authenticate(discovered, returnToUrl, returnToUrl); }
/** * Builds a authentication request message for the user specified in the * discovery information provided as a parameter. * * @param discovered A DiscoveryInformation endpoint from the list * obtained by performing dicovery on the * User-supplied OpenID identifier. * @param returnToUrl The URL on the Consumer site where the OpenID * Provider will return the user after generating * the authentication response. <br> * Null if the Consumer does not with to for the * End User to be returned to it (something else * useful will have been performed via an * extension). <br> * Must not be null in OpenID 1.x compatibility * mode. * @return Authentication request message to be sent to the * OpenID Provider. */ public AuthRequest authenticate(DiscoveryInformation discovered, String returnToUrl) throws MessageException, ConsumerException { return authenticate(discovered, returnToUrl, returnToUrl); }
throws ConsumerException, MessageException return authenticate(discoveries, returnToUrl, returnToUrl);
/** * Builds a authentication request message for the user specified in the * discovery information provided as a parameter. * <p/> * If the discoveries parameter contains more than one entry, it will * iterate over them trying to establish an association. If an association * cannot be established, the first entry is used with stateless mode. * * @param discoveries The DiscoveryInformation list obtained by * performing dicovery on the User-supplied OpenID * identifier. Should be ordered by the priority * of the service endpoints. * @param returnToUrl The URL on the Consumer site where the OpenID * Provider will return the user after generating * the authentication response. <br> * Null if the Consumer does not with to for the * End User to be returned to it (something else * useful will have been performed via an * extension). <br> * Must not be null in OpenID 1.x compatibility * mode. * @return Authentication request message to be sent to the * OpenID Provider. * @see #associate(java.util.List) */ public AuthRequest authenticate(List discoveries, String returnToUrl) throws ConsumerException, MessageException { return authenticate(discoveries, returnToUrl, returnToUrl); }
throws ConsumerException, MessageException return authenticate(discoveries, returnToUrl, returnToUrl);
throws ConsumerException, MessageException return authenticate(discoveries, returnToUrl, returnToUrl);
throws ConsumerException, MessageException return authenticate(discoveries, returnToUrl, returnToUrl);
return authenticate(discovered, returnToUrl, realm);
session.setAttribute("discovery", discovered); try { AuthRequest authReq = openIdConsumerManager.authenticate(discovered, returnURL);
session.setNote("discovery", discovered); try { AuthRequest authReq = openIdConsumerManager.authenticate(discovered, returnURL);
session.setNote("discovery", discovered); try { AuthRequest authReq = openIdConsumerManager.authenticate(discovered, returnURL);
session.setNote("discovery", discovered); try { AuthRequest authReq = openIdConsumerManager.authenticate(discovered, returnURL);
AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
private AuthRequest createOpenIdAuthRequest() { try { ConsumerManager consumerManager = OpenIdSession.get().getConsumerManager(); AuthRequest auth = consumerManager.authenticate(discoveryInformation, OpenIdSession.get() .getOpenIdReturnUrl()); if (discoveryInformation.getTypes().contains(AxMessage.OPENID_NS_AX)) { FetchRequest fetch = FetchRequest.createFetchRequest(); fetch.addAttribute("email", "http://axschema.org/contact/email", true); fetch.addAttribute("fullname", "http://axschema.org/namePerson", false); fetch.addAttribute("firstname", "http://axschema.org/namePerson/first", false); fetch.addAttribute("lastname", "http://axschema.org/namePerson/last", false); auth.addExtension(fetch); } else if (discoveryInformation.getTypes().contains(SRegMessage.OPENID_NS_SREG)) { SRegRequest sregReq = SRegRequest.createFetchRequest(); sregReq.addAttribute("fullname", true); sregReq.addAttribute("email", true); auth.addExtension(sregReq); } return auth; } catch (MessageException e) { throw new WicketRuntimeException("failed to create OpenID AuthRequest", e); } catch (ConsumerException e) { throw new WicketRuntimeException("failed to create OpenID AuthRequest", e); } }