Package org.openid4java.message

Examples of org.openid4java.message.MessageException


    public void messageOrConsumerAuthenticationExceptionRaisesOpenIDException() throws Exception {
        ConsumerManager mgr = mock(ConsumerManager.class);
        OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());

        when(mgr.authenticate(any(DiscoveryInformation.class), anyString(), anyString()))
                .thenThrow(new MessageException("msg"), new ConsumerException("msg"));

        try {
            consumer.beginConsumption(new MockHttpServletRequest(), "", "", "");
            fail();
        } catch (OpenIDConsumerException expected) {
View Full Code Here


    public void verificationExceptionsRaiseOpenIDException() throws Exception {
        ConsumerManager mgr = mock(ConsumerManager.class);
        OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());

        when(mgr.verify(anyString(), any(ParameterList.class), any(DiscoveryInformation.class)))
                .thenThrow(new MessageException(""))
                .thenThrow(new AssociationException(""))
                .thenThrow(new DiscoveryException(""));

        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setQueryString("x=5");
View Full Code Here

    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);
    }
View Full Code Here

        return FetchResponse2.createFetchResponse2(parameterList);
      default:
        return super.getExtension(parameterList, isRequest);
      }
    }
    throw new MessageException("Attribure exchange message is missing a mode.");
  }
View Full Code Here

  public static FetchRequest2 createFetchRequest2(ParameterList params)
    throws MessageException {
      FetchRequest2 req = new FetchRequest2(params);

      if (!req.isValid()) {
        throw new MessageException("Invalid parameters for a fetch request");
      }

      return req;
  }
View Full Code Here

    Arrays.asList(new String[] {SCOPE, OAUTH_TOKEN});

  HybridOauthResponse(ParameterList parameters) throws MessageException {
    this.parameters = parameters;
    if (!isValid()) {
      throw new MessageException("Invalid parameters for Oauth fetch");
    }
  }
View Full Code Here

    Arrays.asList(new String[] {SCOPE});

  HybridOauthRequest(ParameterList parameters) throws MessageException {
    this.parameters = parameters;
    if (!isValid()) {
      throw new MessageException("Invalid parameters for Oauth fetch");
    }
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private <T extends MessageExtension> T getExtension(Class<T> type,
      String typeUri) throws MessageException {
    if (!getAuthResponse().hasExtension(typeUri)) {
      throw new MessageException("Response does not have extension for type: "
          + typeUri);
    }

    MessageExtension ext = getAuthResponse().getExtension(typeUri);
    if (type.isAssignableFrom(ext.getClass())) {
      return (T) ext;
    }
    throw new MessageException("Cannot cast type " + ext.getClass().getName() +
        " to " + type.getName());
  }
View Full Code Here

            throws MessageException
    {
        SRegRequest req = new SRegRequest(params);

        if (! req.isValid())
            throw new MessageException("Invalid parameters for a SReg request");

        if (DEBUG)
            _log.debug("Created SReg request from parameter list:\n" + params);

        return req;
View Full Code Here

        try
        {
            new URL(policyUrl);
        } catch (MalformedURLException e)
        {
            throw new MessageException("Invalid policy_url: " + policyUrl);
        }

        if (DEBUG) _log.debug("Setting SReg request policy_url: " + policyUrl);

        _parameters.set(new Parameter("policy_url", policyUrl));
View Full Code Here

TOP

Related Classes of org.openid4java.message.MessageException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.