Changeset 2425
- Timestamp:
- 12/14/12 13:00:22 (11 years ago)
- 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 | Templates3 * and open the template in the editor.4 */5 1 package clarin.cmdi.componentregistry.servlet; 6 2 … … 16 12 17 13 /** 14 * Checks the availability of an OAuth2 access token 18 15 * 19 16 * @author Twan Goosen <twan.goosen@mpi.nl> 20 17 */ 21 18 @Controller 22 public class OAuth HandshakeServlet extends HttpServlet {19 public class OAuthCheckServlet extends HttpServlet { 23 20 24 21 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 26 24 private OAuth2RestTemplate oauth2RestService; 27 25 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 */ 34 29 @Override 35 @RequestMapping(value = "/c onnect")30 @RequestMapping(value = "/check") 36 31 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 37 if (!"false".equalsIgnoreCase(req.getParameter("acquire"))) {38 oauth2RestService.getAccessToken();39 }40 32 resp.getWriter().write(String.format("%s", oauth2RestService.getOAuth2ClientContext().getAccessToken())); 41 33 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 | Templates3 * and open the template in the editor.4 */5 1 package clarin.cmdi.componentregistry.servlet; 6 2 7 3 import java.io.IOException; 4 import javax.servlet.RequestDispatcher; 8 5 import javax.servlet.ServletException; 9 6 import javax.servlet.http.HttpServlet; … … 21 18 @Controller 22 19 public class OAuthHandshakeServlet extends HttpServlet { 23 20 24 21 private static final long serialVersionUID = 1L; 25 22 // for access to OAuth2-protected resources, set by spring-security-oauth 23 @Autowired 26 24 private OAuth2RestTemplate oauth2RestService; 27 28 @Autowired 29 public OAuthHandshakeServlet(OAuth2RestTemplate oauth2RestService) { 30 super(); 31 this.oauth2RestService = oauth2RestService; 32 } 33 25 34 26 @Override 35 27 @RequestMapping(value = "/connect") 36 28 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 37 if (!"false".equalsIgnoreCase(req.getParameter("acquire"))) {38 39 }40 re sp.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 42 34 } 43 35 } -
ComponentRegistry/branches/ComponentRegistry-oauth-1.13.0/ComponentRegistry/src/main/webapp/js/oauthConnect.js
r2422 r2425 8 8 9 9 function hideOAuthFrame() { 10 10 var frame = document.getElementById('oauth_connect_frame'); 11 11 frame.src = "Javascript:''"; 12 12 13 13 var div = document.getElementById('oauth_connect'); 14 14 div.style.display = 'none'; 15 15 } 16 16 17 function 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.