Examples of ConsumerManager


Examples of org.openid4java.consumer.ConsumerManager

    Optional<ConsumerManager> consumerManagerOptional = InMemoryOpenIDCache.INSTANCE.getConsumerManager(sessionToken);
    if (!consumerManagerOptional.isPresent()) {
      log.debug("Authentication failed due to no consumer manager matching session token {}", rawToken);
      throw new WebApplicationException(Response.Status.UNAUTHORIZED);
    }
    ConsumerManager consumerManager = consumerManagerOptional.get();

    // Attempt to locate the user by the session token
    Optional<User> tempUserOptional = InMemoryUserCache.INSTANCE.getBySessionToken(sessionToken);
    if (!tempUserOptional.isPresent()) {
      log.debug("Authentication failed due to no temp User matching session token {}", rawToken);
      throw new WebApplicationException(Response.Status.UNAUTHORIZED);
    }
    User tempUser = tempUserOptional.get();

    // Retrieve the discovery information
    final DiscoveryInformationMemento memento = tempUser.getOpenIDDiscoveryInformationMemento();
    Identifier identifier = new Identifier() {
      @Override
      public String getIdentifier() {
        return memento.getClaimedIdentifier();
      }
    };

    DiscoveryInformation discovered;
    try {
      discovered = new DiscoveryInformation(
        URI.create(memento.getOpEndpoint()).toURL(),
        identifier,
        memento.getDelegate(),
        memento.getVersion(),
        memento.getTypes()
      );
    } catch (DiscoveryException e) {
      throw new WebApplicationException(e, Response.Status.UNAUTHORIZED);
    } catch (MalformedURLException e) {
      throw new WebApplicationException(e, Response.Status.UNAUTHORIZED);
    }

    // Extract the receiving URL from the HTTP request
    StringBuffer receivingURL = request.getRequestURL();
    String queryString = request.getQueryString();
    if (queryString != null && queryString.length() > 0) {
      receivingURL.append("?").append(request.getQueryString());
    }
    log.debug("Receiving URL = '{}", receivingURL.toString());

    // Extract the parameters from the authentication response
    // (which comes in as a HTTP request from the OpenID provider)
    ParameterList parameterList = new ParameterList(request.getParameterMap());

    try {

      // Verify the response
      // ConsumerManager needs to be the same (static) instance used
      // to place the authentication request
      // This could be tricky if this service is load-balanced
      VerificationResult verification = consumerManager.verify(
        receivingURL.toString(),
        parameterList,
        discovered);

      // Examine the verification result and extract the verified identifier
View Full Code Here

Examples of org.openid4java.consumer.ConsumerManager

    @Override
    public void service(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws ServletException,
            IOException {
        try {
            HttpSession httpSession = httpRequest.getSession(false);
            ConsumerManager manager = (ConsumerManager) httpSession.getAttribute("manager");

            ParameterList openidResp = new ParameterList(httpRequest.getParameterMap());
            List list = openidResp.getParameters();
            if (list != null){
                for (Object param : list) {
                    if (param != null && ((Parameter)param).getKey() != null && ((Parameter)param).getValue() != null){
                        log.info(((Parameter) param).getKey() + "=" + ((Parameter) param).getValue());
                    }
                }
            }

            String openIdIdentity = httpRequest.getParameter("openid.identity");
            DiscoveryInformation discovered = (DiscoveryInformation) httpSession.getAttribute("discovered");

            StringBuffer receivingURL = httpRequest.getRequestURL();
            String queryString = httpRequest.getQueryString();
            if (queryString != null && queryString.length() > 0) {
                receivingURL.append("?").append(httpRequest.getQueryString());
            }
            // verify the response
            VerificationResult verification = null;
            log.info("Receiving URL = " + receivingURL.toString());
            verification = manager.verify(receivingURL.toString(), openidResp, discovered);
            // examine the verification result and extract the verified identifier
            Identifier verified = verification.getVerifiedId();
            if (verified != null) {
                AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();
View Full Code Here

Examples of org.openid4java.consumer.ConsumerManager

        init();
    }

    @Create
    public void init() {
        manager = new ConsumerManager();
        discovered = null;
        id = null;
        authResult = new OpenIdAuthenticationResult();
        // TODO inject these
        identity =
View Full Code Here

Examples of org.openid4java.consumer.ConsumerManager

   
    public void init(FilterConfig config) throws ServletException {
        super.init(config);
        try
        {
            this.manager = new ConsumerManager();
        } catch (ConsumerException ex) {
            throw new ServletException(ex);
        }
        manager.setAssociations(new InMemoryConsumerAssociationStore());
        manager.setNonceVerifier(new InMemoryNonceVerifier(5000));
View Full Code Here

Examples of org.openid4java.consumer.ConsumerManager

   public OpenIDManager(OpenIDRequest theReq)
   {
      this.request = theReq;
      try
      {
         consumerManager = new ConsumerManager();
         consumerManager.setAssociations(new InMemoryConsumerAssociationStore());
         consumerManager.setNonceVerifier(new InMemoryNonceVerifier(5000));
         userString = request.getURL();
      }
      catch(ConsumerException ce)
View Full Code Here

Examples of org.openid4java.consumer.ConsumerManager

   * Constructs a new EROpenIDManager.
   *
   * @throws ConsumerException
   */
  protected EROpenIDManager() throws ConsumerException {
    _manager = new ConsumerManager();
    boolean disableRealmVerifier = ERXProperties.booleanForKeyWithDefault("er.openid.disableRealmVerifier", false);
    if (disableRealmVerifier) {
      _manager.getRealmVerifier().setEnforceRpId(false);
      EROpenIDManager.log.info("Disabling realm verifier.");
    }
View Full Code Here

Examples of org.openid4java.consumer.ConsumerManager

    }
  }

  private ConsumerManager getConsumerManager() {
    Application app = Session.get().getApplication();
    ConsumerManager consumerManager = app.getMetaData(CONSUMER_MANAGER_KEY);
    if (consumerManager == null) {
      // double checked locking
      synchronized (CONSUMER_MANAGER_KEY) {
        consumerManager = app.getMetaData(CONSUMER_MANAGER_KEY);
        if (consumerManager == null) {
          consumerManager = new ConsumerManager();
          consumerManager.setAssociations(new InMemoryConsumerAssociationStore());
          consumerManager.setNonceVerifier(new InMemoryNonceVerifier(10000));
          app.setMetaData(CONSUMER_MANAGER_KEY, consumerManager);
        }
      }
    }
    return consumerManager;
View Full Code Here

Examples of org.tubo.resource.consumer.ConsumerManager

        // get all consumers (managers)
        List consumerManagers =  resourceManager.getConsumerManagers();
        //
        // loop over consumer managers
        for (Iterator it=consumerManagers.iterator(); it.hasNext();) {
            ConsumerManager consumerManager = (ConsumerManager)it.next();
            try {
                //
                // delegate consumer loading to manager
                consumerManager.load();
            } catch (TuboConsumerException e) {
                //
                // if something go wrong then a exception is throw and execution ends
                throw resourceManager.getExceptionManager().getException(1100,consumerManager.getId(),e);
            }
        }
        //
        // set running flag
        running=true;
View Full Code Here

Examples of org.tubo.resource.consumer.ConsumerManager

        // get all consumers (managers)
        List consumerManagers =  resourceManager.getConsumerManagers();
        //
        // loop over consumer managers
        for (Iterator it=consumerManagers.iterator(); it.hasNext();) {
            ConsumerManager consumerManager = (ConsumerManager)it.next();
            try {
                //
                // delegate consumer loading to manager
                consumerManager.unload();
            } catch (TuboConsumerException e) {
                //
                // if something go wrong then a exception is throw and execution ends
                throw resourceManager.getExceptionManager().getException(1100,consumerManager.getId(),e);
            }
        }

        synchronized (this) {
            notify();
View Full Code Here

Examples of org.tubo.resource.consumer.ConsumerManager

        //
        // get manager identified by id
        Manager manager = getManager(id);
        //
        // define var
        ConsumerManager consumerManager;
        //
        // check instanceof
        if (manager instanceof ConsumerManager) {
            //
            // cast manager to Consumermanager
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.