Package org.apache.roller.weblogger.business

Examples of org.apache.roller.weblogger.business.OAuthManager


    public String execute() {
        boolean flush = false;
       
        try {
            User ud = getAuthenticatedUser();
            OAuthManager omgr = WebloggerFactory.getWeblogger().getOAuthManager();
            userConsumer = omgr.getConsumerByUsername(ud.getUserName());
            if (userConsumer == null) {
                String consumerKey = DigestUtils.md5Hex(ud.getUserName());
                userConsumer = omgr.addConsumer(ud.getUserName(), consumerKey);
                flush = true;
            }

            if (isUserIsAdmin()) {
                siteWideConsumer = omgr.getConsumer();
                if (siteWideConsumer == null) {
                    String consumerKey = DigestUtils.md5Hex(
                        WebloggerRuntimeConfig.getAbsoluteContextURL());
                    siteWideConsumer = omgr.addConsumer(consumerKey);
                    flush = true;
                }
            }
           
            if (flush) {
View Full Code Here


   
    private String authenticationOAUTH(
            HttpServletRequest request, HttpServletResponse response) {
        try {
            OAuthManager omgr = WebloggerFactory.getWeblogger().getOAuthManager();
            OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
            OAuthAccessor accessor = omgr.getAccessor(requestMessage);
            omgr.getValidator().validateMessage(requestMessage, accessor);
            return (String)accessor.consumer.getProperty("userId");

        } catch (Exception ex) {
            log.debug("ERROR authenticating user", ex);
            String realm = (request.isSecure())?"https://":"http://";
View Full Code Here

            throws IOException, ServletException {
       
        try{
            OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
           
            OAuthManager omgr = WebloggerFactory.getWeblogger().getOAuthManager();
            OAuthAccessor accessor = omgr.getAccessor(requestMessage);
          
            if (Boolean.TRUE.equals(accessor.getProperty("authorized"))) {
                // already authorized send the user back
                returnToConsumer(request, response, accessor);
            } else {
View Full Code Here

            throws IOException, ServletException {
       
        try{
            OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
           
            OAuthManager omgr = WebloggerFactory.getWeblogger().getOAuthManager();
            OAuthAccessor accessor = omgr.getAccessor(requestMessage);

            String userId = request.getParameter("userId");
            if (userId == null) {
                userId = request.getParameter("xoauth_requestor_id");
            }
           
            if (userId == null) {
                // no user associted with the key, must be site-wide key,
                // so get user to login and do the authorization process
                sendToAuthorizePage(request, response, accessor);
           
            } else {

                // if consumer key is for specific user, check username match
                String consumerUserId = (String)accessor.consumer.getProperty("userId");
                if (consumerUserId != null && !userId.equals(consumerUserId)) {
                    throw new ServletException("ERROR: invalid or unspecified userId");
                }

                // set userId in accessor and mark it as authorized
                omgr.markAsAuthorized(accessor, userId);
                WebloggerFactory.getWeblogger().flush();
            }
           
            returnToConsumer(request, response, accessor);
           
View Full Code Here

    public void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {

        try {
            OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
            OAuthManager omgr = WebloggerFactory.getWeblogger().getOAuthManager();           
            OAuthAccessor accessor = omgr.getAccessor(requestMessage);

            if (accessor == null) {

                OAuthConsumer consumer = omgr.getConsumer(requestMessage);
                accessor = new OAuthAccessor(consumer);
                omgr.getValidator().validateMessage(requestMessage, accessor);

                {
                    // Support the 'Variable Accessor Secret' extension
                    // described in http://oauth.pbwiki.com/AccessorSecret
                    String secret = requestMessage.getParameter("oauth_accessor_secret");
                    if (secret != null) {
                        accessor.setProperty(OAuthConsumer.ACCESSOR_SECRET, secret);
                    }
                }

                // generate request_token and secret
                omgr.generateRequestToken(accessor);
                WebloggerFactory.getWeblogger().flush();
            }

            response.setContentType("text/plain");
            OutputStream out = response.getOutputStream();
View Full Code Here

    public void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        try{
            OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
           
            OAuthManager omgr = WebloggerFactory.getWeblogger().getOAuthManager();
            OAuthAccessor accessor = omgr.getAccessor(requestMessage);
            omgr.getValidator().validateMessage(requestMessage, accessor);
           
            // make sure token is authorized
            if (!Boolean.TRUE.equals(accessor.getProperty("authorized"))) {
                 OAuthProblemException problem = new OAuthProblemException("permission_denied");
                throw problem;
            }
            // generate access token and secret
            if (accessor.accessToken == null) {
                omgr.generateAccessToken(accessor);
                WebloggerFactory.getWeblogger().flush();
            }

            response.setContentType("text/plain");
            OutputStream out = response.getOutputStream();
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.business.OAuthManager

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.