/** * @param consumerKey * @param newState * @throws IdentityOAuthAdminException */ public void updateConsumerAppState(String consumerKey, String newState) throws IdentityOAuthAdminException { OAuthAppDAO oAuthAppDAO = new OAuthAppDAO(); try { OAuthAppDO oAuthAppDO = AppInfoCache.getInstance().getValueFromCache(consumerKey); if (oAuthAppDO == null) { oAuthAppDO = oAuthAppDAO.getAppInformation(consumerKey); } // change the state oAuthAppDO.setState(newState); Properties properties = new Properties(); properties.setProperty(OAuthConstants.OAUTH_APP_NEW_STATE, newState); properties.setProperty(OAuthConstants.ACTION_PROPERTY_KEY, OAuthConstants.ACTION_REVOKE); updateAppAndRevokeTokensAndAuthzCodes(consumerKey, properties); AppInfoCache.getInstance().addToCache(consumerKey, oAuthAppDO); if (log.isDebugEnabled()) { log.debug("App state is updated to:" + newState + " in the AppInfoCache for OAuth App with " + "consumerKey: " + consumerKey); } } catch (InvalidOAuthClientException | IdentityOAuth2Exception e) { throw handleError("Error while updating state of OAuth app with consumerKey: " + consumerKey, e); } }
/** * Get OAuth application data by the consumer key. * * @param consumerKey Consumer Key * @return <code>OAuthConsumerAppDTO</code> with application information * @throws IdentityOAuthAdminException Error when reading application information from persistence store. */ public OAuthConsumerAppDTO getOAuthApplicationData(String consumerKey) throws IdentityOAuthAdminException { OAuthConsumerAppDTO dto; OAuthAppDAO dao = new OAuthAppDAO(); try { OAuthAppDO app = dao.getAppInformation(consumerKey); if (app != null) { dto = buildConsumerAppDTO(app); if (log.isDebugEnabled()) { log.debug("Found App :" + dto.getApplicationName() + " for consumerKey: " + consumerKey); } } else { dto = new OAuthConsumerAppDTO(); } return dto; } catch (InvalidOAuthClientException | IdentityOAuth2Exception e) { throw handleError("Error while retrieving the app information using consumerKey: " + consumerKey, e); } }
private OAuthAppDO getAppInformation(OAuth2AuthorizeReqDTO authzReqDTO) throws IdentityOAuth2Exception, InvalidOAuthClientException { OAuthAppDO oAuthAppDO = appInfoCache.getValueFromCache(authzReqDTO.getConsumerKey()); if (oAuthAppDO != null) { return oAuthAppDO; } else { oAuthAppDO = new OAuthAppDAO().getAppInformation(authzReqDTO.getConsumerKey()); appInfoCache.addToCache(authzReqDTO.getConsumerKey(), oAuthAppDO); return oAuthAppDO; } }
/** * Get Oauth application information * * @param clientId * @return Oauth app information * @throws IdentityOAuth2Exception * @throws InvalidOAuthClientException */ public static OAuthAppDO getAppInformationByClientId(String clientId) throws IdentityOAuth2Exception, InvalidOAuthClientException { OAuthAppDO oAuthAppDO = AppInfoCache.getInstance().getValueFromCache(clientId); if (oAuthAppDO != null) { return oAuthAppDO; } else { oAuthAppDO = new OAuthAppDAO().getAppInformation(clientId); AppInfoCache.getInstance().addToCache(clientId, oAuthAppDO); return oAuthAppDO; } }
/** * Get Oauth application information * * @param clientId * @return Oauth app information * @throws IdentityOAuth2Exception * @throws InvalidOAuthClientException */ public static OAuthAppDO getAppInformationByClientId(String clientId) throws IdentityOAuth2Exception, InvalidOAuthClientException { OAuthAppDO oAuthAppDO = AppInfoCache.getInstance().getValueFromCache(clientId); if (oAuthAppDO != null) { return oAuthAppDO; } else { oAuthAppDO = new OAuthAppDAO().getAppInformation(clientId); AppInfoCache.getInstance().addToCache(clientId, oAuthAppDO); return oAuthAppDO; } }
private OAuthAppDO getAppInformation(OAuth2AuthorizeReqDTO authzReqDTO) throws IdentityOAuth2Exception, InvalidOAuthClientException { OAuthAppDO oAuthAppDO = AppInfoCache.getInstance().getValueFromCache(authzReqDTO.getConsumerKey()); if (oAuthAppDO != null) { return oAuthAppDO; } else { oAuthAppDO = new OAuthAppDAO().getAppInformation(authzReqDTO.getConsumerKey()); AppInfoCache.getInstance().addToCache(authzReqDTO.getConsumerKey(), oAuthAppDO); return oAuthAppDO; } }
if (dao.isDuplicateConsumer(inboundAuthKey)) { try { OAuthAppDO appInformation = dao.getAppInformation(inboundAuthKey); if (!appInformation.getApplicationName().equals( serviceProvider.getApplicationName())) {
@Override public boolean validateGrant(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception { OAuth2AccessTokenReqDTO tokenReqDTO = tokReqMsgCtx.getOauth2AccessTokenReqDTO(); String grantType = tokenReqDTO.getGrantType(); // Load application data from the cache AppInfoCache appInfoCache = AppInfoCache.getInstance(); OAuthAppDO oAuthAppDO = appInfoCache.getValueFromCache(tokenReqDTO.getClientId()); if (oAuthAppDO == null) { try { oAuthAppDO = new OAuthAppDAO().getAppInformation(tokenReqDTO.getClientId()); appInfoCache.addToCache(tokenReqDTO.getClientId(), oAuthAppDO); } catch (InvalidOAuthClientException e) { throw new IdentityOAuth2Exception(e.getMessage(), e); } } // If the application has defined a limited set of grant types, then check the grant if (oAuthAppDO.getGrantTypes() != null && !oAuthAppDO.getGrantTypes().contains(grantType)) { if (log.isDebugEnabled()) { //Do not change this log format as these logs use by external applications log.debug("Unsupported Grant Type : " + grantType + " for client id : " + tokenReqDTO.getClientId()); } throw new IdentityOAuth2UnAuthorizedClientException("The authenticated client is not authorized to use " + "this authorization grant type"); } return true; } }
oAuthAppDO = new OAuthAppDAO().getAppInformation(clientId); } catch (InvalidOAuthClientException e) { throw new IdentityOAuth2Exception("Invalid OAuth client", e);
/** * 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; }
/** * 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; }
OAuthAppDO appDO; try { appDO = appDAO.getAppInformation(scopedToken.getConsumerKey()); appDTOs.add(buildConsumerAppDTO(appDO)); if (log.isDebugEnabled()) {
OAuthAppDO appDO = oAuthAppDAO.getAppInformation(clientId);
OAuthAppDO appDO; try { appDO = appDAO.getAppInformation(clientId);
OAuthAppDO appDO; try { appDO = appDAO.getAppInformation(scopedToken.getConsumerKey()); appDTO.setOauthConsumerKey(scopedToken.getConsumerKey()); appDTO.setApplicationName(appDO.getApplicationName());
OAuthAppDO appDO = oAuthAppDAO.getAppInformation(clientId);
if (oAuthAppDO == null) { try { oAuthAppDO = new OAuthAppDAO().getAppInformation(authorizationReqDTO.getConsumerKey()); } catch (InvalidOAuthClientException e) { throw new IdentityOAuth2Exception("Invalid consumer application. Failed to issue Grant token.", e);
OAuthAppDO appDO; try { appDO = appDAO.getAppInformation(clientId);
OAuthAppDO oauthappdo; try { oauthappdo = dao.getAppInformation(consumerAppDTO.getOauthConsumerKey()); if (oauthappdo == null) { if (log.isDebugEnabled()) {
/** * 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); } }