private long getValidityPeriodForApplicationUser(String consumerKey, OAuthAppDO oAuthAppBean) { long validityPeriodInMillis;// If the user is an application user if (oAuthAppBean.getUserAccessTokenExpiryTime() != 0) { validityPeriodInMillis = oAuthAppBean.getUserAccessTokenExpiryTime() * SECONDS_TO_MILISECONDS_FACTOR; if (log.isDebugEnabled()) { log.debug("OAuth application id: " + consumerKey + ", user access token validity time " + validityPeriodInMillis + "ms"); } } else { validityPeriodInMillis = OAuthServerConfiguration.getInstance(). getUserAccessTokenValidityPeriodInSeconds() * SECONDS_TO_MILISECONDS_FACTOR; } return validityPeriodInMillis; }
private long getValidityPeriodInMillis(OAuthTokenReqMessageContext tokReqMsgCtx, OAuthAppDO oAuthAppDO) { long validityPeriodInMillis; if (oAuthAppDO.getUserAccessTokenExpiryTime() != 0) { validityPeriodInMillis = oAuthAppDO.getUserAccessTokenExpiryTime() * SECONDS_TO_MILISECONDS_FACTOR; } else { validityPeriodInMillis = OAuthServerConfiguration.getInstance() .getUserAccessTokenValidityPeriodInSeconds() * SECONDS_TO_MILISECONDS_FACTOR; } // if a VALID validity period is set through the callback, then use it long callbackValidityPeriod = tokReqMsgCtx.getValidityPeriod(); if (callbackValidityPeriod != OAuthConstants.UNASSIGNED_VALIDITY_PERIOD) { validityPeriodInMillis = callbackValidityPeriod * SECONDS_TO_MILISECONDS_FACTOR; } return validityPeriodInMillis; }
/** * Get token validity period for the Self contained JWT Access Token. (For implicit grant) * * @param authzReqMessageContext * @param oAuthAppDO * @param consumerKey * @return * @throws IdentityOAuth2Exception */ protected long getAccessTokenLifeTimeInMillis(OAuthAuthzReqMessageContext authzReqMessageContext, OAuthAppDO oAuthAppDO, String consumerKey) throws IdentityOAuth2Exception { long lifetimeInMillis = oAuthAppDO.getUserAccessTokenExpiryTime() * 1000; if (lifetimeInMillis == 0) { lifetimeInMillis = OAuthServerConfiguration.getInstance() .getUserAccessTokenValidityPeriodInSeconds() * 1000; if (log.isDebugEnabled()) { log.debug("User access token time was 0ms. Setting default user access token lifetime : " + lifetimeInMillis + "ms."); } } if (log.isDebugEnabled()) { log.debug("JWT Self Signed Access Token Life time set to : " + lifetimeInMillis + "ms."); } return lifetimeInMillis; }
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 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 OAuthAppDO getoAuthApp(String consumerKey) throws IdentityOAuth2Exception { OAuthAppDO oAuthAppBean; try { oAuthAppBean = OAuth2Util.getAppInformationByClientId(consumerKey); if (log.isDebugEnabled()) { log.debug("Service Provider specific expiry time enabled for application : " + consumerKey + ". Application access token expiry time : " + oAuthAppBean.getApplicationAccessTokenExpiryTime() + ", User access token expiry time : " + oAuthAppBean.getUserAccessTokenExpiryTime() + ", Refresh token expiry time : " + oAuthAppBean.getRefreshTokenExpiryTime()); } } catch (InvalidOAuthClientException e) { throw new IdentityOAuth2Exception("Error while retrieving app information for clientId : " + consumerKey, e); } return oAuthAppBean; }
private void setValuesToStatementWithOwnerUpdateNoPKCE(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, oauthAppDO.getAppOwner().getUserName()); prepStmt.setString(9, oauthAppDO.getAppOwner().getUserStoreDomain()); prepStmt.setString(10, persistenceProcessor.getProcessedClientId(oauthAppDO.getOauthConsumerKey())); }
private void setValuesToStatementWithPKCEAndOwnerUpdate(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, oauthAppDO.getAppOwner().getUserName()); prepStmt.setString(11, oauthAppDO.getAppOwner().getUserStoreDomain()); prepStmt.setString(12, persistenceProcessor.getProcessedClientId(oauthAppDO.getOauthConsumerKey())); }
private static OAuthAppDO getOAuthApp(String consumerKey) throws IdentityOAuth2Exception { OAuthAppDO oAuthAppBean; try { oAuthAppBean = OAuth2Util.getAppInformationByClientId(consumerKey); if (log.isDebugEnabled()) { log.debug("Service Provider specific expiry time enabled for application : " + consumerKey + ". " + "Application access token expiry time : " + oAuthAppBean.getApplicationAccessTokenExpiryTime () + ", User access token expiry time : " + oAuthAppBean.getUserAccessTokenExpiryTime() + ", " + "" + "Refresh token expiry time : " + oAuthAppBean.getRefreshTokenExpiryTime()); } } catch (InvalidOAuthClientException e) { throw new IdentityOAuth2Exception("Error while retrieving app information for clientId : " + consumerKey, e); } return oAuthAppBean; }
private static long getConfiguredAccessTokenValidityPeriodInMillis(OAuthAuthzReqMessageContext oauthAuthzMsgCtx, OAuthAppDO oAuthAppBean) throws IdentityOAuth2Exception { long validityPeriodInMillis; long callbackValidityPeriod = oauthAuthzMsgCtx.getAccessTokenValidityPeriod(); if (callbackValidityPeriod != OAuthConstants.UNASSIGNED_VALIDITY_PERIOD && callbackValidityPeriod > 0) { // If a valid validity period is set through the callback, use it. validityPeriodInMillis = callbackValidityPeriod * SECOND_TO_MILLISECONDS_FACTOR; if (log.isDebugEnabled()) { log.debug("OAuth application id : " + oAuthAppBean.getOauthConsumerKey() + ", using access token " + "validity period configured from callback: " + validityPeriodInMillis + " ms"); } } else if (oAuthAppBean.getUserAccessTokenExpiryTime() != 0) { // Get user access token expiry time configured for OAuth application. validityPeriodInMillis = oAuthAppBean.getUserAccessTokenExpiryTime() * SECOND_TO_MILLISECONDS_FACTOR; if (log.isDebugEnabled()) { log.debug("OAuth application id: " + oAuthAppBean.getOauthConsumerKey() + ", using user access token " + "" + "validity period configured for application: " + validityPeriodInMillis + " ms"); } } else { // Get user access token expiry time configured over global configuration in identity.xml file. validityPeriodInMillis = OAuthServerConfiguration.getInstance(). getUserAccessTokenValidityPeriodInSeconds() * SECOND_TO_MILLISECONDS_FACTOR; if (log.isDebugEnabled()) { log.debug("OAuth application id: " + oAuthAppBean.getOauthConsumerKey() + ", using user access token " + "" + "validity period configured for server: " + validityPeriodInMillis + " ms"); } } return validityPeriodInMillis; }
private OAuthAppDO getOAuthApp(String clientId) throws IdentityOAuth2Exception { OAuthAppDO oAuthAppDO; try { oAuthAppDO = OAuth2Util.getAppInformationByClientId(clientId); } catch (InvalidOAuthClientException e) { throw new IdentityOAuth2Exception("Error while retrieving app information for clientId: " + clientId, e); } if (log.isDebugEnabled()) { log.debug("Service Provider specific expiry time enabled for application : " + clientId + ". Application access token expiry time : " + oAuthAppDO.getApplicationAccessTokenExpiryTime() + ", User access token expiry time : " + oAuthAppDO.getUserAccessTokenExpiryTime() + ", Refresh token expiry time : " + oAuthAppDO.getRefreshTokenExpiryTime()); } return oAuthAppDO; }
lifetimeInMillis = oAuthAppDO.getUserAccessTokenExpiryTime() * 1000; if (log.isDebugEnabled()) { log.debug("User Access Token Life time set to : " + lifetimeInMillis + "ms.");
prepStmt.setString(10, consumerAppDO.isPkceMandatory() ? "1" : "0"); prepStmt.setString(11, consumerAppDO.isPkceSupportPlain() ? "1" : "0"); prepStmt.setLong(12, consumerAppDO.getUserAccessTokenExpiryTime()); prepStmt.setLong(13, consumerAppDO.getApplicationAccessTokenExpiryTime()); prepStmt.setLong(14, consumerAppDO.getRefreshTokenExpiryTime()); prepStmt.setString(8, consumerAppDO.getCallbackUrl()); prepStmt.setString(9, consumerAppDO.getGrantTypes()); prepStmt.setLong(10, consumerAppDO.getUserAccessTokenExpiryTime()); prepStmt.setLong(11, consumerAppDO.getApplicationAccessTokenExpiryTime()); prepStmt.setLong(12, consumerAppDO.getRefreshTokenExpiryTime());
log.debug("Service Provider specific expiry time enabled for application : " + consumerKey + ". Application access token expiry time : " + oAuthAppDO.getApplicationAccessTokenExpiryTime() + ", User access token expiry time : " + oAuthAppDO.getUserAccessTokenExpiryTime() + ", Refresh token expiry time : " + oAuthAppDO.getRefreshTokenExpiryTime()); if (oAuthAppDO.getUserAccessTokenExpiryTime() != 0) { validityPeriodInMillis = oAuthAppDO.getUserAccessTokenExpiryTime() * 1000;
dto.setPkceMandatory(appDO.isPkceMandatory()); dto.setPkceSupportPlain(appDO.isPkceSupportPlain()); dto.setUserAccessTokenExpiryTime(appDO.getUserAccessTokenExpiryTime()); dto.setApplicationAccessTokenExpiryTime(appDO.getApplicationAccessTokenExpiryTime()); dto.setRefreshTokenExpiryTime(appDO.getRefreshTokenExpiryTime());