Package org.openid4java.discovery

Examples of org.openid4java.discovery.DiscoveryInformation


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

            // retrieve the previously stored discovery information
            DiscoveryInformation discovered = (DiscoveryInformation)
                    httpReq.getSession().getAttribute("openid-disc");

            // extract the receiving URL from the HTTP request
            StringBuffer receivingURL = httpReq.getRequestURL();
            String queryString = httpReq.getQueryString();
View Full Code Here


                Iterator typesIter = endpoint.getTypes().iterator();
                while (typesIter.hasNext()) {
                    String type = (String) typesIter.next();
                    if (!targetTypes.contains(type)) continue;
                    try {
                        result.add(new DiscoveryInformation(
                            new URL(endpoint.getUri()),
                            DiscoveryInformation.OPENID_SIGNON_TYPES.contains(type) ?
                                new UrlIdentifier(_normalizedUrl) : null,
                            DiscoveryInformation.OPENID2.equals(type) ? endpoint.getLocalId() :
                            DiscoveryInformation.OPENID1_SIGNON_TYPES.contains(type) ? endpoint.getDelegate() : null,
View Full Code Here

            // perform discovery on the user-supplied identifier
            final List discoveries = this.consumerManager.discover(userIdentifier);

            // attempt to associate with the OpenID provider
            // and retrieve one service endpoint for authentication
            final DiscoveryInformation discoveryInformation = this.consumerManager.associate(discoveries);

            // save discovery information in session
            context.setSessionAttribute(getDiscoveryInformationSessionAttributeName(), discoveryInformation);

            final String contextualCallbackUrl = getContextualCallbackUrl(context);
View Full Code Here

        // parameters list returned by the provider
        final ParameterList parameterList = new ParameterList(context.getRequestParameters());

        // retrieve the previously stored discovery information
        final DiscoveryInformation discoveryInformation = (DiscoveryInformation) context
                .getSessionAttribute(getDiscoveryInformationSessionAttributeName());

        // create credentials
        final OpenIdCredentials credentials = new OpenIdCredentials(discoveryInformation, parameterList, getName());
        logger.debug("credentials : {}", credentials);
View Full Code Here

    protected abstract U createProfile(AuthSuccess authSuccess) throws MessageException;

    @Override
    protected U retrieveUserProfile(final OpenIdCredentials credentials, final WebContext context) {
        final ParameterList parameterList = credentials.getParameterList();
        final DiscoveryInformation discoveryInformation = credentials.getDiscoveryInformation();
        logger.debug("parameterList : {}", parameterList);
        logger.debug("discoveryInformation : {}", discoveryInformation);

        try {
            final String contextualCallbackUrl = getContextualCallbackUrl(context);
View Full Code Here

      List discoveries = manager.discover(loginString);

      // attempt to associate with the OpenID provider
      // and retrieve one service endpoint for authentication
      System.out.println("retrieve single authentication endpoint");
      DiscoveryInformation discovered = manager.associate(discoveries);
     
      System.out.println("obtaining authrequest");
      // obtain a AuthRequest message to be sent to the OpenID provider
      String returnUrl = callback.getOpenIdServletURL(request.getParameter(appBaseUrl));
      if (request.getParameter(StaticConfig.DEBUG_ARGUMENT_KEY) != null) {
View Full Code Here

            discoveries = consumerManager.discover(identityUrl);
        } catch (DiscoveryException e) {
            throw new OpenIDConsumerException("Error during discovery", e);
        }

        DiscoveryInformation information = consumerManager.associate(discoveries);
        req.getSession().setAttribute(DISCOVERY_INFO_KEY, information);

        AuthRequest authReq;

        try {
View Full Code Here

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

        // retrieve the previously stored discovery information
        DiscoveryInformation discovered = (DiscoveryInformation) request.getSession().getAttribute(DISCOVERY_INFO_KEY);

        // 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());
        }

        // verify the response
        VerificationResult verification;

        try {
            verification = consumerManager.verify(receivingURL.toString(), openidResp, discovered);
        } catch (MessageException e) {
            throw new OpenIDConsumerException("Error verifying openid response", e);
        } catch (DiscoveryException e) {
            throw new OpenIDConsumerException("Error verifying openid response", e);
        } catch (AssociationException e) {
            throw new OpenIDConsumerException("Error verifying openid response", e);
        }

        // fetch the attributesToFetch of the response
        Message authSuccess = verification.getAuthResponse();
        List<OpenIDAttribute> attributes = new ArrayList<OpenIDAttribute>(this.attributesToFetch.size());

        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
            if (debug) {
                logger.debug("Extracting attributes retrieved by attribute exchange");
            }
            try {
                MessageExtension ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX);
                if (ext instanceof FetchResponse) {
                    FetchResponse fetchResp = (FetchResponse) ext;
                    for (OpenIDAttribute attr : attributesToFetch) {
                        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);
                        }
                    }
                }
            } catch (MessageException e) {
                attributes.clear();
                throw new OpenIDConsumerException("Attribute retrieval failed", e);
            }
            if (debug) {
                logger.debug("Retrieved attributes" + attributes);
            }
        }

        // examine the verification result and extract the verified identifier
        Identifier verified = verification.getVerifiedId();

        if (verified == null) {
            Identifier id = discovered.getClaimedIdentifier();
            return new OpenIDAuthenticationToken(OpenIDAuthenticationStatus.FAILURE,
                    id == null ? "Unknown" : id.getIdentifier(),
                    "Verification status message: [" + verification.getStatusMsg() + "]", attributes);
        }
View Full Code Here

            // perform discovery on the user-supplied identifier
            List<?> discoveries = manager.discover(userSuppliedString);

            // attempt to associate with the OpenID provider
            // and retrieve one service endpoint for authentication
            DiscoveryInformation discovered = manager.associate(discoveries);

            // store the discovery information in the user's session
            sessionMap.put("openid-disc", discovered);

            // obtain a AuthRequest message to be sent to the OpenID provider
            AuthRequest authReq = manager.authenticate(discovered, returnToUrl);

            // Attribute Exchange example: fetching the 'email' attribute
            FetchRequest fetch = FetchRequest.createFetchRequest();
            fetch.addAttribute("email", // attribute alias
                    "http://schema.openid.net/contact/email", // type URI
                    true); // required
            // attach the extension to the authentication request
            authReq.addExtension(fetch);

            // example using Simple Registration to fetching the 'email' attribute
            SRegRequest sregReq = SRegRequest.createFetchRequest();
            sregReq.addAttribute("email", true);
            authReq.addExtension(sregReq);

            if (!discovered.isVersion2()) {
                // Option 1: GET HTTP-redirect to the OpenID Provider endpoint
                // The only method supported in OpenID 1.x
                // redirect-URL usually limited ~2048 bytes
                return authReq.getDestinationUrl(true);
            } else {
View Full Code Here

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

            // retrieve the previously stored discovery information
            DiscoveryInformation discovered = (DiscoveryInformation)
                    httpReq.getSession().getAttribute("openid-disc");

            // extract the receiving URL from the HTTP request
            StringBuffer receivingURL = httpReq.getRequestURL();
            String queryString = httpReq.getQueryString();
View Full Code Here

TOP

Related Classes of org.openid4java.discovery.DiscoveryInformation

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.