/** * @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); }
private void handleSpOIDCProperties(Connection connection, String preprocessedClientId, String spTenantDomain, OAuthAppDO oauthApp) throws IdentityOAuth2Exception { Map<String, List<String>> spOIDCProperties = getSpOIDCProperties(connection, preprocessedClientId, spTenantDomain); // Set OIDC properties to IDP_OIDC_PROPERTY table. setSpOIDCProperties(spOIDCProperties, oauthApp); }
/** * @return * @throws IdentityOAuthAdminException */ public String getOauthApplicationState(String consumerKey) throws IdentityOAuthAdminException { OAuthAppDAO oAuthAppDAO = new OAuthAppDAO(); return oAuthAppDAO.getConsumerAppState(consumerKey); }
/** * 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; }
private void setValuesToStatementWithPKCENoOwnerUpdate(OAuthAppDO oauthAppDO, PreparedStatement prepStmt) throws SQLException, IdentityOAuth2Exception { prepStmt.setString(4, oauthAppDO.isPkceMandatory() ? "1" : "0"); prepStmt.setString(5, oauthAppDO.isPkceSupportPlain() ? "1" : "0"); prepStmt.setLong(6, oauthAppDO.getUserAccessTokenExpiryTime()); prepStmt.setLong(7, oauthAppDO.getApplicationAccessTokenExpiryTime()); prepStmt.setLong(8, oauthAppDO.getRefreshTokenExpiryTime()); prepStmt.setLong(9, oauthAppDO.getIdTokenExpiryTime()); prepStmt.setString(10, persistenceProcessor.getProcessedClientId(oauthAppDO.getOauthConsumerKey())); }
private void setValuesToStatementWithNoPKCEAndNoOwnerUpdate(OAuthAppDO oauthAppDO, PreparedStatement prepStmt) throws SQLException, IdentityOAuth2Exception { prepStmt.setLong(4, oauthAppDO.getUserAccessTokenExpiryTime()); prepStmt.setLong(5, oauthAppDO.getApplicationAccessTokenExpiryTime()); prepStmt.setLong(6, oauthAppDO.getRefreshTokenExpiryTime()); prepStmt.setLong(7, oauthAppDO.getIdTokenExpiryTime()); prepStmt.setString(8, persistenceProcessor.getProcessedClientId(oauthAppDO.getOauthConsumerKey())); }
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; } }
private void addOrUpdateOIDCSpProperty(String preprocessedClientId, int spTenantId, Map<String, List<String>> spOIDCProperties, String propertyKey, String propertyValue, PreparedStatement preparedStatementForPropertyAdd, PreparedStatement preparedStatementForPropertyUpdate) throws SQLException { if (propertyAlreadyExists(spOIDCProperties, propertyKey)) { addToBatchForOIDCPropertyUpdate(preprocessedClientId, spTenantId, preparedStatementForPropertyUpdate, propertyKey, propertyValue); } else { addToBatchForOIDCPropertyAdd(preprocessedClientId, spTenantId, preparedStatementForPropertyAdd, propertyKey, propertyValue); } }
/** * Get the tenant domain of an oauth application * * @param oAuthAppDO * @return */ public static String getTenantDomainOfOauthApp(OAuthAppDO oAuthAppDO) { String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; if (oAuthAppDO != null) { AuthenticatedUser appDeveloper = oAuthAppDO.getUser(); tenantDomain = appDeveloper.getTenantDomain(); } return tenantDomain; }
private long getIDTokenExpiryInMillis(OAuthAppDO oAuthAppDO) { return oAuthAppDO.getIdTokenExpiryTime() * 1000L; }
/** * @deprecated use {@link #setAppOwner(AuthenticatedUser)} instead. */ @Deprecated public void setUser(AuthenticatedUser user) { this.setAppOwner(user); }
/** * @deprecated use {@link #getAppOwner()} instead. */ @Deprecated public AuthenticatedUser getUser() { return this.getAppOwner(); }
/** * Checks if the client can bypass credentials. * * @param clientId Client ID * @return True is the client can bypass credentials, False otherwise. * @throws IdentityOAuth2Exception OAuth2 exception. * @throws InvalidOAuthClientException Invalid OAuth2 client exception. */ private boolean canBypassClientCredentials(String clientId) throws IdentityOAuth2Exception, InvalidOAuthClientException { return OAuth2Util.getAppInformationByClientId(clientId).isBypassClientCredentials(); }
private long getRefreshTokenValidityPeriod(long refreshTokenValidityPeriod, OAuthAppDO oAuthAppDO) { // If issuing new refresh token, use default refresh token validity Period // otherwise use existing refresh token's validity period if (refreshTokenValidityPeriod == 0) { if (oAuthAppDO.getRefreshTokenExpiryTime() != 0) { refreshTokenValidityPeriod = oAuthAppDO.getRefreshTokenExpiryTime() * SECONDS_TO_MILISECONDS_FACTOR; } else { refreshTokenValidityPeriod = OAuthServerConfiguration.getInstance() .getRefreshTokenValidityPeriodInSeconds() * SECONDS_TO_MILISECONDS_FACTOR; } } return refreshTokenValidityPeriod; }
/** * 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; }
/** * @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); }
public String getOauthApplicationState(String consumerKey) { OAuthAppDAO oAuthAppDAO = new OAuthAppDAO(); try { return oAuthAppDAO.getConsumerAppState(consumerKey); } catch (IdentityOAuthAdminException e) { log.error("Error while getting oauth app state", e); return null; } }
/** * Get the tenant domain of an oauth application * * @param oAuthAppDO * @return */ public static String getTenantDomainOfOauthApp(OAuthAppDO oAuthAppDO) { String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; if (oAuthAppDO != null) { AuthenticatedUser appDeveloper = oAuthAppDO.getUser(); tenantDomain = appDeveloper.getTenantDomain(); } return tenantDomain; }
private String getClientSecret(String inboundAuthKey) throws IdentityOAuthAdminException { OAuthConsumerDAO dao = new OAuthConsumerDAO(); return dao.getOAuthConsumerSecret(inboundAuthKey); }
private String getClientSecret(String inboundAuthKey) throws IdentityOAuthAdminException { OAuthConsumerDAO dao = new OAuthConsumerDAO(); return dao.getOAuthConsumerSecret(inboundAuthKey); }