Examples of DiscoveryInformation


Examples of org.openid4java.discovery.DiscoveryInformation

            // perform discovery on the user-supplied identifier
            List discoveries = manager.discover(openId);

            // 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
            httpReq.getSession().setAttribute("openid-disc", discovered);

            // obtain a AuthRequest message to be sent to the OpenID provider
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

      // Perform discovery on the user-supplied identifier
      List discoveries = manager.discover(identifier);

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

      // Create a memento to rebuild the discovered information in a subsequent request
      DiscoveryInformationMemento memento = new DiscoveryInformationMemento();
      if (discovered.getClaimedIdentifier() != null) {
        memento.setClaimedIdentifier(discovered.getClaimedIdentifier().getIdentifier());
      }
      memento.setDelegate(discovered.getDelegateIdentifier());
      if (discovered.getOPEndpoint() != null) {
        memento.setOpEndpoint(discovered.getOPEndpoint().toString());
      }
      memento.setTypes(discovered.getTypes());
      memento.setVersion(discovered.getVersion());

      // Create a temporary User to preserve state between requests without
      // using a session (we could be in a cluster)
      User tempUser = new User(sessionToken);
      tempUser.setOpenIDDiscoveryInformationMemento(memento);
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

      public String getIdentifier() {
        return memento.getClaimedIdentifier();
      }
    };

    DiscoveryInformation discovered;
    try {
      discovered = new DiscoveryInformation(
        URI.create(memento.getOpEndpoint()).toURL(),
        identifier,
        memento.getDelegate(),
        memento.getVersion(),
        memento.getTypes()
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

    }

    public DiscoveryInformation discover(String identifier) throws OpenIDException {
        String userSuppliedString = identifier;
        List<?> discoveries = consumerManager.discover(userSuppliedString);
        DiscoveryInformation discovered = consumerManager.associate(discoveries);

        return discovered;
    }
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

    }   

    public void processIncomingMessage(ParameterList parameterList, String queryString, HttpServletResponse httpResponse) {
        try {
            // retrieve the previously stored discovery information
            DiscoveryInformation discovered = openIdRequest.getDiscoveryInformation();
            if (discovered == null) {
                throw new IllegalStateException("No discovery information found in OpenID request");
            }

            // extract the receiving URL from the HTTP request           
            StringBuffer receivingURL = new StringBuffer(relyingPartyBean.get().getServiceURL(OpenIdService.OPEN_ID_SERVICE));
           
            if (queryString != null && queryString.length() > 0)
                receivingURL.append("?").append(queryString);

            // verify the response; ConsumerManager needs to be the same
            // (static) instance used to place the authentication request
            VerificationResult verification = openIdConsumerManager.verify(
                    receivingURL.toString(), parameterList, discovered);

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

            if (identifier != null) {
                AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();

                Map<String, List<String>> attributeValues = null;
                if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
                    FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);
                    @SuppressWarnings("unchecked")
                    Map<String, List<String>> attrValues = fetchResp.getAttributes();
                    attributeValues = attrValues;
                }

                OpenIdPrincipal principal = createPrincipal(identifier.getIdentifier(),
                        discovered.getOPEndpoint(), attributeValues);

                openIdRelyingPartySpi.get().loginSucceeded(principal,
                        responseHandler.createResponseHolder(httpResponse));
            } else {
                openIdRelyingPartySpi.get().loginFailed(verification.getStatusMsg(),
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

                                HttpServletResponse response) {
        try {
            @SuppressWarnings("unchecked")
            List<DiscoveryInformation> discoveries = openIdConsumerManager.discover(openId);

            DiscoveryInformation discovered = openIdConsumerManager.associate(discoveries);

            openIdRequest.setDiscoveryInformation(discovered);

            String realm = relyingPartyBean.get().getRealm();
            String returnTo = relyingPartyBean.get().getServiceURL(
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

        assert sessionId != null;
        if (sessionId == null)
            throw new PartakeException(ServerErrorCode.SESSION_ID_KEY_NOTFOUND);

        IOpenIDService service = PartakeApp.getOpenIDService();
        DiscoveryInformation discoveryInformation = service.discover(identifier);
        OpenIDLoginInformation info = new OpenIDLoginInformation(purpose, discoveryInformation);
        Cache.set(Constants.Cache.OPENID_LOGIN_KEY_PREFIX + sessionId, info, LOGIN_TIMEOUT_SEC);

        String authURL = service.getURLToAuthenticate(discoveryInformation, CALLBACK_URL);
        return renderRedirect(authURL);
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

    @Test
    public void failedVerificationReturnsFailedAuthenticationStatus() throws Exception {
        ConsumerManager mgr = mock(ConsumerManager.class);
        OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
        VerificationResult vr = mock(VerificationResult.class);
        DiscoveryInformation di = mock(DiscoveryInformation.class);

        when(mgr.verify(anyString(), any(ParameterList.class), any(DiscoveryInformation.class))).thenReturn(vr);

        MockHttpServletRequest request = new MockHttpServletRequest();
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

    @Test
    public void successfulVerificationReturnsExpectedAuthentication() throws Exception {
        ConsumerManager mgr = mock(ConsumerManager.class);
        OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
        VerificationResult vr = mock(VerificationResult.class);
        DiscoveryInformation di = mock(DiscoveryInformation.class);
        Identifier id = new Identifier() {
            public String getIdentifier() {
                return "id";
            }
        };
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

    @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), anyString(), anyString())).thenReturn(authReq);
        when(mgr.associate(anyList())).thenReturn(di);

        OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, attributes);
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.