/** * Authorizes the OAuth request token. * * @param oauthToken Authorized OAuth token * @param userName The name of the user who authorized the token. * @param oauthVerifier oauth_verifier - an unique identifier * @throws IdentityException */ public Parameters authorizeOAuthToken(String oauthToken, String userName, String oauthVerifier) throws IdentityException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQueries.OAuthConsumerDAOSQLQueries.AUTHORIZE_REQ_TOKEN); prepStmt.setString(1, Boolean.toString(true)); prepStmt.setString(2, oauthVerifier); prepStmt.setString(3, userName); prepStmt.setString(4, oauthToken); prepStmt.execute(); connection.commit(); } catch (SQLException e) { throw new IdentityOAuthAdminException("Error when authorizing the request token : " + oauthToken); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } Parameters params = new Parameters(); params.setOauthCallback(getCallbackURLOfReqToken(oauthToken)); return params; }
/** * Authorizes the OAuth request token. * * @param oauthToken Authorized OAuth token * @param userName The name of the user who authorized the token. * @param oauthVerifier oauth_verifier - an unique identifier * @throws IdentityException */ public Parameters authorizeOAuthToken(String oauthToken, String userName, String oauthVerifier) throws IdentityException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQueries.OAuthConsumerDAOSQLQueries.AUTHORIZE_REQ_TOKEN); prepStmt.setString(1, Boolean.toString(true)); prepStmt.setString(2, oauthVerifier); prepStmt.setString(3, userName); prepStmt.setString(4, oauthToken); prepStmt.execute(); connection.commit(); } catch (SQLException e) { throw new IdentityOAuthAdminException("Error when authorizing the request token : " + oauthToken); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } Parameters params = new Parameters(); params.setOauthCallback(getCallbackURLOfReqToken(oauthToken)); return params; }