/** * 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; }
log.debug("CallbackURL is set to : " + callbackUrl); oAuthConsumerAppDTO.setOauthConsumerKey(consumerKey); if (applicationName != null && !applicationName.isEmpty()) { oAuthConsumerAppDTO.setApplicationName(applicationName);
log.debug("CallbackURL is set to : " + callbackUrl); oAuthConsumerAppDTO.setOauthConsumerKey(consumerKey); if (applicationName != null && !applicationName.isEmpty()) { oAuthConsumerAppDTO.setApplicationName(applicationName);
String clientIdRegex = OAuthServerConfiguration.getInstance().getClientIdValidationRegex(); if (clientIdMatchesRegex(registrationRequest.getConsumerKey(), clientIdRegex)) { oAuthConsumerApp.setOauthConsumerKey(registrationRequest.getConsumerKey()); } else { throw DCRMUtils.generateClientException(DCRMConstants.ErrorMessages.BAD_REQUEST_CLIENT_ID_VIOLATES_PATTERN,
try { appDO = appDAO.getAppInformation(scopedToken.getConsumerKey()); appDTO.setOauthConsumerKey(scopedToken.getConsumerKey()); appDTO.setApplicationName(appDO.getApplicationName()); appDTO.setUsername(appDO.getUser().toString());
String clientId = (String) jsonObj.get(APIConstants.JSON_CLIENT_ID); if (!clientId.isEmpty()) { oAuthConsumerAppDTO.setOauthConsumerKey(clientId); if (jsonObj.has(APIConstants.JSON_CLIENT_SECRET)) { String clientSecret = (String) jsonObj.get(APIConstants.JSON_CLIENT_SECRET);
dto.setApplicationName(app.getApplicationName()); dto.setCallbackUrl(app.getCallbackUrl()); dto.setOauthConsumerKey(app.getOauthConsumerKey()); dto.setOauthConsumerSecret(app.getOauthConsumerSecret()); dto.setOAuthVersion(app.getOauthVersion());
/** * Get OAuth application data by the consumer key. * * @param consumerKey Consumer Key * @return <code>OAuthConsumerAppDTO</code> with application information * @throws Exception Error when reading application information from persistence store. */ public OAuthConsumerAppDTO getOAuthApplicationData(String consumerKey) throws IdentityOAuthAdminException { OAuthConsumerAppDTO dto = new OAuthConsumerAppDTO(); OAuthAppDAO dao = new OAuthAppDAO(); try { OAuthAppDO app = dao.getAppInformation(consumerKey); if (app != null) { dto.setApplicationName(app.getApplicationName()); dto.setCallbackUrl(app.getCallbackUrl()); dto.setOauthConsumerKey(app.getOauthConsumerKey()); dto.setOauthConsumerSecret(app.getOauthConsumerSecret()); dto.setOAuthVersion(app.getOauthVersion()); dto.setGrantTypes(app.getGrantTypes()); dto.setPkceMandatory(app.isPkceMandatory()); dto.setPkceSupportPlain(app.isPkceSupportPlain()); } return dto; } catch (InvalidOAuthClientException | IdentityOAuth2Exception e) { throw new IdentityOAuthAdminException("Error while retrieving the app information using consumer key", e); } }
/** * Get OAuth application data by the application name. * * @param appName OAuth application name * @return <code>OAuthConsumerAppDTO</code> with application information * @throws Exception Error when reading application information from persistence store. */ public OAuthConsumerAppDTO getOAuthApplicationDataByAppName(String appName) throws IdentityOAuthAdminException { OAuthConsumerAppDTO dto = new OAuthConsumerAppDTO(); OAuthAppDAO dao = new OAuthAppDAO(); try { OAuthAppDO app = dao.getAppInformationByAppName(appName); if (app != null) { dto.setApplicationName(app.getApplicationName()); dto.setCallbackUrl(app.getCallbackUrl()); dto.setOauthConsumerKey(app.getOauthConsumerKey()); dto.setOauthConsumerSecret(app.getOauthConsumerSecret()); dto.setOAuthVersion(app.getOauthVersion()); dto.setGrantTypes(app.getGrantTypes()); dto.setPkceMandatory(app.isPkceMandatory()); dto.setPkceSupportPlain(app.isPkceSupportPlain()); } return dto; } catch (InvalidOAuthClientException | IdentityOAuth2Exception e) { throw new IdentityOAuthAdminException("Error while retrieving the app information by app name", e); } }
dto.setApplicationName(appDO.getApplicationName()); dto.setCallbackUrl(appDO.getCallbackUrl()); dto.setOauthConsumerKey(appDO.getOauthConsumerKey()); dto.setOauthConsumerSecret(appDO.getOauthConsumerSecret()); dto.setOAuthVersion(appDO.getOauthVersion());