/** * @param consumerKey Consumer Key provided by the user * @return consumer secret * @throws Exception Error when reading the consumer secret from the persistence store. */ private String getOAuthSecretKey(String consumerKey) throws IdentityOAuthAdminException { OAuthConsumerDAO dao = new OAuthConsumerDAO(); return dao.getOAuthConsumerSecret(consumerKey); }
String secretKey = null; OAuthConsumerDAO dao = new OAuthConsumerDAO(); secretKey = dao.getOAuthConsumerSecret(params.getOauthConsumerKey()); String tokenSecret = dao.getOAuthTokenSecret(params.getOauthToken(), false); Parameters resp = dao.getRequestToken(params.getOauthToken()); String oauthSecret = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); dao.issueAccessToken(params.getOauthConsumerKey(), oauthToken, oauthSecret, params.getOauthToken(), resp.getAuthorizedbyUserName(), resp.getScope()); resp.setOauthToken(oauthToken);
OAuthConsumerDAO dao = new OAuthConsumerDAO(); secretKey = dao.getOAuthConsumerSecret(params.getOauthConsumerKey()); if (secretKey == null) { log.debug("Invalid Credentials."); String tokenSecret = dao.getOAuthTokenSecret(params.getOauthToken(), true); String subject = dao.validateAccessToken(params.getOauthConsumerKey(), params.getOauthToken(), params.getScope()); Parameters returnParams = new Parameters();
OAuthConsumerDAO oAuthConsumerDAO = new OAuthConsumerDAO(); if (isHashDisabled) { if (clientSecret == null) { clientSecret = oAuthConsumerDAO.getOAuthConsumerSecret(clientId); if (log.isDebugEnabled()) { log.debug("Client credentials were fetched from the database."); if (!oAuthConsumerDAO.isConsumerSecretExist(clientId, clientSecretProvided)) { if (log.isDebugEnabled()) { log.debug("Provided the Client ID : " + clientId +
/** * @param oauthParams * @return * @throws RegistryException * @throws IdentityException */ private Parameters generateOauthToken(Parameters oauthParams) throws IdentityOAuthAdminException { OAuthConsumerDAO dao = new OAuthConsumerDAO(); String oauthToken = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); String oauthSecret = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); dao.createOAuthRequestToken(oauthParams.getOauthConsumerKey(), oauthToken, oauthSecret, oauthParams.getOauthCallback(), oauthParams.getScope()); Parameters params = new Parameters(); params.setOauthConsumerKey(oauthParams.getOauthConsumerKey()); params.setOauthToken(oauthToken); params.setOauthTokenSecret(oauthSecret); return params; }
/** * Returns the scope and the web application this particular token been issued to. * * @param oauthToken OAuth request token. * @return * @throws Exception */ public Parameters getScopeAndAppName(String oauthToken) throws Exception { OAuthConsumerDAO consumerDAO = new OAuthConsumerDAO(); Parameters params = consumerDAO.getRequestToken(oauthToken); OAuthAppDAO appDAO = new OAuthAppDAO(); OAuthAppDO oauthAppDO = appDAO.getAppInformation(params.getOauthConsumerKey()); Parameters resp = new Parameters(); resp.setScope(params.getScope()); resp.setAppName(oauthAppDO.getApplicationName()); return resp; }
OAuthConsumerDAO dao = new OAuthConsumerDAO(); String oauthVerifier = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); Parameters token = dao.authorizeOAuthToken(params.getOauthToken(), tenantUser, oauthVerifier); token.setOauthToken(params.getOauthToken());
OAuthConsumerDAO oAuthConsumerDAO = new OAuthConsumerDAO(); username = oAuthConsumerDAO.getAuthenticatedUsername(clientId, clientSecretProvided); if (log.isDebugEnabled()) { log.debug("Username fetch from the database");
/** * 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; }
final String OUT_OF_BAND = "oob"; if (userCallback == null || OUT_OF_BAND.equals(userCallback)) { userCallback = getCallbackURLOfApp(consumerKey);
String secretKey = null; OAuthConsumerDAO dao = new OAuthConsumerDAO(); secretKey = dao.getOAuthConsumerSecret(params.getOauthConsumerKey()); String tokenSecret = dao.getOAuthTokenSecret(params.getOauthToken(), false); Parameters resp = dao.getRequestToken(params.getOauthToken()); String oauthSecret = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); dao.issueAccessToken(params.getOauthConsumerKey(), oauthToken, oauthSecret, params.getOauthToken(), resp.getAuthorizedbyUserName(), resp.getScope()); resp.setOauthToken(oauthToken);
OAuthConsumerDAO dao = new OAuthConsumerDAO(); secretKey = dao.getOAuthConsumerSecret(params.getOauthConsumerKey()); if (secretKey == null) { log.debug("Invalid Credentials."); String tokenSecret = dao.getOAuthTokenSecret(params.getOauthToken(), true); String subject = dao.validateAccessToken(params.getOauthConsumerKey(), params.getOauthToken(), params.getScope()); Parameters returnParams = new Parameters();
/** * @param oauthParams * @return * @throws RegistryException * @throws IdentityException */ private Parameters generateOauthToken(Parameters oauthParams) throws IdentityOAuthAdminException { OAuthConsumerDAO dao = new OAuthConsumerDAO(); String oauthToken = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); String oauthSecret = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); dao.createOAuthRequestToken(oauthParams.getOauthConsumerKey(), oauthToken, oauthSecret, oauthParams.getOauthCallback(), oauthParams.getScope()); Parameters params = new Parameters(); params.setOauthConsumerKey(oauthParams.getOauthConsumerKey()); params.setOauthToken(oauthToken); params.setOauthTokenSecret(oauthSecret); return params; }
/** * Returns the scope and the web application this particular token been issued to. * * @param oauthToken OAuth request token. * @return * @throws Exception */ public Parameters getScopeAndAppName(String oauthToken) throws Exception { OAuthConsumerDAO consumerDAO = new OAuthConsumerDAO(); Parameters params = consumerDAO.getRequestToken(oauthToken); OAuthAppDAO appDAO = new OAuthAppDAO(); OAuthAppDO oauthAppDO = appDAO.getAppInformation(params.getOauthConsumerKey()); Parameters resp = new Parameters(); resp.setScope(params.getScope()); resp.setAppName(oauthAppDO.getApplicationName()); return resp; }
OAuthConsumerDAO dao = new OAuthConsumerDAO(); String oauthVerifier = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); Parameters token = dao.authorizeOAuthToken(params.getOauthToken(), tenantUser, oauthVerifier); token.setOauthToken(params.getOauthToken());
OAuthConsumerDAO oAuthConsumerDAO = new OAuthConsumerDAO(); username = oAuthConsumerDAO.getAuthenticatedUsername(clientId, clientSecretProvided); if (log.isDebugEnabled()) { log.debug("Username fetch from the database");
/** * 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; }
final String OUT_OF_BAND = "oob"; if (userCallback == null || OUT_OF_BAND.equals(userCallback)) { userCallback = getCallbackURLOfApp(consumerKey);
private String getClientSecret(String inboundAuthKey) throws IdentityOAuthAdminException { OAuthConsumerDAO dao = new OAuthConsumerDAO(); return dao.getOAuthConsumerSecret(inboundAuthKey); }
/** * @param consumerKey Consumer Key provided by the user * @return consumer secret * @throws Exception Error when reading the consumer secret from the persistence store. */ private String getOAuthSecretKey(String consumerKey) throws IdentityOAuthAdminException { OAuthConsumerDAO dao = new OAuthConsumerDAO(); return dao.getOAuthConsumerSecret(consumerKey); }