Changeset 2425


Ignore:
Timestamp:
12/14/12 13:00:22 (11 years ago)
Author:
twagoo
Message:

Separated check and connect servlets. In case of connect, respond with page that interacts with Flex UI

Location:
ComponentRegistry/branches/ComponentRegistry-oauth-1.13.0/ComponentRegistry/src/main
Files:
2 added
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/branches/ComponentRegistry-oauth-1.13.0/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/servlet/OAuthCheckServlet.java

    r2423 r2425  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    51package clarin.cmdi.componentregistry.servlet;
    62
     
    1612
    1713/**
     14 * Checks the availability of an OAuth2 access token
    1815 *
    1916 * @author Twan Goosen <twan.goosen@mpi.nl>
    2017 */
    2118@Controller
    22 public class OAuthHandshakeServlet extends HttpServlet {
     19public class OAuthCheckServlet extends HttpServlet {
    2320
    2421    private static final long serialVersionUID = 1L;
    25     // for access to OAuth2-protected resources, set by spring-security-oauth
     22    // for access to OAuth2-protected resources, set by spring-security-oauth   
     23    @Autowired
    2624    private OAuth2RestTemplate oauth2RestService;
    2725
    28     @Autowired
    29     public OAuthHandshakeServlet(OAuth2RestTemplate oauth2RestService) {
    30         super();
    31         this.oauth2RestService = oauth2RestService;
    32     }
    33 
     26    /**
     27     * Serves the content of the current access token, or the string 'null' if none is available
     28     */
    3429    @Override
    35     @RequestMapping(value = "/connect")
     30    @RequestMapping(value = "/check")
    3631    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    37         if (!"false".equalsIgnoreCase(req.getParameter("acquire"))) {
    38             oauth2RestService.getAccessToken();
    39         }
    4032        resp.getWriter().write(String.format("%s", oauth2RestService.getOAuth2ClientContext().getAccessToken()));
    4133        resp.flushBuffer();
  • ComponentRegistry/branches/ComponentRegistry-oauth-1.13.0/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/servlet/OAuthHandshakeServlet.java

    r2414 r2425  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    51package clarin.cmdi.componentregistry.servlet;
    62
    73import java.io.IOException;
     4import javax.servlet.RequestDispatcher;
    85import javax.servlet.ServletException;
    96import javax.servlet.http.HttpServlet;
     
    2118@Controller
    2219public class OAuthHandshakeServlet extends HttpServlet {
    23 
     20   
    2421    private static final long serialVersionUID = 1L;
    2522    // for access to OAuth2-protected resources, set by spring-security-oauth
     23    @Autowired
    2624    private OAuth2RestTemplate oauth2RestService;
    27 
    28     @Autowired
    29     public OAuthHandshakeServlet(OAuth2RestTemplate oauth2RestService) {
    30         super();
    31         this.oauth2RestService = oauth2RestService;
    32     }
    33 
     25   
    3426    @Override
    3527    @RequestMapping(value = "/connect")
    3628    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    37         if (!"false".equalsIgnoreCase(req.getParameter("acquire"))) {
    38             oauth2RestService.getAccessToken();
    39         }
    40         resp.getWriter().write(String.format("%s", oauth2RestService.getOAuth2ClientContext().getAccessToken()));
    41         resp.flushBuffer();
     29        // Acquire token
     30        oauth2RestService.getAccessToken();
     31        RequestDispatcher requestDispatcher = req.getRequestDispatcher("/pages/oauthSuccess.jsp");
     32        requestDispatcher.forward(req, resp);
     33        //TODO: Also provided error response
    4234    }
    4335}
  • ComponentRegistry/branches/ComponentRegistry-oauth-1.13.0/ComponentRegistry/src/main/webapp/js/oauthConnect.js

    r2422 r2425  
    88
    99function hideOAuthFrame() {
    10         var frame = document.getElementById('oauth_connect_frame');
     10    var frame = document.getElementById('oauth_connect_frame');
    1111    frame.src = "Javascript:''";
    1212   
    13         var div = document.getElementById('oauth_connect');
     13    var div = document.getElementById('oauth_connect');
    1414    div.style.display = 'none';
    1515}
    1616
     17function callFlexCallback(result) {
     18    var flexUI = parent.document.getElementsByName('ComponentRegistry')[0];
     19    flexUI.handleOAuthConnect(result);
     20}
Note: See TracChangeset for help on using the changeset viewer.