public static FrameworkException error(String message, Throwable cause) { return new FrameworkException(message, cause); } }
public HttpIdentityResponse.HttpIdentityResponseBuilder handleException(FrameworkException exception) { HttpIdentityResponse.HttpIdentityResponseBuilder builder = new HttpIdentityResponse.HttpIdentityResponseBuilder(); String errorMessage = ""; if (ErrorCodes.META_DATA_VALIDATION_FAILED.name().equals(exception.getErrorCode())) { errorMessage = generateErrorResponse(INVALID_CLIENT_METADATA, exception.getMessage()).toJSONString(); } else if (ErrorCodes.BAD_REQUEST.name().equals(exception.getErrorCode())) { errorMessage = generateErrorResponse(BACKEND_FAILED, exception.getMessage()).toJSONString(); } builder.setBody(errorMessage); builder.setStatusCode(HttpServletResponse.SC_BAD_REQUEST); builder.addHeader(OAuthConstants.HTTP_RESP_HEADER_CACHE_CONTROL, OAuthConstants.HTTP_RESP_HEADER_VAL_CACHE_CONTROL_NO_STORE); builder.addHeader(OAuthConstants.HTTP_RESP_HEADER_PRAGMA, OAuthConstants.HTTP_RESP_HEADER_VAL_PRAGMA_NO_CACHE); builder.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); return builder; }
public HttpIdentityResponse.HttpIdentityResponseBuilder handleException(FrameworkException exception) { HttpIdentityResponse.HttpIdentityResponseBuilder builder = new HttpIdentityResponse.HttpIdentityResponseBuilder(); builder.setStatusCode(500); builder.setBody(exception.getMessage()); return builder; } }
public static FrameworkException error(String message) { return new FrameworkException(message); }
private String getCallerPath(HttpServletRequest request) throws FrameworkException { String callerPath = request.getParameter(FrameworkConstants.RequestParams.CALLER_PATH); try { if (callerPath != null) { callerPath = URLDecoder.decode(callerPath, "UTF-8"); } } catch (UnsupportedEncodingException e) { throw new FrameworkException(e.getMessage(), e); } return callerPath; }
private String getCallerPath(HttpServletRequest request) throws FrameworkException { String callerPath = request.getParameter(FrameworkConstants.RequestParams.CALLER_PATH); try { if (callerPath != null) { callerPath = URLDecoder.decode(callerPath, "UTF-8"); } } catch (UnsupportedEncodingException e) { throw new FrameworkException(e.getMessage(), e); } return callerPath; }
private String getCallerPath(HttpServletRequest request) throws FrameworkException { String callerPath = request.getParameter(FrameworkConstants.RequestParams.CALLER_PATH); try { if (callerPath != null) { callerPath = URLDecoder.decode(callerPath, "UTF-8"); } } catch (UnsupportedEncodingException e) { throw new FrameworkException(e.getMessage(), e); } return callerPath; }
private ClaimManager getClaimManager(String tenantDomain, UserRealm realm) throws FrameworkException { ClaimManager claimManager = null; try { claimManager = realm.getClaimManager(); } catch (UserStoreException e) { throw new FrameworkException("Error occurred while retrieving the ClaimManager " + "from Realm for " + tenantDomain + " to handle local claims", e); } return claimManager; }
private ClaimManager getClaimManager(String tenantDomain, UserRealm realm) throws FrameworkException { ClaimManager claimManager = null; try { claimManager = realm.getClaimManager(); } catch (UserStoreException e) { throw new FrameworkException("Error occurred while retrieving the ClaimManager " + "from Realm for " + tenantDomain + " to handle local claims", e); } return claimManager; }
private ClaimManager getClaimManager(String tenantDomain, UserRealm realm) throws FrameworkException { ClaimManager claimManager = null; try { claimManager = realm.getClaimManager(); } catch (UserStoreException e) { throw new FrameworkException("Error occurred while retrieving the ClaimManager " + "from Realm for " + tenantDomain + " to handle local claims", e); } return claimManager; }
public void removeWaitStatus(String waitKey) throws FrameworkException { String query = "DELETE FROM IDN_AUTH_WAIT_STATUS WHERE LONG_WAIT_KEY=?"; try (Connection connection = IdentityDatabaseUtil.getDBConnection()) { try (PreparedStatement addPrepStmt = connection.prepareStatement(query)) { addPrepStmt.setString(1, waitKey); addPrepStmt.execute(); if (log.isDebugEnabled()) { log.debug("Removed wait status for wait key: " + waitKey); } connection.commit(); } catch (SQLException e) { throw new FrameworkException("Error while removing wait status with key:" + waitKey, e); } } catch (SQLException e) { throw new FrameworkException("Error while removing wait status with key:" + waitKey, e); } }
public void removeWaitStatus(String waitKey) throws FrameworkException { String query = "DELETE FROM IDN_AUTH_WAIT_STATUS WHERE LONG_WAIT_KEY=?"; try (Connection connection = IdentityDatabaseUtil.getDBConnection()) { try (PreparedStatement addPrepStmt = connection.prepareStatement(query)) { addPrepStmt.setString(1, waitKey); addPrepStmt.execute(); if (log.isDebugEnabled()) { log.debug("Removed wait status for wait key: " + waitKey); } connection.commit(); } catch (SQLException e) { throw new FrameworkException("Error while removing wait status with key:" + waitKey, e); } } catch (SQLException e) { throw new FrameworkException("Error while removing wait status with key:" + waitKey, e); } }
public static Object fromJsSerializable(Object value, ScriptEngine engine) throws FrameworkException { if (value instanceof SerializableJsFunction) { SerializableJsFunction serializableJsFunction = (SerializableJsFunction) value; try { return engine.eval(serializableJsFunction.getSource()); } catch (ScriptException e) { throw new FrameworkException("Error in resurrecting a Javascript Function : " + serializableJsFunction); } } else if (value instanceof Map) { Map<String, Object> deserializedMap = new HashMap<>(); for (Entry<String, Object> entry : ((Map<String, Object>) value).entrySet()) { Object deserializedObj = fromJsSerializable(entry.getValue(), engine); deserializedMap.put(entry.getKey(), deserializedObj); } return deserializedMap; } return value; }
public static BundleContext getBundleContext() throws FrameworkException { BundleContext bundleContext = FrameworkServiceDataHolder.getInstance().getBundleContext(); if (bundleContext == null) { String msg = "System has not been started properly. Bundle Context is null."; log.error(msg); throw new FrameworkException(msg); } return bundleContext; }
private String getStandardClaimURIFromLocal(String standardDialect, String tenantDomain, String claimURI) throws FrameworkException { try { Map<String, String> claimMapping = ClaimMetadataHandler.getInstance() .getMappingsMapFromOtherDialectToCarbon(standardDialect, null, tenantDomain, true); if (claimMapping.containsKey(claimURI)) { return claimMapping.get(claimURI); } } catch (ClaimMetadataException e) { throw new FrameworkException("Error while loading mappings.", e); } return null; }
private String getStandardClaimURIFromLocal(String standardDialect, String tenantDomain, String claimURI) throws FrameworkException { try { Map<String, String> claimMapping = ClaimMetadataHandler.getInstance() .getMappingsMapFromOtherDialectToCarbon(standardDialect, null, tenantDomain, true); if (claimMapping.containsKey(claimURI)) { return claimMapping.get(claimURI); } } catch (ClaimMetadataException e) { throw new FrameworkException("Error while loading mappings.", e); } return null; }
/** * This method retrieves requested claim value from the user store * * @param username * @param userStoreManager * @param claimURI * @return claim value as a String * @throws FrameworkException */ private String getClaimValue(String username, UserStoreManager userStoreManager, String claimURI) throws FrameworkException { try { Map<String, String> values = userStoreManager.getUserClaimValues(username, new String[]{claimURI}, UserCoreConstants.DEFAULT_PROFILE); if (log.isDebugEnabled()) { log.debug(String.format("%s claim value of user %s is set to: " + values.get(claimURI), claimURI, username)); } return values.get(claimURI); } catch (UserStoreException e) { throw new FrameworkException("Error occurred while retrieving claim: " + claimURI, e); } } }
public void addWaitStatus(int tenantId, String waitKey, LongWaitStatus status, Timestamp createdTime, Timestamp expireTime) throws FrameworkException { String query = "INSERT INTO IDN_AUTH_WAIT_STATUS (TENANT_ID, LONG_WAIT_KEY, WAIT_STATUS, TIME_CREATED, " + "EXPIRE_TIME) VALUES (?, ?, ?, ?, ?)"; try (Connection connection = IdentityDatabaseUtil.getDBConnection()) { try (PreparedStatement addPrepStmt = connection.prepareStatement(query)) { addPrepStmt.setInt(1, tenantId); addPrepStmt.setString(2, waitKey); if (LongWaitStatus.Status.WAITING == status.getStatus()) { addPrepStmt.setString(3, "1"); } else { addPrepStmt.setString(3, "0"); } addPrepStmt.setTimestamp(4, createdTime); addPrepStmt.setTimestamp(5, expireTime); addPrepStmt.execute(); if (log.isDebugEnabled()) { log.debug("Added wait status for wait key: " + waitKey); } connection.commit(); } catch (SQLException e) { throw new FrameworkException("Error while adding wait status for key:" + waitKey, e); } } catch (SQLException e) { throw new FrameworkException("Error while adding wait status for key:" + waitKey, e); } }
/** * This method retrieves requested claim value from the user store * * @param username * @param userStoreManager * @param claimURI * @return claim value as a String * @throws FrameworkException */ private String getClaimValue(String username, UserStoreManager userStoreManager, String claimURI) throws FrameworkException { try { Map<String, String> values = userStoreManager.getUserClaimValues(username, new String[]{claimURI}, UserCoreConstants.DEFAULT_PROFILE); if (log.isDebugEnabled()) { log.debug(String.format("%s claim value of user %s is set to: " + values.get(claimURI), claimURI, username)); } return values.get(claimURI); } catch (UserStoreException e) { throw new FrameworkException("Error occurred while retrieving claim: " + claimURI, e); } } }
public static Object fromJsSerializable(Object value, ScriptEngine engine) throws FrameworkException { if (value instanceof SerializableJsFunction) { SerializableJsFunction serializableJsFunction = (SerializableJsFunction) value; try { return engine.eval(serializableJsFunction.getSource()); } catch (ScriptException e) { throw new FrameworkException("Error in resurrecting a Javascript Function : " + serializableJsFunction); } } else if (value instanceof Map) { Map<String, Object> deserializedMap = new HashMap<>(); for (Entry<String, Object> entry : ((Map<String, Object>) value).entrySet()) { Object deserializedObj = fromJsSerializable(entry.getValue(), engine); deserializedMap.put(entry.getKey(), deserializedObj); } return deserializedMap; } return value; }