public String[] addOAuthConsumer(String username, int tenantId, String userDomain) throws IdentityOAuthAdminException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; String sqlStmt = null; String consumerKey; String consumerSecret = OAuthUtil.getRandomNumber(); do { consumerKey = OAuthUtil.getRandomNumber(); } while (isDuplicateConsumer(consumerKey)); try { sqlStmt = SQLQueries.OAuthAppDAOSQLQueries.ADD_OAUTH_CONSUMER; prepStmt = connection.prepareStatement(sqlStmt); prepStmt.setString(1, consumerKey); prepStmt.setString(2, consumerSecret); prepStmt.setString(3, username); prepStmt.setInt(4, tenantId); prepStmt.setString(5, userDomain); // it is assumed that the OAuth version is 1.0a because this is required with OAuth 1.0a prepStmt.setString(6, OAuthConstants.OAuthVersions.VERSION_1A); prepStmt.execute(); connection.commit(); } catch (SQLException e) { throw new IdentityOAuthAdminException("Error when executing the SQL : " + sqlStmt, e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } return new String[]{consumerKey, consumerSecret}; }
public String[] addOAuthConsumer(String username, int tenantId, String userDomain) throws IdentityOAuthAdminException { String consumerKey; String consumerSecret = OAuthUtil.getRandomNumber(); long userAccessTokenExpireTime = OAuthServerConfiguration.getInstance() .getUserAccessTokenValidityPeriodInSeconds(); consumerKey = OAuthUtil.getRandomNumber();
+ "(CONSUMER_KEY, CONSUMER_SECRET, USERNAME, TENANT_ID, OAUTH_VERSION, APP_NAME, CALLBACK_URL) VALUES (?,?,?,?,?,?, ?) "; String consumerKey; String consumerSecret = OAuthUtil.getRandomNumber(); consumerKey = OAuthUtil.getRandomNumber(); } while (isDuplicateConsumer(consumerKey));
/** * Regenerate consumer secret for the application and retrieve application details. * * @param consumerKey Consumer key for the application. * @return OAuthConsumerAppDTO OAuth application details. * @throws IdentityOAuthAdminException Error while regenerating the consumer secret. */ public OAuthConsumerAppDTO updateAndRetrieveOauthSecretKey(String consumerKey) throws IdentityOAuthAdminException { OAuthConsumerAppDTO oAuthConsumerAppDTO = new OAuthConsumerAppDTO(); String newSecretKey = OAuthUtil.getRandomNumber(); CacheEntry clientCredentialDO = new ClientCredentialDO(newSecretKey); oAuthConsumerAppDTO.setOauthConsumerKey(consumerKey); oAuthConsumerAppDTO.setOauthConsumerSecret(newSecretKey); Properties properties = new Properties(); properties.setProperty(OAuthConstants.OAUTH_APP_NEW_SECRET_KEY, newSecretKey); properties.setProperty(OAuthConstants.ACTION_PROPERTY_KEY, OAuthConstants.ACTION_REGENERATE); updateAppAndRevokeTokensAndAuthzCodes(consumerKey, properties); OAuthCache.getInstance().addToCache(new OAuthCacheKey(consumerKey), clientCredentialDO); if (log.isDebugEnabled()) { log.debug("Client Secret for OAuth app with consumerKey: " + consumerKey + " updated in OAuthCache."); } return oAuthConsumerAppDTO; }
/** * @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; }
/** * @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; }
String oauthToken = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); String oauthSecret = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber();
oAuthAppDO.setOauthConsumerSecret(OAuthUtil.getRandomNumber());
String oauthToken = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); String oauthSecret = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber();
app.setState(APP_STATE_ACTIVE); if (StringUtils.isEmpty(application.getOauthConsumerKey())) { app.setOauthConsumerKey(OAuthUtil.getRandomNumber()); app.setOauthConsumerSecret(OAuthUtil.getRandomNumber()); } else { app.setOauthConsumerKey(application.getOauthConsumerKey()); if (StringUtils.isEmpty(application.getOauthConsumerSecret())) { app.setOauthConsumerSecret(OAuthUtil.getRandomNumber()); } else { app.setOauthConsumerSecret(application.getOauthConsumerSecret());
app.setOauthConsumerKey(OAuthUtil.getRandomNumber()); app.setOauthConsumerSecret(OAuthUtil.getRandomNumber()); } else { app.setOauthConsumerKey(application.getOauthConsumerKey());
String oauthVerifier = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); Parameters token = dao.authorizeOAuthToken(params.getOauthToken(), tenantUser, oauthVerifier);
String oauthVerifier = org.wso2.carbon.identity.oauth.OAuthUtil.getRandomNumber(); Parameters token = dao.authorizeOAuthToken(params.getOauthToken(), tenantUser, oauthVerifier);