/** * 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); } }
/** * Get OAuth application data by the application name. * * @param appName OAuth application name * @return <code>OAuthConsumerAppDTO</code> with application information * @throws IdentityOAuthAdminException Error when reading application information from persistence store. */ public OAuthConsumerAppDTO getOAuthApplicationDataByAppName(String appName) throws IdentityOAuthAdminException { OAuthConsumerAppDTO dto; OAuthAppDAO dao = new OAuthAppDAO(); try { OAuthAppDO app = dao.getAppInformationByAppName(appName); if (app != null) { dto = buildConsumerAppDTO(app); } else { dto = new OAuthConsumerAppDTO(); } return dto; } catch (InvalidOAuthClientException | IdentityOAuth2Exception e) { throw handleError("Error while retrieving the app information by app name: " + appName, e); } }
/** * Get all registered OAuth applications for the logged in user. * * @return An array of <code>OAuthConsumerAppDTO</code> objecting containing the application * information of the user * @throws IdentityOAuthAdminException Error when reading the data from the persistence store. */ public OAuthConsumerAppDTO[] getAllOAuthApplicationData() throws IdentityOAuthAdminException { String userName = CarbonContext.getThreadLocalCarbonContext().getUsername(); OAuthConsumerAppDTO[] dtos = new OAuthConsumerAppDTO[0]; if (userName == null) { if (log.isDebugEnabled()) { log.debug("User not logged in to get all registered OAuth Applications"); } throw new IdentityOAuthAdminException("User not logged in to get all registered OAuth Applications"); } int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); OAuthAppDAO dao = new OAuthAppDAO(); OAuthAppDO[] apps = dao.getOAuthConsumerAppsOfUser(userName, tenantId); if (apps != null && apps.length > 0) { dtos = new OAuthConsumerAppDTO[apps.length]; OAuthAppDO app; for (int i = 0; i < apps.length; i++) { app = apps[i]; dtos[i] = buildConsumerAppDTO(app); } } return dtos; }
try { appDO = appDAO.getAppInformation(scopedToken.getConsumerKey()); appDTOs.add(buildConsumerAppDTO(appDO)); if (log.isDebugEnabled()) { log.debug("Found App: " + appDO.getApplicationName() + " for user: " + username);