├── .gitignore ├── README.md ├── data-services ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── atg │ │ └── openssp │ │ └── dataprovider │ │ ├── provider │ │ ├── dto │ │ │ └── TokenWrapper.java │ │ └── handler │ │ │ ├── AppDataHandler.java │ │ │ ├── CurrencyDataHandler.java │ │ │ ├── DataHandler.java │ │ │ ├── LoginHandler.java │ │ │ ├── PricelayerDataHandler.java │ │ │ ├── SiteDataHandler.java │ │ │ └── SupplierDataHandler.java │ │ ├── service │ │ ├── AppDataService.java │ │ ├── CoreDataServlet.java │ │ ├── CurrencyDataService.java │ │ ├── LoginService.java │ │ ├── PricelayerDataService.java │ │ ├── SiteDataService.java │ │ └── SupplierDataService.java │ │ └── system │ │ ├── InitLogging.java │ │ └── ServicesInit.java │ ├── resources │ ├── app_db.json │ ├── config.xml │ ├── currency_db.json │ ├── global.runtime.xml │ ├── local.runtime.xml │ ├── log4j2.xml │ ├── price_layer.json │ ├── site_db.json │ └── supplier_db.json │ └── webapp │ └── WEB-INF │ └── web.xml ├── data-sim-client ├── pom.xml ├── run_sim.sh └── src │ └── main │ ├── java │ └── com │ │ └── atg │ │ └── openssp │ │ └── dspSim │ │ ├── DspSimClient.java │ │ ├── ServerHandler.java │ │ ├── model │ │ ├── BaseModel.java │ │ ├── MessageNotificationListener.java │ │ ├── MessageStatus.java │ │ ├── ModelException.java │ │ ├── ad │ │ │ └── AdModel.java │ │ ├── client │ │ │ ├── ServerCommand.java │ │ │ ├── ServerCommandType.java │ │ │ ├── ServerResponse.java │ │ │ └── ServerResponseStatus.java │ │ └── dsp │ │ │ ├── DspModel.java │ │ │ └── SimBidder.java │ │ └── view │ │ └── dsp │ │ ├── DspView.java │ │ └── SimBidderPanel.java │ └── resources │ └── DspSimClient.properties ├── dsp-sim ├── pom.xml ├── run_sim.sh └── src │ └── main │ └── java │ └── com │ └── atg │ └── openssp │ └── dspSim │ ├── AdServerHandler.java │ ├── ClientHandler.java │ ├── DspHandler.java │ ├── DspSim.java │ ├── channel │ └── adserving │ │ └── AdservingCampaignProvider.java │ └── model │ ├── ModelException.java │ ├── ad │ └── AdModel.java │ ├── client │ ├── ClientCommand.java │ ├── ClientCommandType.java │ ├── ClientResponse.java │ └── ClientResponseStatus.java │ └── dsp │ ├── DspModel.java │ ├── SimBidder.java │ └── SimBidderListener.java ├── license └── open-ssp-parent ├── .gitignore ├── TODO ├── channel-adserver ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── channel │ └── adserving │ ├── AdserverBroker.java │ ├── AdservingCampaignProvider.java │ └── AdservingService.java ├── channel-ssp ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── channel │ ├── adapter │ ├── AdapterBuilder.java │ ├── AdapterConnector.java │ ├── SSPAdapter.java │ ├── TrialAdapterBuilder.java │ └── TrialAdapterConnector.java │ ├── cache │ ├── BasicAdapter.java │ ├── SSPAdapterDataBroker.java │ └── SSPAdapterDto.java │ └── ssp │ ├── SSPAdapterCache.java │ ├── SSPBroker.java │ └── SSPService.java ├── core ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── atg │ │ │ └── openssp │ │ │ └── core │ │ │ ├── cache │ │ │ ├── broker │ │ │ │ ├── CacheController.java │ │ │ │ ├── dto │ │ │ │ │ ├── AppDto.java │ │ │ │ │ ├── CurrencyDto.java │ │ │ │ │ ├── PricelayerDto.java │ │ │ │ │ ├── SiteDto.java │ │ │ │ │ └── SupplierDto.java │ │ │ │ ├── json │ │ │ │ │ ├── PricelayerBrokerJson.java │ │ │ │ │ ├── SiteDataBrokerJson.java │ │ │ │ │ └── SupplierDataBrokerJson.java │ │ │ │ └── remote │ │ │ │ │ ├── AbstractRemoteDataProvider.java │ │ │ │ │ ├── RemoteCurrencyDataBroker.java │ │ │ │ │ ├── RemoteSupplierDataBroker.java │ │ │ │ │ ├── RemoteVideoadDataBroker.java │ │ │ │ │ └── RemoteWebsiteDataBroker.java │ │ │ └── type │ │ │ │ ├── ConnectorCache.java │ │ │ │ ├── PricelayerCache.java │ │ │ │ ├── SiteDataCache.java │ │ │ │ ├── VideoAdDataCache.java │ │ │ │ ├── WebsiteDataCache.java │ │ │ │ └── ZoneDataCache.java │ │ │ ├── entry │ │ │ ├── EntryValidator.java │ │ │ └── SupplyVideoService.java │ │ │ ├── exchange │ │ │ ├── Auction.java │ │ │ ├── BidRequestBuilder.java │ │ │ ├── ChannelFactory.java │ │ │ ├── ExchangeServer.java │ │ │ ├── RequestSessionAgent.java │ │ │ ├── RtbAdProvider.java │ │ │ ├── VastResolverBroker.java │ │ │ └── channel │ │ │ │ └── rtb │ │ │ │ ├── DemandBroker.java │ │ │ │ ├── DemandExecutorServiceFacade.java │ │ │ │ ├── DemandService.java │ │ │ │ └── OpenRtbConnector.java │ │ │ └── system │ │ │ ├── AbstractLogger.java │ │ │ ├── ApplicationInit.java │ │ │ ├── InitLogging.java │ │ │ ├── LocalContext.java │ │ │ ├── MetricFactory.java │ │ │ ├── job │ │ │ ├── CacheTriggerController.java │ │ │ ├── CoreCacheLoaderJob.java │ │ │ ├── HeartBeatJob.java │ │ │ ├── JobConfig.java │ │ │ ├── JobService.java │ │ │ ├── ResetCounterJob.java │ │ │ └── WatchdogService.java │ │ │ ├── loader │ │ │ ├── AbstractConfigurationLoader.java │ │ │ ├── ConfigLoader.java │ │ │ ├── GlobalContextLoader.java │ │ │ └── LocalContextLoader.java │ │ │ └── properties │ │ │ └── MavenProperties.java │ ├── resources │ │ ├── config.xml │ │ ├── global.runtime.xml │ │ ├── local.runtime.xml │ │ ├── log4j2.xml │ │ ├── price_layer.json │ │ ├── site_db.json │ │ └── supplier_db.json │ └── webapp │ │ └── WEB-INF │ │ └── web.xml │ └── test │ ├── java │ ├── agent │ │ └── SessionAgentParamsTest.java │ ├── auction │ │ ├── AuctionServiceDealSingleBidTest.java │ │ ├── OpenAuctionServiceDealMultiBidTest.java │ │ ├── PrivateAuctionServiceDealMultiBidTest.java │ │ └── RequestResponseHelper.java │ └── request │ │ └── BidRequestBuilderTest.java │ └── resources │ └── log4j.properties ├── open-ssp-common ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── atg │ └── openssp │ └── common │ ├── annotation │ ├── RuntimeConfig.java │ ├── RuntimeMeta.java │ └── Scope.java │ ├── buffer │ ├── AdservingLatencyBuffer.java │ ├── LongTypedBuffer.java │ ├── SSPLatencyBuffer.java │ └── VastResolverLatencyBuffer.java │ ├── cache │ ├── CurrencyCache.java │ ├── DynamicCache.java │ ├── ListCache.java │ ├── MapCache.java │ ├── broker │ │ ├── AbstractDataBroker.java │ │ └── DataBrokerObserver.java │ └── dto │ │ ├── VideoAd.java │ │ ├── Website.java │ │ └── Zone.java │ ├── configuration │ ├── Context.java │ ├── ContextCache.java │ ├── ContextProperties.java │ └── GlobalContext.java │ ├── core │ ├── broker │ │ └── AbstractBroker.java │ ├── connector │ │ ├── DefaultConnector.java │ │ ├── JsonGetConnector.java │ │ └── JsonPostConnector.java │ ├── entry │ │ ├── CoreSupplyServlet.java │ │ ├── RequestMonitor.java │ │ └── SessionAgent.java │ └── exchange │ │ ├── Exchange.java │ │ └── ExchangeExecutorServiceFacade.java │ ├── demand │ ├── BidExchange.java │ ├── ParamValue.java │ ├── ResponseContainer.java │ └── Supplier.java │ ├── exception │ ├── BidProcessingException.java │ ├── ERROR_CODE.java │ ├── EmptyCacheException.java │ ├── EmptyHostException.java │ ├── InvalidBidException.java │ ├── InvalidDatePattern.java │ ├── NotifyingException.java │ ├── RequestException.java │ └── RtbValidationException.java │ ├── jobservice │ └── CommonJobTrigger.java │ ├── logadapter │ ├── LogFacade.java │ ├── ParamMessage.java │ ├── ProviderLogProcessor.java │ ├── RequestLogProcessor.java │ ├── RtbRequestLogProcessor.java │ └── RtbResponseLogProcessor.java │ ├── model │ ├── Category.java │ ├── Country.java │ ├── EurRef.java │ ├── FactualCategory.java │ ├── Productcategory.java │ └── Taxonomy.java │ ├── provider │ ├── AdProviderReader.java │ ├── AdProviderWriter.java │ ├── MacroPattern.java │ ├── MarkupParser.java │ └── WinningNotifier.java │ └── watchdog │ ├── DynamicLoadable.java │ └── Watchdog.java ├── open-ssp-openrtb-validator ├── .gitignore ├── LICENSE.txt ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── openrtb │ │ │ └── validator │ │ │ ├── GenericOpenRtbValidator.java │ │ │ ├── OpenRtbInputType.java │ │ │ ├── OpenRtbValidator.java │ │ │ ├── OpenRtbValidatorFactory.java │ │ │ ├── OpenRtbVersion.java │ │ │ ├── ValidationResult.java │ │ │ └── ValidatorMain.java │ └── resources │ │ ├── LICENSE.txt │ │ ├── schemas │ │ ├── openrtb-schema_bid-request_v1-0.json │ │ ├── openrtb-schema_bid-request_v2-0.json │ │ ├── openrtb-schema_bid-request_v2-1.json │ │ ├── openrtb-schema_bid-request_v2-2.json │ │ ├── openrtb-schema_bid-request_v2-3.json │ │ ├── openrtb-schema_bid-request_v2-4.json │ │ ├── openrtb-schema_bid-request_with_factual_v2-3.json │ │ ├── openrtb-schema_bid-request_with_factual_v2-4.json │ │ ├── openrtb-schema_bid-response_v1-0.json │ │ ├── openrtb-schema_bid-response_v2-0.json │ │ ├── openrtb-schema_bid-response_v2-1.json │ │ ├── openrtb-schema_bid-response_v2-2.json │ │ ├── openrtb-schema_bid-response_v2-3.json │ │ └── openrtb-schema_bid-response_v2-4.json │ │ └── specifications │ │ ├── OpenRTB-API-Specification-Version-2-1-FINAL.pdf │ │ ├── OpenRTB-API-Specification-Version-2-3.pdf │ │ ├── OpenRTB-API-Specification-Version-2-4-FINAL.pdf │ │ ├── OpenRTBAPISpecificationVersion2_2.pdf │ │ ├── OpenRTB_API_Specification_Version2.0_FINAL.PDF │ │ └── OpenRTB_Mobile_RTB_API-1.0.pdf │ └── test │ ├── java │ └── org │ │ └── openrtb │ │ └── validator │ │ ├── OpenRtbValidatorV1_0Tests.java │ │ ├── OpenRtbValidatorV2_0Tests.java │ │ ├── OpenRtbValidatorV2_1Tests.java │ │ ├── OpenRtbValidatorV2_2Tests.java │ │ ├── OpenRtbValidatorV2_3Tests.java │ │ ├── OpenRtbValidatorV2_4Tests.java │ │ ├── OpenRtbValidatorV2_xTestRunner.java │ │ └── steps │ │ └── OpenRtb2_4BidRequestResponseSteps.java │ └── resources │ ├── features │ ├── openRtbV2_xBidRequest.feature │ └── openRtbV2_xBidResponse.feature │ ├── v1_0 │ ├── bid_requests │ │ ├── full_bid_request_app.json │ │ └── full_bid_request_site.json │ └── bid_responses │ │ └── full_bid_response.json │ ├── v2_0 │ ├── bid_requests │ │ ├── example1_simple_banner.json │ │ ├── example2_expandable_creative.json │ │ ├── example3_mobile.json │ │ ├── example4_video.json │ │ └── fixed │ │ │ ├── example2_expandable_creative.json │ │ │ ├── example3_mobile.json │ │ │ └── example4_video.json │ └── bid_responses │ │ ├── example1_ad_served_on_win_notice.json │ │ ├── example2_vast_url_returned.json │ │ ├── example3_vast_xml_document_returned_inline.json │ │ └── fixed │ │ └── example3_vast_xml_document_returned_inline.json │ ├── v2_1 │ ├── bid_requests │ │ ├── example1_simple_banner.json │ │ ├── example2_expandable_creative.json │ │ ├── example3_mobile.json │ │ ├── example4_video.json │ │ └── fixed │ │ │ ├── example1_simple_banner.json │ │ │ ├── example2_expandable_creative.json │ │ │ ├── example3_mobile.json │ │ │ └── example4_video.json │ └── bid_responses │ │ ├── example1_ad_served_on_win_notice.json │ │ ├── example2_vast_url_returned.json │ │ ├── example3_vast_xml_document_returned_inline.json │ │ └── fixed │ │ └── example3_vast_xml_document_returned_inline.json │ ├── v2_2 │ ├── bid_requests │ │ ├── example1_simple_banner.json │ │ ├── example2_expandable_creative.json │ │ ├── example3_mobile.json │ │ ├── example4_video.json │ │ ├── example5_pmp_with_direct_deal.json │ │ └── fixed │ │ │ ├── example1_simple_banner.json │ │ │ ├── example2_expandable_creative.json │ │ │ ├── example3_mobile.json │ │ │ ├── example4_video.json │ │ │ └── example5_pmp_with_direct_deal.json │ └── bid_responses │ │ ├── example1_ad_served_on_win_notice.json │ │ ├── example2_vast_url_returned.json │ │ ├── example3_vast_xml_document_returned_inline.json │ │ ├── example4_direct_deal_ad_served_on_win_notice.json │ │ └── fixed │ │ └── example3_vast_xml_document_returned_inline.json │ ├── v2_3 │ ├── bid_requests │ │ ├── example1_simple_banner.json │ │ ├── example2_expandable_creative.json │ │ ├── example3_mobile.json │ │ ├── example4_video.json │ │ ├── example5_pmp_with_direct_deal.json │ │ └── example6_native_ad.json │ └── bid_responses │ │ ├── example1_ad_served_on_win_notice.json │ │ ├── example2_vast_url_returned.json │ │ ├── example3_direct_deal_ad_served_on_win_notice.json │ │ └── example4_native_markup_returned_inline.json │ └── v2_4 │ ├── bid_requests │ ├── example1_simple_banner.json │ ├── example2_expandable_creative.json │ ├── example3_mobile.json │ ├── example4_video.json │ ├── example5_pmp_with_direct_deal.json │ └── example6_native_ad.json │ └── bid_responses │ ├── example1_ad_served_on_win_notice.json │ ├── example2_vast_xml_document_returned_inline.json │ ├── example3_direct_deal_ad_served_on_win_notice.json │ └── example4_native_markup_returned_inline.json ├── open-ssp-openrtb ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── openrtb │ ├── bidrequest │ ├── exception │ │ └── BuilderException.java │ └── model │ │ ├── App.java │ │ ├── Banner.java │ │ ├── BidRequest.java │ │ ├── Device.java │ │ ├── DirectDeal.java │ │ ├── Gender.java │ │ ├── Geo.java │ │ ├── Impression.java │ │ ├── PMP.java │ │ ├── Pricelayer.java │ │ ├── Publisher.java │ │ ├── Site.java │ │ ├── User.java │ │ └── Video.java │ ├── bidresponse │ └── model │ │ ├── Bid.java │ │ ├── BidOrBuilder.java │ │ ├── BidResponse.java │ │ ├── SeatBid.java │ │ └── SeatBidOrBuilder.java │ └── tables │ ├── CreativeAttribute.java │ ├── DeviceType.java │ ├── NoBidreason.java │ ├── VideoApiFramework.java │ ├── VideoBidResponseProtocol.java │ └── VideoLinearity.java ├── open-ssp-restful-client ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── restful │ ├── client │ ├── DataProviderConnector.java │ ├── HttpComponentsClientHttpRequestFactoryBasicAuth.java │ ├── JsonDataProviderConnector.java │ ├── LoginService.java │ └── RemoteDataProviderConnector.java │ ├── context │ ├── Path.java │ ├── PathBuilder.java │ └── RestfulContext.java │ └── exception │ └── RestException.java ├── open-ssp-utilities ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── util │ ├── CatalinaUtil.java │ ├── SimpleRingBuffer.java │ ├── math │ └── FloatComparator.java │ └── properties │ └── ProjectProperty.java └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | DSP_SIM_MODEL.json 2 | -------------------------------------------------------------------------------- /data-services/src/main/java/com/atg/openssp/dataprovider/provider/dto/TokenWrapper.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dataprovider.provider.dto; 2 | 3 | /** 4 | * @author André Schmer 5 | */ 6 | public class TokenWrapper { 7 | private String token; 8 | 9 | public String getToken() { 10 | return token; 11 | } 12 | 13 | @SuppressWarnings("unused") 14 | public void setToken(final String token) { 15 | this.token = token; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /data-services/src/main/java/com/atg/openssp/dataprovider/system/InitLogging.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dataprovider.system; 2 | 3 | import util.CatalinaUtil; 4 | 5 | /** 6 | * @author André Schmer 7 | * 8 | */ 9 | class InitLogging { 10 | 11 | static void setSystemProperties() { 12 | System.setProperty("tomcatid", CatalinaUtil.instanceName()); 13 | if (false == "localhost".equals(CatalinaUtil.instanceName())) { 14 | System.setProperty("log4j.configurationFile", CatalinaUtil.catalinaHome() + "/properties/log4j2.xml"); 15 | } 16 | System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); 17 | System.setProperty("pid", CatalinaUtil.pid()); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /data-services/src/main/resources/app_db.json: -------------------------------------------------------------------------------- 1 | { 2 | "apps": [ 3 | { 4 | "id": "1" 5 | } 6 | ] 7 | } -------------------------------------------------------------------------------- /data-services/src/main/resources/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | false 10 | 11 | -------------------------------------------------------------------------------- /data-services/src/main/resources/currency_db.json: -------------------------------------------------------------------------------- 1 | { 2 | "currency": "USD", 3 | "data": [{ 4 | "currency": "EUR", 5 | "rate": 0.80 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /data-services/src/main/resources/global.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 0.3 11 | 12 | 13 | 14 | 500 15 | 16 | 17 | -------------------------------------------------------------------------------- /data-services/src/main/resources/price_layer.json: -------------------------------------------------------------------------------- 1 | { 2 | "pricelayer": [{ 3 | "siteid": "1", 4 | "bidfloor": 1.2, 5 | "currency": "USD" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /data-services/src/main/resources/site_db.json: -------------------------------------------------------------------------------- 1 | { 2 | "sites": [{ 3 | "id": "1", 4 | "name": "site_1", 5 | "domain": "site_1.com", 6 | "cat": ["1"], 7 | "page": "www.site_1.com", 8 | "publisher": { 9 | "id": "pubisher_1", 10 | "name": "publisher_1_name", 11 | "cat": [], 12 | "domain": "www.publisher_1.com", 13 | "ext": null 14 | }, 15 | "ext": null 16 | }, 17 | { 18 | "id": "testsite.com", 19 | "name": "testsite.com", 20 | "domain": "testsite.com", 21 | "cat": ["1"], 22 | "page": "http://alexs-mbp:8000/integrationExamples/gpt/freestar_hello_world.html", 23 | "publisher": { 24 | "id": "testpublisher_1", 25 | "name": "testpublisher 1", 26 | "cat": [], 27 | "domain": "www.testpublisher_1.com", 28 | "ext": null 29 | }, 30 | "ext": null 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /data-services/src/main/resources/supplier_db.json: -------------------------------------------------------------------------------- 1 | { 2 | "supplier": [{ 3 | "shortName": "dsp_1", 4 | "endPoint": "http://localhost:8082/dsp-sim/DemandService", 5 | "connectionKeepAlive": true, 6 | "openRtbVersion": 2.2, 7 | "contentType": "application/json", 8 | "supplierId": "1", 9 | "currency": "USD", 10 | "underTest": 1, 11 | "active": 1 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /data-services/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ATG SSP 4 | 5 | ServicesInit 6 | com.atg.openssp.dataprovider.system.ServicesInit 7 | 1 8 | 9 | -------------------------------------------------------------------------------- /data-sim-client/run_sim.sh: -------------------------------------------------------------------------------- 1 | 2 | java -jar target/open-ssp-dsp-sim-client-0.1-SNAPSHOT.jar 3 | 4 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/DspSimClient.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim; 2 | 3 | import com.atg.openssp.dspSim.model.ModelException; 4 | import com.atg.openssp.dspSim.model.ad.AdModel; 5 | import com.atg.openssp.dspSim.model.dsp.DspModel; 6 | import com.atg.openssp.dspSim.view.dsp.DspView; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import java.io.File; 11 | import java.io.FileInputStream; 12 | import java.io.IOException; 13 | import java.io.InputStream; 14 | import java.util.Properties; 15 | 16 | /** 17 | * @author Brian Sorensen 18 | */ 19 | public class DspSimClient { 20 | private static final Logger log = LoggerFactory.getLogger(DspSimClient.class); 21 | private final Properties props = new Properties(); 22 | private final DspView dspView; 23 | private DspModel dspModel; 24 | private AdModel adModel; 25 | 26 | public DspSimClient() throws ModelException { 27 | load(props); 28 | dspModel = new DspModel(props); 29 | dspView = new DspView(dspModel); 30 | adModel = new AdModel(props); 31 | } 32 | 33 | private void load(Properties p) { 34 | try { 35 | File file = new File("DspSimClient.properties"); 36 | InputStream is; 37 | if (file.exists()) { 38 | is = new FileInputStream(file); 39 | } else { 40 | is = getClass().getClassLoader().getSystemResourceAsStream("DspSimClient.properties"); 41 | } 42 | p.load(is); 43 | is.close(); 44 | } catch (IOException e) { 45 | log.warn("Could not load properties file.", e); 46 | } 47 | } 48 | 49 | public void start() { 50 | dspView.start(); 51 | dspModel.start(); 52 | } 53 | 54 | public static void main(String[] args) { 55 | try { 56 | DspSimClient sim = new DspSimClient(); 57 | sim.start(); 58 | } catch (ModelException e) { 59 | log.error(e.getMessage(), e); 60 | } 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/model/BaseModel.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model; 2 | 3 | import java.util.ArrayList; 4 | 5 | public abstract class BaseModel { 6 | private final ArrayList messageListeners = new ArrayList(); 7 | 8 | public void setMessage(String m) { 9 | notifyMessageListeners(MessageStatus.NOMINAL, m); 10 | } 11 | 12 | public void setMessageAsWarning(String m) { 13 | notifyMessageListeners(MessageStatus.WARNING, m); 14 | } 15 | 16 | public void setMessageAsFault(String m) { 17 | notifyMessageListeners(MessageStatus.FAULT, m); 18 | } 19 | 20 | private void notifyMessageListeners(MessageStatus s, String m) { 21 | for (MessageNotificationListener lis : messageListeners) { 22 | lis.sendMessage(s, m); 23 | } 24 | } 25 | 26 | public void addMessageNotificationListener(MessageNotificationListener lis) { 27 | messageListeners.add(lis); 28 | } 29 | 30 | public void removeMessageNotificationListener(MessageNotificationListener lis) { 31 | messageListeners.remove(lis); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/model/MessageNotificationListener.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model; 2 | 3 | public interface MessageNotificationListener { 4 | void sendMessage(MessageStatus s, String m); 5 | 6 | } 7 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/model/MessageStatus.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model; 2 | 3 | import java.awt.*; 4 | 5 | public enum MessageStatus { 6 | NOMINAL(Color.WHITE), FAULT(Color.RED), WARNING(Color.YELLOW); 7 | 8 | private final Color c; 9 | 10 | MessageStatus(Color c) { 11 | this.c = c; 12 | } 13 | 14 | public Color getColor() 15 | { 16 | return c; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/model/ModelException.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public class ModelException extends Exception { 7 | public ModelException(String msg) { 8 | super(msg); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/model/ad/AdModel.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.ad; 2 | 3 | import com.atg.openssp.dspSim.model.BaseModel; 4 | 5 | import java.util.Properties; /** 6 | * @author Brian Sorensen 7 | */ 8 | public class AdModel extends BaseModel { 9 | private final Properties props; 10 | 11 | public AdModel(Properties props) { 12 | this.props = props; 13 | } 14 | 15 | public String lookupProperty(String key) { 16 | return props.getProperty(key); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/model/client/ServerCommand.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.client; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public class ServerCommand { 7 | private ServerCommandType type; 8 | private String id; 9 | private float price; 10 | 11 | public void setType(ServerCommandType type) { 12 | this.type = type; 13 | } 14 | 15 | public ServerCommandType getType() { 16 | return type; 17 | } 18 | 19 | public void setId(String id) { 20 | this.id = id; 21 | } 22 | 23 | public String getId() { 24 | return id; 25 | } 26 | 27 | public void setPrice(float price) { 28 | this.price = price; 29 | } 30 | 31 | public float getPrice() { 32 | return price; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/model/client/ServerCommandType.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.client; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public enum ServerCommandType { 7 | LIST, UPDATE, REMOVE, ADD 8 | } 9 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/model/client/ServerResponse.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.client; 2 | 3 | import com.atg.openssp.dspSim.model.dsp.SimBidder; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Brian Sorensen 9 | */ 10 | public class ServerResponse { 11 | private ServerResponseStatus status; 12 | private String reason=""; 13 | private List bidders; 14 | 15 | public void setStatus(ServerResponseStatus status) { 16 | this.status = status; 17 | } 18 | 19 | public ServerResponseStatus getStatus() { 20 | return status; 21 | } 22 | 23 | public void setReason(String reason) { 24 | this.reason = reason; 25 | } 26 | 27 | public String getReason() { 28 | return reason; 29 | } 30 | 31 | public void setBidders(List bidders) { 32 | this.bidders = bidders; 33 | } 34 | 35 | public List getBidders() { 36 | return bidders; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/model/client/ServerResponseStatus.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.client; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public enum ServerResponseStatus { 7 | FAILURE, SUCCESS 8 | } 9 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/model/dsp/SimBidder.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.dsp; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public class SimBidder { 7 | private final String id; 8 | private float price; 9 | 10 | public SimBidder(String id) { 11 | this.id = id; 12 | } 13 | 14 | public String getId() { 15 | return id; 16 | } 17 | 18 | public void setPrice(float price) { 19 | this.price = price; 20 | } 21 | 22 | public float getPrice() { 23 | return price; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return id + " - ("+price+")"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /data-sim-client/src/main/java/com/atg/openssp/dspSim/view/dsp/DspView.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.view.dsp; 2 | 3 | import com.atg.openssp.dspSim.model.dsp.DspModel; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | 8 | /** 9 | * @author Brian Sorensen 10 | */ 11 | public class DspView { 12 | private final DspModel model; 13 | private final JFrame frame; 14 | 15 | public DspView(DspModel model) { 16 | this.model = model; 17 | frame = new JFrame("DSP Sim"); 18 | JTabbedPane tabs = new JTabbedPane(); 19 | tabs.addTab("Bidders", new SimBidderPanel(model)); 20 | frame.setContentPane(tabs); 21 | Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); 22 | frame.setSize(d.width, d.height-40); 23 | frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 24 | } 25 | 26 | public void start() { 27 | frame.setVisible(true); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /data-sim-client/src/main/resources/DspSimClient.properties: -------------------------------------------------------------------------------- 1 | 2 | server-host=localhost 3 | server-port=8082 4 | -------------------------------------------------------------------------------- /dsp-sim/run_sim.sh: -------------------------------------------------------------------------------- 1 | 2 | java -jar target/open-ssp-dsp-sim-0.1-SNAPSHOT.jar 3 | 4 | -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/AdServerHandler.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim; 2 | 3 | import com.atg.openssp.dspSim.model.ad.AdModel; 4 | import com.google.gson.Gson; 5 | import com.sun.net.httpserver.HttpExchange; 6 | import com.sun.net.httpserver.HttpHandler; 7 | import com.atg.openssp.dspSim.channel.adserving.AdservingCampaignProvider; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import java.io.*; 12 | 13 | /** 14 | * @author Brian Sorensen 15 | */ 16 | public class AdServerHandler implements HttpHandler { 17 | private static final Logger log = LoggerFactory.getLogger(AdServerHandler.class); 18 | private final AdModel model; 19 | 20 | public AdServerHandler(AdModel model) { 21 | this.model = model; 22 | } 23 | 24 | @Override 25 | public void handle(HttpExchange httpExchange) throws IOException { 26 | 27 | StringBuilder input = new StringBuilder(); 28 | try { 29 | BufferedReader is = new BufferedReader(new InputStreamReader(httpExchange.getRequestBody())); 30 | String line; 31 | while((line = is.readLine()) != null) { 32 | input.append(line+"\n"); 33 | } 34 | } catch (Exception ex) { 35 | log.error(ex.getMessage(), ex); 36 | } 37 | log.info("AD-->"+new Gson().toJson(input)); 38 | 39 | AdservingCampaignProvider p = new AdservingCampaignProvider(); 40 | p.setIsValid(true); 41 | p.setPrice(40f); 42 | p.setPriceEur(30f); 43 | 44 | String result = new Gson().toJson(p); 45 | log.info("<--"+result); 46 | httpExchange.sendResponseHeaders(200, result.length()); 47 | OutputStream os = httpExchange.getResponseBody(); 48 | os.write(result.getBytes()); 49 | os.close(); 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/DspSim.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim; 2 | 3 | import com.atg.openssp.dspSim.model.ModelException; 4 | import com.atg.openssp.dspSim.model.ad.AdModel; 5 | import com.atg.openssp.dspSim.model.dsp.DspModel; 6 | import com.sun.net.httpserver.HttpServer; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import java.io.IOException; 11 | import java.net.InetSocketAddress; 12 | 13 | /** 14 | * @author Brian Sorensen 15 | */ 16 | public class DspSim { 17 | private static final Logger log = LoggerFactory.getLogger(DspSim.class); 18 | private DspModel dspModel; 19 | private AdModel adModel; 20 | 21 | public DspSim() throws ModelException { 22 | dspModel = new DspModel(); 23 | adModel = new AdModel(); 24 | } 25 | 26 | public void start() { 27 | try { 28 | HttpServer server = HttpServer.create(new InetSocketAddress(8082), 0); 29 | server.createContext("/dsp-sim/admin", new ClientHandler(dspModel)); 30 | server.createContext("/dsp-sim/DemandService", new DspHandler(dspModel)); 31 | server.createContext("/dsp-sim/myAds", new AdServerHandler(adModel)); 32 | server.setExecutor(null); // creates a default executor 33 | server.start(); 34 | } catch (IOException e) { 35 | log.error(e.getMessage(), e); 36 | } 37 | 38 | } 39 | 40 | public static void main(String[] args) { 41 | try { 42 | DspSim sim = new DspSim(); 43 | sim.start(); 44 | while(true) { 45 | try { 46 | Thread.sleep(100000); 47 | } catch (InterruptedException e) { 48 | } 49 | } 50 | } catch (ModelException e) { 51 | log.error(e.getMessage(), e); 52 | } 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/channel/adserving/AdservingCampaignProvider.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.channel.adserving; 2 | 3 | import com.atg.openssp.common.core.entry.SessionAgent; 4 | import com.atg.openssp.common.provider.AdProviderReader; 5 | import com.atg.openssp.common.provider.AdProviderWriter; 6 | 7 | /** 8 | * 9 | * @author André Schmer 10 | * 11 | */ 12 | public class AdservingCampaignProvider implements AdProviderReader, AdProviderWriter { 13 | 14 | private boolean isValid = Boolean.TRUE; 15 | 16 | private static final String currency = "EUR"; 17 | 18 | private float cpm; 19 | 20 | private int adid;// sent by adserver 21 | 22 | private String vasturl; 23 | 24 | @Override 25 | public float getPrice() { 26 | return cpm; 27 | } 28 | 29 | @Override 30 | public void setPrice(final float bidPrice) { 31 | cpm = bidPrice; 32 | } 33 | 34 | @Override 35 | public void setIsValid(final boolean valid) { 36 | isValid = valid; 37 | } 38 | 39 | @Override 40 | public boolean isValid() { 41 | return isValid; 42 | } 43 | 44 | @Override 45 | public float getPriceEur() { 46 | return cpm * 1; 47 | } 48 | 49 | @Override 50 | public String getCurrrency() { 51 | return currency; 52 | } 53 | 54 | @Override 55 | public void perform(final SessionAgent agent) { 56 | // nothing to implement yet 57 | } 58 | 59 | @Override 60 | public String buildResponse() { 61 | return vasturl; 62 | } 63 | 64 | @Override 65 | public String getVendorId() { 66 | if (adid > 0) { 67 | return "Adserving_" + adid; 68 | } 69 | return null; 70 | } 71 | 72 | @Override 73 | public void setPriceEur(final float priceEur) { 74 | cpm = priceEur; 75 | } 76 | 77 | @Override 78 | public String getAdid() { 79 | return String.valueOf(adid); 80 | } 81 | 82 | @Override 83 | public String toString() { 84 | return "AdservingCampaignProvider [isValid=" + isValid + ", currency=" + currency + ", cpm=" + cpm + ", adid=" + adid + ", vasturl=" + vasturl + "]"; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/model/ModelException.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public class ModelException extends Exception { 7 | public ModelException(String msg) { 8 | super(msg); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/model/ad/AdModel.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.ad; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public class AdModel { 7 | } 8 | -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/model/client/ClientCommand.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.client; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public class ClientCommand { 7 | private ClientCommandType type; 8 | private String id; 9 | private float price; 10 | 11 | public void setType(ClientCommandType type) { 12 | this.type = type; 13 | } 14 | 15 | public ClientCommandType getType() { 16 | return type; 17 | } 18 | 19 | public void setId(String id) { 20 | this.id = id; 21 | } 22 | 23 | public String getId() { 24 | return id; 25 | } 26 | 27 | public void setPrice(float price) { 28 | this.price = price; 29 | } 30 | 31 | public float getPrice() { 32 | return price; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/model/client/ClientCommandType.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.client; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public enum ClientCommandType { 7 | LIST, UPDATE, REMOVE, ADD 8 | } 9 | -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/model/client/ClientResponse.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.client; 2 | 3 | import com.atg.openssp.dspSim.model.dsp.SimBidder; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Brian Sorensen 9 | */ 10 | public class ClientResponse { 11 | private ClientResponseStatus status; 12 | private String reason=""; 13 | private List bidders; 14 | 15 | public void setStatus(ClientResponseStatus status) { 16 | this.status = status; 17 | } 18 | 19 | public ClientResponseStatus getStatus() { 20 | return status; 21 | } 22 | 23 | public void setReason(String reason) { 24 | this.reason = reason; 25 | } 26 | 27 | public String getReason() { 28 | return reason; 29 | } 30 | 31 | public void setBidders(List bidders) { 32 | this.bidders = bidders; 33 | } 34 | 35 | public List getBidders() { 36 | return bidders; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/model/client/ClientResponseStatus.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.client; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public enum ClientResponseStatus { 7 | FAILURE, SUCCESS 8 | } 9 | -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/model/dsp/SimBidder.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.dsp; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public class SimBidder { 7 | private final String id; 8 | private float price; 9 | 10 | public SimBidder(String id) { 11 | this.id = id; 12 | } 13 | 14 | public String getId() { 15 | return id; 16 | } 17 | 18 | public void setPrice(float price) { 19 | this.price = price; 20 | } 21 | 22 | public float getPrice() { 23 | return price; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return id + " - ("+price+")"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /dsp-sim/src/main/java/com/atg/openssp/dspSim/model/dsp/SimBidderListener.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.dspSim.model.dsp; 2 | 3 | /** 4 | * @author Brian Sorensen 5 | */ 6 | public interface SimBidderListener { 7 | void added(SimBidder sb); 8 | 9 | void removed(SimBidder sb); 10 | } 11 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 ad-tech-group 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /open-ssp-parent/.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings/ 3 | -------------------------------------------------------------------------------- /open-ssp-parent/TODO: -------------------------------------------------------------------------------- 1 | TODO List 2 | 3 | - Change to a more elegant and common used generic caching system. 4 | - Moving stopwatch with a more general context beahviour like MetricRegistry -------------------------------------------------------------------------------- /open-ssp-parent/channel-adserver/.gitignore: -------------------------------------------------------------------------------- 1 | /.classpath 2 | /.project 3 | /.settings/ 4 | /target/ 5 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-adserver/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.atg.openssp 6 | open-ssp-parent 7 | 0.3 8 | 9 | channel-adserver 10 | 11 | 12 | 13 | com.atg.openssp 14 | open-ssp-common 15 | ${project.version} 16 | 17 | 18 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-adserver/src/main/java/channel/adserving/AdserverBroker.java: -------------------------------------------------------------------------------- 1 | package channel.adserving; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | import java.util.Optional; 5 | 6 | import org.apache.http.client.utils.URIBuilder; 7 | 8 | import com.atg.openssp.common.core.broker.AbstractBroker; 9 | import com.atg.openssp.common.core.connector.JsonGetConnector; 10 | import com.atg.openssp.common.exception.BidProcessingException; 11 | import com.atg.openssp.common.provider.AdProviderReader; 12 | import com.google.common.base.Stopwatch; 13 | import com.google.gson.Gson; 14 | 15 | /** 16 | * This class acts as Broker to the adserver connector. It uses a get-connector to connect direct to the adserver and retrieves the result from it. 17 | * 18 | * @author André Schmer 19 | * 20 | */ 21 | public class AdserverBroker extends AbstractBroker { 22 | 23 | private final Gson gson; 24 | 25 | private final JsonGetConnector jsonGetConnector; 26 | 27 | // define endpoint 28 | private static final String scheme = "http"; 29 | private static final String host = "doamin.com"; 30 | private static final String path = "/path/to/target"; 31 | 32 | final URIBuilder uriBuilder; 33 | 34 | public AdserverBroker() { 35 | uriBuilder = new URIBuilder().setCharset(StandardCharsets.UTF_8).setScheme(scheme).setHost(host).setPath(path); 36 | 37 | jsonGetConnector = new JsonGetConnector(); 38 | gson = new Gson(); 39 | } 40 | 41 | /** 42 | * Connects to the Adserver. 43 | * 44 | * @return Optional of {@link AdProviderReader} 45 | * @throws BidProcessingException 46 | */ 47 | public Optional call() throws BidProcessingException { 48 | final Stopwatch stopwatch = Stopwatch.createStarted(); 49 | try { 50 | 51 | final String result = jsonGetConnector.connect(uriBuilder); 52 | final AdProviderReader adProvider = gson.fromJson(result, AdservingCampaignProvider.class); 53 | stopwatch.stop(); 54 | return Optional.ofNullable(adProvider); 55 | } finally { 56 | if (stopwatch.isRunning()) { 57 | stopwatch.stop(); 58 | } 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-adserver/src/main/java/channel/adserving/AdservingCampaignProvider.java: -------------------------------------------------------------------------------- 1 | package channel.adserving; 2 | 3 | import com.atg.openssp.common.core.entry.SessionAgent; 4 | import com.atg.openssp.common.provider.AdProviderReader; 5 | import com.atg.openssp.common.provider.AdProviderWriter; 6 | 7 | /** 8 | * 9 | * @author André Schmer 10 | * 11 | */ 12 | public class AdservingCampaignProvider implements AdProviderReader, AdProviderWriter { 13 | 14 | private boolean isValid = Boolean.TRUE; 15 | 16 | private static final String currency = "EUR"; 17 | 18 | private float cpm; 19 | 20 | private int adid;// sent by adserver 21 | 22 | private String vasturl; 23 | 24 | @Override 25 | public float getPrice() { 26 | return cpm; 27 | } 28 | 29 | @Override 30 | public void setPrice(final float bidPrice) { 31 | cpm = bidPrice; 32 | } 33 | 34 | @Override 35 | public void setIsValid(final boolean valid) { 36 | isValid = valid; 37 | } 38 | 39 | @Override 40 | public boolean isValid() { 41 | return isValid; 42 | } 43 | 44 | @Override 45 | public float getPriceEur() { 46 | return cpm * 1; 47 | } 48 | 49 | @Override 50 | public String getCurrrency() { 51 | return currency; 52 | } 53 | 54 | @Override 55 | public void perform(final SessionAgent agent) { 56 | // nothing to implement yet 57 | } 58 | 59 | @Override 60 | public String buildResponse() { 61 | return vasturl; 62 | } 63 | 64 | @Override 65 | public String getVendorId() { 66 | if (adid > 0) { 67 | return "Adserving_" + adid; 68 | } 69 | return null; 70 | } 71 | 72 | @Override 73 | public void setPriceEur(final float priceEur) { 74 | cpm = priceEur; 75 | } 76 | 77 | @Override 78 | public String getAdid() { 79 | return String.valueOf(adid); 80 | } 81 | 82 | @Override 83 | public String toString() { 84 | return "AdservingCampaignProvider [isValid=" + isValid + ", currency=" + currency + ", cpm=" + cpm + ", adid=" + adid + ", vasturl=" + vasturl + "]"; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-adserver/src/main/java/channel/adserving/AdservingService.java: -------------------------------------------------------------------------------- 1 | package channel.adserving; 2 | 3 | import java.util.Optional; 4 | import java.util.concurrent.Callable; 5 | 6 | import com.atg.openssp.common.core.entry.SessionAgent; 7 | import com.atg.openssp.common.provider.AdProviderReader; 8 | 9 | /** 10 | * @author André Schmer 11 | * 12 | */ 13 | public class AdservingService implements Callable { 14 | 15 | private final AdserverBroker broker; 16 | 17 | private final SessionAgent agent; 18 | 19 | /** 20 | * 21 | * @param agent 22 | * {@link SessionAgent} 23 | */ 24 | public AdservingService(final SessionAgent agent) { 25 | this.agent = agent; 26 | broker = new AdserverBroker(); 27 | broker.setSessionAgent(agent); 28 | } 29 | 30 | /** 31 | * Calls the Broker for Adserver. 32 | * 33 | * @return {@link AdProviderReader} 34 | */ 35 | @Override 36 | public AdProviderReader call() throws Exception { 37 | final Optional adProvider = broker.call(); 38 | 39 | if (adProvider.isPresent()) { 40 | final AdProviderReader provider = adProvider.get(); 41 | 42 | // check if the ad response price is greator or equal the floorprice 43 | // if (FloatComparator.greaterOrEqual(provider.getPriceEur(), agent.getParamValues().getVideoad().getBidfloorPrice())) { 44 | // return provider; 45 | // } 46 | } 47 | 48 | return null; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/.gitignore: -------------------------------------------------------------------------------- 1 | /.classpath 2 | /.project 3 | /.settings/ 4 | /target/ 5 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.atg.openssp 6 | open-ssp-parent 7 | 0.3 8 | 9 | channel-ssp 10 | 11 | 12 | 13 | com.atg.openssp 14 | open-ssp-common 15 | ${project.version} 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/src/main/java/channel/adapter/AdapterBuilder.java: -------------------------------------------------------------------------------- 1 | package channel.adapter; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public interface AdapterBuilder { 8 | 9 | String build(); 10 | } 11 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/src/main/java/channel/adapter/AdapterConnector.java: -------------------------------------------------------------------------------- 1 | package channel.adapter; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.atg.openssp.common.core.entry.SessionAgent; 6 | import com.atg.openssp.common.exception.BidProcessingException; 7 | 8 | /** 9 | * @author André Schmer 10 | * 11 | */ 12 | public interface AdapterConnector extends Serializable { 13 | 14 | String connect(SessionAgent sessionAgent) throws BidProcessingException; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/src/main/java/channel/adapter/SSPAdapter.java: -------------------------------------------------------------------------------- 1 | package channel.adapter; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public interface SSPAdapter { 8 | 9 | String getCurrency(); 10 | 11 | String getEndpoint(); 12 | 13 | String getName(); 14 | 15 | AdapterConnector getConnector(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/src/main/java/channel/adapter/TrialAdapterBuilder.java: -------------------------------------------------------------------------------- 1 | package channel.adapter; 2 | 3 | import com.atg.openssp.common.core.entry.SessionAgent; 4 | 5 | /** 6 | * @author André Schmer 7 | * 8 | */ 9 | public class TrialAdapterBuilder implements AdapterBuilder { 10 | 11 | private final SessionAgent sessionAgent; 12 | 13 | public TrialAdapterBuilder(final SessionAgent sessionAgent) { 14 | this.sessionAgent = sessionAgent; 15 | } 16 | 17 | @Override 18 | public String build() { 19 | sessionAgent.getRequestid(); 20 | return null; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/src/main/java/channel/adapter/TrialAdapterConnector.java: -------------------------------------------------------------------------------- 1 | package channel.adapter; 2 | 3 | import org.apache.http.client.methods.HttpPost; 4 | import org.apache.http.entity.ContentType; 5 | import org.apache.http.entity.StringEntity; 6 | 7 | import com.atg.openssp.common.core.connector.JsonPostConnector; 8 | import com.atg.openssp.common.core.entry.SessionAgent; 9 | import com.atg.openssp.common.exception.BidProcessingException; 10 | 11 | /** 12 | * @author André Schmer 13 | * 14 | */ 15 | public class TrialAdapterConnector implements AdapterConnector { 16 | 17 | private static final long serialVersionUID = -6978598309872993590L; 18 | 19 | private final JsonPostConnector jsonPostConnector; 20 | 21 | private final SSPAdapter sspAdapter; 22 | 23 | public TrialAdapterConnector(final SSPAdapter sspAdapter) { 24 | this.sspAdapter = sspAdapter; 25 | jsonPostConnector = new JsonPostConnector(); 26 | } 27 | 28 | @Override 29 | public String connect(final SessionAgent sessionAgent) throws BidProcessingException { 30 | final String jsonRequest = new TrialAdapterBuilder(sessionAgent).build(); 31 | 32 | final HttpPost httpPost = new HttpPost(sspAdapter.getEndpoint()); 33 | return jsonPostConnector.connect(new StringEntity(jsonRequest, ContentType.APPLICATION_JSON), httpPost); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/src/main/java/channel/cache/BasicAdapter.java: -------------------------------------------------------------------------------- 1 | package channel.cache; 2 | 3 | import java.io.Serializable; 4 | 5 | import channel.adapter.AdapterConnector; 6 | import channel.adapter.SSPAdapter; 7 | 8 | /** 9 | * @author André Schmer 10 | * 11 | */ 12 | public class BasicAdapter implements Serializable, SSPAdapter { 13 | 14 | private static final long serialVersionUID = -5648775770118011066L; 15 | 16 | private String name; 17 | 18 | private String currency; 19 | 20 | private String endpoint; 21 | 22 | private static final boolean connectionkeepAlive = true; 23 | 24 | private String contentType; 25 | 26 | private String connectorClass; 27 | 28 | private AdapterConnector connector; 29 | 30 | public BasicAdapter() {} 31 | 32 | @Override 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(final String name) { 38 | this.name = name; 39 | } 40 | 41 | @Override 42 | public String getCurrency() { 43 | return currency; 44 | } 45 | 46 | public void setCurrency(final String currency) { 47 | this.currency = currency; 48 | } 49 | 50 | @Override 51 | public String getEndpoint() { 52 | return endpoint; 53 | } 54 | 55 | public void setEndpoint(final String endpoint) { 56 | this.endpoint = endpoint; 57 | } 58 | 59 | public String getContentType() { 60 | return contentType; 61 | } 62 | 63 | public void setContentType(final String contentType) { 64 | this.contentType = contentType; 65 | } 66 | 67 | public boolean isConnectionkeepAlive() { 68 | return connectionkeepAlive; 69 | } 70 | 71 | @Override 72 | public AdapterConnector getConnector() { 73 | return connector; 74 | } 75 | 76 | public void setConnector(final AdapterConnector connector) { 77 | this.connector = connector; 78 | } 79 | 80 | public String getConnectorClass() { 81 | return connectorClass; 82 | } 83 | 84 | public void setConnectorClass(final String connectorClass) { 85 | this.connectorClass = connectorClass; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/src/main/java/channel/cache/SSPAdapterDataBroker.java: -------------------------------------------------------------------------------- 1 | package channel.cache; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import com.atg.openssp.common.cache.broker.AbstractDataBroker; 7 | import com.atg.openssp.common.exception.EmptyHostException; 8 | 9 | import channel.ssp.SSPAdapterCache; 10 | import channel.ssp.SSPBroker; 11 | import restful.context.Path; 12 | import restful.context.PathBuilder; 13 | import restful.exception.RestException; 14 | 15 | /** 16 | * Act as broker between connector which loads the data from the webservice into a data transfer object and the cache. 17 | * 18 | * @author André Schmer 19 | * 20 | */ 21 | public final class SSPAdapterDataBroker extends AbstractDataBroker { 22 | 23 | private static final Logger log = LoggerFactory.getLogger(SSPAdapterDataBroker.class); 24 | 25 | public SSPAdapterDataBroker() {} 26 | 27 | @Override 28 | public boolean doCaching() { 29 | try { 30 | final SSPAdapterDto dto = super.connect(SSPAdapterDto.class); 31 | if (dto != null) { 32 | log.debug("sizeof sspadapter data= {}", dto.getData().size()); 33 | dto.getData().forEach(adapter -> { 34 | final SSPBroker broker = new SSPBroker(adapter); 35 | SSPAdapterCache.INSTANCE.add(broker); 36 | }); 37 | 38 | return true; 39 | } 40 | log.error("dto is null"); 41 | } catch (final RestException | EmptyHostException e) { 42 | log.error(e.getMessage()); 43 | } 44 | return false; 45 | } 46 | 47 | @Override 48 | public PathBuilder getRestfulContext() { 49 | return getDefaulPathBuilder().addPath(Path.CORE).addPath(Path.SSP_ADAPTER); 50 | } 51 | 52 | @Override 53 | protected void finalWork() { 54 | SSPAdapterCache.INSTANCE.switchCache(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/src/main/java/channel/cache/SSPAdapterDto.java: -------------------------------------------------------------------------------- 1 | package channel.cache; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * @author André Schmer 8 | * 9 | */ 10 | public class SSPAdapterDto implements Serializable { 11 | 12 | private static final long serialVersionUID = -8474260463798948583L; 13 | 14 | private List data; 15 | 16 | public SSPAdapterDto() {} 17 | 18 | public List getData() { 19 | return data; 20 | } 21 | 22 | public void setData(final List data) { 23 | this.data = data; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return String.format("SSPAdapterDto [data=%s]", data); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /open-ssp-parent/channel-ssp/src/main/java/channel/ssp/SSPAdapterCache.java: -------------------------------------------------------------------------------- 1 | package channel.ssp; 2 | 3 | import com.atg.openssp.common.cache.ListCache; 4 | 5 | /** 6 | * @author André Schmer 7 | * 8 | */ 9 | public final class SSPAdapterCache extends ListCache { 10 | 11 | public static final SSPAdapterCache INSTANCE = new SSPAdapterCache(); 12 | 13 | private SSPAdapterCache() { 14 | super(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /open-ssp-parent/core/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.classpath 3 | /.project 4 | /.settings/ 5 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/broker/CacheController.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.broker; 2 | 3 | import java.util.Observable; 4 | 5 | import com.atg.openssp.core.cache.broker.json.PricelayerBrokerJson; 6 | import com.atg.openssp.core.cache.broker.json.SiteDataBrokerJson; 7 | import com.atg.openssp.core.cache.broker.json.SupplierDataBrokerJson; 8 | 9 | /** 10 | * 11 | * CacheController manages the list of available observers to cache broker. 12 | * 13 | * @author André Schmer 14 | */ 15 | public class CacheController extends Observable { 16 | 17 | public static final CacheController instance = new CacheController(); 18 | 19 | public CacheController() { 20 | initingCacheList(); 21 | } 22 | 23 | private void initingCacheList() { 24 | deleteObservers(); 25 | 26 | /** 27 | * Use the following types of brokers to load JSON based configured data into cache. 28 | */ 29 | // loads supplier data from supplier_db.json into the cache 30 | addObserver(new SupplierDataBrokerJson()); 31 | 32 | // loads site data from site_db.json into the cache 33 | addObserver(new SiteDataBrokerJson()); 34 | 35 | // loads priceinformation from price_layer.json into the cache 36 | addObserver(new PricelayerBrokerJson()); 37 | 38 | /** 39 | * Use the following types of brokers to load remote e.g. RESTful webservice based configured data into cache. 40 | */ 41 | // loads currency data from webservice into the cache 42 | // addObserver(new RemoteCurrencyDataBroker()); 43 | 44 | // loads website data from webservice into the cache 45 | // addObserver(new RemoteWebsiteDataBroker()); 46 | 47 | // loads videoad data from webservice into the cache 48 | // addObserver(new RemoteVideoadDataBroker()); 49 | 50 | // loads supplier data from webservice into the cache 51 | // addObserver(new RemoteSupplierDataBroker()); 52 | } 53 | 54 | /** 55 | * Updates the registered caches. 56 | */ 57 | public void update() { 58 | setChanged(); 59 | this.notifyObservers(); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/broker/dto/AppDto.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.broker.dto; 2 | 3 | import openrtb.bidrequest.model.App; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * 10 | * @author André Schmer 11 | * 12 | */ 13 | public class AppDto implements Serializable { 14 | 15 | private static final long serialVersionUID = 6743606462533687452L; 16 | 17 | private List apps; 18 | 19 | public AppDto() {} 20 | 21 | public List getApps() { 22 | return apps; 23 | } 24 | 25 | public void setSupplier(final List apps) { 26 | this.apps = apps; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return String.format("AppDto [apps=%s]", apps); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/broker/dto/CurrencyDto.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.broker.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import com.atg.openssp.common.model.EurRef; 7 | 8 | /** 9 | * 10 | * @author André Schmer 11 | * 12 | */ 13 | public class CurrencyDto implements Serializable { 14 | 15 | private static final long serialVersionUID = 3455274178456736049L; 16 | 17 | private List data; 18 | 19 | public CurrencyDto() {} 20 | 21 | public List getData() { 22 | return data; 23 | } 24 | 25 | public void setData(final List data) { 26 | this.data = data; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return String.format("CurrencyDto [data=%s]", data); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/broker/dto/PricelayerDto.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.broker.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import openrtb.bidrequest.model.Pricelayer; 7 | 8 | /** 9 | * 10 | * @author André Schmer 11 | * 12 | */ 13 | public class PricelayerDto implements Serializable { 14 | 15 | private static final long serialVersionUID = -7348030785810292621L; 16 | 17 | private List pricelayer; 18 | 19 | public PricelayerDto() {} 20 | 21 | public List getPricelayer() { 22 | return pricelayer; 23 | } 24 | 25 | public void setPricelayer(final List pricelayer) { 26 | this.pricelayer = pricelayer; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return String.format("PricelayerDto [pricelayer=%s]", pricelayer); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/broker/dto/SiteDto.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.broker.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import openrtb.bidrequest.model.Site; 7 | 8 | /** 9 | * 10 | * @author André Schmer 11 | * 12 | */ 13 | public class SiteDto implements Serializable { 14 | 15 | private static final long serialVersionUID = 6743606462533687452L; 16 | 17 | private List sites; 18 | 19 | public SiteDto() {} 20 | 21 | public List getSites() { 22 | return sites; 23 | } 24 | 25 | public void setSupplier(final List sites) { 26 | this.sites = sites; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return String.format("SiteDto [sites=%s]", sites); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/broker/dto/SupplierDto.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.broker.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import com.atg.openssp.common.demand.Supplier; 7 | 8 | /** 9 | * 10 | * @author André Schmer 11 | * 12 | */ 13 | public class SupplierDto implements Serializable { 14 | 15 | private static final long serialVersionUID = 2494786819460515865L; 16 | 17 | private List supplier; 18 | 19 | public SupplierDto() {} 20 | 21 | public List getSupplier() { 22 | return supplier; 23 | } 24 | 25 | public void setSupplier(final List supplier) { 26 | this.supplier = supplier; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return String.format("SupplierDto [supplier=%s]", supplier); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/broker/json/PricelayerBrokerJson.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.broker.json; 2 | 3 | import java.io.IOException; 4 | import java.nio.charset.StandardCharsets; 5 | import java.nio.file.Files; 6 | import java.nio.file.Paths; 7 | 8 | import javax.xml.bind.PropertyException; 9 | 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import com.atg.openssp.common.cache.broker.DataBrokerObserver; 14 | import com.atg.openssp.core.cache.broker.dto.PricelayerDto; 15 | import com.atg.openssp.core.cache.type.PricelayerCache; 16 | import com.google.gson.Gson; 17 | 18 | import util.properties.ProjectProperty; 19 | 20 | /** 21 | * @author André Schmer 22 | * 23 | */ 24 | public class PricelayerBrokerJson extends DataBrokerObserver { 25 | 26 | private static final Logger log = LoggerFactory.getLogger(PricelayerBrokerJson.class); 27 | 28 | public PricelayerBrokerJson() {} 29 | 30 | @Override 31 | protected boolean doCaching() { 32 | final Gson gson = new Gson(); 33 | try { 34 | final String path = ProjectProperty.readFile("price_layer.json").getAbsolutePath(); 35 | final String content = new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8); 36 | final PricelayerDto dto = gson.fromJson(content, PricelayerDto.class); 37 | if (dto != null) { 38 | log.info("sizeof pricelayer data=" + dto.getPricelayer().size()); 39 | dto.getPricelayer().forEach(pricelayer -> { 40 | PricelayerCache.instance.put(pricelayer.getSiteid(), pricelayer); 41 | }); 42 | return true; 43 | } 44 | 45 | log.error("no price data"); 46 | return false; 47 | } catch (final IOException | PropertyException e) { 48 | log.error(getClass() + ", " + e.getMessage()); 49 | } 50 | 51 | return true; 52 | } 53 | 54 | @Override 55 | protected void finalWork() { 56 | PricelayerCache.instance.switchCache(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/broker/json/SiteDataBrokerJson.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.broker.json; 2 | 3 | import java.io.IOException; 4 | import java.nio.charset.StandardCharsets; 5 | import java.nio.file.Files; 6 | import java.nio.file.Paths; 7 | 8 | import javax.xml.bind.PropertyException; 9 | 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | import com.atg.openssp.common.cache.broker.DataBrokerObserver; 14 | import com.atg.openssp.core.cache.broker.dto.SiteDto; 15 | import com.atg.openssp.core.cache.type.SiteDataCache; 16 | import com.google.gson.Gson; 17 | 18 | import util.properties.ProjectProperty; 19 | 20 | /** 21 | * @author André Schmer 22 | * 23 | */ 24 | public class SiteDataBrokerJson extends DataBrokerObserver { 25 | 26 | private static final Logger log = LoggerFactory.getLogger(SiteDataBrokerJson.class); 27 | 28 | public SiteDataBrokerJson() {} 29 | 30 | @Override 31 | protected boolean doCaching() { 32 | final Gson gson = new Gson(); 33 | try { 34 | final String path = ProjectProperty.readFile("site_db.json").getAbsolutePath(); 35 | final String content = new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8); 36 | final SiteDto dto = gson.fromJson(content, SiteDto.class); 37 | if (dto != null) { 38 | log.info("sizeof site data=" + dto.getSites().size()); 39 | dto.getSites().forEach(site -> { 40 | SiteDataCache.instance.put(site.getId(), site); 41 | }); 42 | return true; 43 | } 44 | log.error("no Site data"); 45 | return false; 46 | } catch (final PropertyException | IOException e) { 47 | log.error(getClass() + ", " + e.getMessage()); 48 | } 49 | 50 | return true; 51 | } 52 | 53 | @Override 54 | protected void finalWork() { 55 | SiteDataCache.instance.switchCache(); 56 | 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/type/ConnectorCache.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.type; 2 | 3 | import com.atg.openssp.common.cache.ListCache; 4 | import com.atg.openssp.core.exchange.channel.rtb.OpenRtbConnector; 5 | 6 | /** 7 | * @author André Schmer 8 | * 9 | */ 10 | public final class ConnectorCache extends ListCache { 11 | 12 | public static final ConnectorCache instance = new ConnectorCache(); 13 | 14 | private ConnectorCache() { 15 | super(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/type/PricelayerCache.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.type; 2 | 3 | import com.atg.openssp.common.cache.MapCache; 4 | 5 | import openrtb.bidrequest.model.Pricelayer; 6 | 7 | /** 8 | * @author André Schmer 9 | * 10 | */ 11 | public final class PricelayerCache extends MapCache { 12 | 13 | public static final PricelayerCache instance = new PricelayerCache(); 14 | 15 | private PricelayerCache() { 16 | super(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/type/SiteDataCache.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.type; 2 | 3 | import com.atg.openssp.common.cache.MapCache; 4 | 5 | import openrtb.bidrequest.model.Site; 6 | 7 | /** 8 | * @author André Schmer 9 | * 10 | */ 11 | public final class SiteDataCache extends MapCache { 12 | 13 | public static final SiteDataCache instance = new SiteDataCache(); 14 | 15 | private SiteDataCache() { 16 | super(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/type/VideoAdDataCache.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.type; 2 | 3 | import com.atg.openssp.common.cache.MapCache; 4 | import com.atg.openssp.common.cache.dto.VideoAd; 5 | 6 | /** 7 | * @author André Schmer 8 | * 9 | */ 10 | public final class VideoAdDataCache extends MapCache { 11 | 12 | public static final VideoAdDataCache instance = new VideoAdDataCache(); 13 | 14 | private VideoAdDataCache() { 15 | super(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/type/WebsiteDataCache.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.type; 2 | 3 | import com.atg.openssp.common.cache.MapCache; 4 | import com.atg.openssp.common.cache.dto.Website; 5 | 6 | /** 7 | * @author André Schmer 8 | * 9 | */ 10 | public final class WebsiteDataCache extends MapCache { 11 | 12 | public static final WebsiteDataCache instance = new WebsiteDataCache(); 13 | 14 | private WebsiteDataCache() { 15 | super(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/cache/type/ZoneDataCache.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.cache.type; 2 | 3 | import com.atg.openssp.common.cache.MapCache; 4 | import com.atg.openssp.common.cache.dto.Zone; 5 | 6 | /** 7 | * @author André Schmer 8 | * 9 | */ 10 | public final class ZoneDataCache extends MapCache { 11 | 12 | public static final ZoneDataCache instance = new ZoneDataCache(); 13 | 14 | private ZoneDataCache() { 15 | super(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/entry/SupplyVideoService.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.entry; 2 | 3 | import javax.servlet.annotation.WebServlet; 4 | import javax.servlet.http.HttpServletRequest; 5 | import javax.servlet.http.HttpServletResponse; 6 | 7 | import com.atg.openssp.common.core.entry.CoreSupplyServlet; 8 | import com.atg.openssp.common.core.exchange.Exchange; 9 | import com.atg.openssp.common.exception.RequestException; 10 | import com.atg.openssp.core.exchange.ExchangeServer; 11 | import com.atg.openssp.core.exchange.RequestSessionAgent; 12 | 13 | /** 14 | * Servlet implementation class SupplyVideoService 15 | * 16 | * @author André Schmer 17 | */ 18 | @WebServlet(value = "/SupplyVideoService", asyncSupported = false, name = "SupplyVideo-Service") 19 | public class SupplyVideoService extends CoreSupplyServlet { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | @Override 24 | protected RequestSessionAgent getAgent(final HttpServletRequest request, final HttpServletResponse response) throws RequestException { 25 | return new RequestSessionAgent(request, response); 26 | } 27 | 28 | @Override 29 | protected Exchange getServer() { 30 | return new ExchangeServer(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/exchange/BidRequestBuilder.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.exchange; 2 | 3 | import com.atg.openssp.common.core.entry.SessionAgent; 4 | 5 | import openrtb.bidrequest.model.BidRequest; 6 | import openrtb.bidrequest.model.Device; 7 | import openrtb.bidrequest.model.Gender; 8 | import openrtb.bidrequest.model.Geo; 9 | import openrtb.bidrequest.model.Impression; 10 | import openrtb.bidrequest.model.User; 11 | import openrtb.bidrequest.model.Video; 12 | import openrtb.tables.VideoBidResponseProtocol; 13 | 14 | /** 15 | * RequestBuilder builds the BidRequest Object for RTB Exchange. 16 | * 17 | * @author André Schmer 18 | * 19 | */ 20 | public class BidRequestBuilder { 21 | 22 | /** 23 | * Build a request object regarding to the OpenRTB Specification. 24 | * 25 | * @return {@see BidRequest} 26 | */ 27 | public static BidRequest build(final SessionAgent agent) { 28 | 29 | final BidRequest bidRequest = new BidRequest.Builder().setId(agent.getRequestid()).setSite(agent.getParamValues().getSite()).setDevice(new Device.Builder().setGeo( 30 | new Geo.Builder().setCity("Hamburg").setCountry("DEU").setLat(53.563452f).setLon(9.925742f).setZip("22761").build()).build()).addImp(new Impression.Builder().setId( 31 | "1").setVideo(new Video.Builder().addMime("application/x-shockwave-flash").setH(400).setW(600).setMaxduration(100).setMinduration(30).addProtocol( 32 | VideoBidResponseProtocol.VAST_2_0.getValue()).setStartdelay(1).build()).build()).setUser(new User.Builder().setBuyeruid("HHcFrt-76Gh4aPl") 33 | .setGender(Gender.MALE).setId("99").setYob(1981).build()).build(); 34 | 35 | return bidRequest; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/exchange/RequestSessionAgent.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.exchange; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import com.atg.openssp.common.core.entry.RequestMonitor; 10 | import com.atg.openssp.common.core.entry.SessionAgent; 11 | import com.atg.openssp.common.demand.BidExchange; 12 | import com.atg.openssp.common.exception.RequestException; 13 | import com.atg.openssp.common.logadapter.RequestLogProcessor; 14 | import com.atg.openssp.core.entry.EntryValidator; 15 | 16 | /** 17 | * Handling class for single request handling. Holding all those data which are relevant to a video request and performing demand requests. 18 | * 19 | * Responsible for extracting and evaluating request parameter. Creates a requestid as request identifier, useful in logging. 20 | * 21 | * 22 | * @author André Schmer 23 | * 24 | */ 25 | public class RequestSessionAgent extends SessionAgent { 26 | 27 | private static final Logger log = LoggerFactory.getLogger(RequestSessionAgent.class); 28 | 29 | /** 30 | * 31 | * @param request 32 | * @param response 33 | * @throws RequestException 34 | */ 35 | public RequestSessionAgent(final HttpServletRequest request, final HttpServletResponse response) throws RequestException { 36 | super(request, response); 37 | paramValue = new EntryValidator().validateEntryParams(request); 38 | 39 | log.debug(paramValue.toString()); 40 | 41 | bidExchange = new BidExchange(); 42 | 43 | RequestLogProcessor.instance.setLogData(this); 44 | RequestMonitor.monitorRequests(); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/exchange/VastResolverBroker.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.exchange; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.apache.http.NameValuePair; 8 | import org.apache.http.client.entity.UrlEncodedFormEntity; 9 | import org.apache.http.client.methods.HttpPost; 10 | import org.apache.http.message.BasicNameValuePair; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | import com.atg.openssp.common.core.connector.JsonPostConnector; 15 | import com.atg.openssp.common.exception.BidProcessingException; 16 | 17 | /** 18 | * @author André Schmer 19 | * 20 | */ 21 | public class VastResolverBroker { 22 | 23 | private final Logger log = LoggerFactory.getLogger(VastResolverBroker.class); 24 | 25 | private final JsonPostConnector jsonPostConnector; 26 | 27 | private final String endPoint; 28 | 29 | public VastResolverBroker() { 30 | // set up endpoint 31 | endPoint = ""; 32 | jsonPostConnector = new JsonPostConnector(); 33 | } 34 | 35 | public String call(final String vast, final String adid, final String zoneid) { 36 | final List nameValuePairs = new ArrayList<>(); 37 | nameValuePairs.add(new BasicNameValuePair("adid", adid)); 38 | nameValuePairs.add(new BasicNameValuePair("zoneid", zoneid)); 39 | nameValuePairs.add(new BasicNameValuePair("vast", vast)); 40 | 41 | try { 42 | return jsonPostConnector.connect(new UrlEncodedFormEntity(nameValuePairs, StandardCharsets.UTF_8), new HttpPost(endPoint)); 43 | } catch (final BidProcessingException e) { 44 | log.error(e.getMessage()); 45 | } 46 | return null; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/exchange/channel/rtb/OpenRtbConnector.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.exchange.channel.rtb; 2 | 3 | import org.apache.http.Header; 4 | import org.apache.http.client.methods.HttpPost; 5 | import org.apache.http.entity.ContentType; 6 | import org.apache.http.entity.StringEntity; 7 | 8 | import com.atg.openssp.common.core.connector.JsonPostConnector; 9 | import com.atg.openssp.common.demand.Supplier; 10 | import com.atg.openssp.common.exception.BidProcessingException; 11 | 12 | /** 13 | * A wrapper to a concrete connector using JSON notation and post method. 14 | * 15 | * @author André Schmer 16 | * 17 | */ 18 | public class OpenRtbConnector { 19 | 20 | private final JsonPostConnector jsonPostConnector; 21 | 22 | private final String endpoint; 23 | 24 | private final Supplier supplier; 25 | 26 | public OpenRtbConnector(final Supplier supplier) { 27 | this.supplier = supplier; 28 | endpoint = supplier.getEndPoint(); 29 | jsonPostConnector = new JsonPostConnector(); 30 | } 31 | 32 | /** 33 | * Prepares the post transport. 34 | * 35 | * @param bidrequest 36 | * the request to send 37 | * @param header 38 | * to fill in connection header 39 | * @return the body result from the response 40 | * @throws BidProcessingException 41 | */ 42 | String connect(final String bidrequest, final Header[] header) throws BidProcessingException { 43 | final HttpPost httpPost = new HttpPost(endpoint); 44 | httpPost.setHeaders(header); 45 | return jsonPostConnector.connect(new StringEntity(bidrequest, ContentType.APPLICATION_JSON), httpPost); 46 | } 47 | 48 | public Supplier getSupplier() { 49 | return supplier; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/InitLogging.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system; 2 | 3 | import util.CatalinaUtil; 4 | 5 | /** 6 | * @author André Schmer 7 | * 8 | */ 9 | class InitLogging { 10 | 11 | static void setSystemProperties() { 12 | System.setProperty("tomcatid", CatalinaUtil.instanceName()); 13 | if (false == "localhost".equals(CatalinaUtil.instanceName())) { 14 | System.setProperty("log4j.configurationFile", CatalinaUtil.catalinaHome() + "/properties/log4j2.xml"); 15 | } 16 | System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); 17 | System.setProperty("pid", CatalinaUtil.pid()); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/MetricFactory.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import com.codahale.metrics.Counter; 6 | import com.codahale.metrics.Histogram; 7 | import com.codahale.metrics.MetricRegistry; 8 | import com.codahale.metrics.Slf4jReporter; 9 | 10 | /** 11 | * @author André Schmer 12 | * 13 | */ 14 | public class MetricFactory { 15 | 16 | public static final MetricFactory instance = new MetricFactory(); 17 | 18 | private final MetricRegistry registry; 19 | 20 | private Histogram histogram; 21 | 22 | private Counter requests; 23 | 24 | private MetricFactory() { 25 | registry = new MetricRegistry(); 26 | } 27 | 28 | public void initMetrics() { 29 | requests = registry.counter("requests"); 30 | histogram = registry.histogram("histogram"); 31 | } 32 | 33 | public Counter getRequestCounter() { 34 | return requests; 35 | } 36 | 37 | public Histogram getHistogram() { 38 | return histogram; 39 | } 40 | 41 | void startMetricReport() { 42 | // final CsvReporter reporter = CsvReporter.forRegistry(registry).formatFor(Locale.US).convertRatesTo( 43 | // TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(new File("metrics.csv")); 44 | // final ConsoleReporter reporter = ConsoleReporter.forRegistry(registry).convertRatesTo(TimeUnit.SECONDS) 45 | // .convertDurationsTo(TimeUnit.MILLISECONDS).build(); 46 | 47 | final Slf4jReporter reporter = Slf4jReporter.forRegistry(registry).outputTo(new AbstractLogger()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS) 48 | .build(); 49 | reporter.start(1, TimeUnit.SECONDS); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/job/CacheTriggerController.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system.job; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import com.atg.openssp.common.jobservice.CommonJobTrigger; 7 | 8 | /** 9 | * @author André Schmer 10 | * 11 | */ 12 | public class CacheTriggerController { 13 | 14 | private static final Logger log = LoggerFactory.getLogger(CacheTriggerController.class); 15 | 16 | /** 17 | * Checks if the cronExpression for execution regarding jobName has changed. In case of true, the new expression will be updated. 18 | * 19 | * @param cronExpression 20 | */ 21 | public static void checkForExpressionUpdate(final String cronExpression, final String jobName) { 22 | final CommonJobTrigger job = JobService.instance.getJobByName(jobName); 23 | 24 | if (job == null || job.getExpression().equals(cronExpression)) { 25 | // do nothing - up to date 26 | return; 27 | } 28 | log.info("found expression changes [" + cronExpression + "] reiniting " + jobName); 29 | job.reinitJob(cronExpression); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/job/CoreCacheLoaderJob.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system.job; 2 | 3 | import org.quartz.Job; 4 | import org.quartz.JobExecutionContext; 5 | import org.quartz.JobExecutionException; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import com.atg.openssp.core.cache.broker.CacheController; 10 | import com.atg.openssp.core.system.LocalContext; 11 | 12 | /** 13 | * @author André Schmer 14 | * 15 | */ 16 | public class CoreCacheLoaderJob implements Job { 17 | 18 | private static final Logger log = LoggerFactory.getLogger(CoreCacheLoaderJob.class); 19 | 20 | @Override 21 | public void execute(final JobExecutionContext context) throws JobExecutionException { 22 | if (LocalContext.isVerboseEnabled()) { 23 | log.info(this.getClass().getSimpleName() + " fired ... next fire time: " + context.getNextFireTime()); 24 | } 25 | CacheController.instance.update(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/job/JobConfig.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system.job; 2 | 3 | import com.atg.openssp.common.jobservice.CommonJobTrigger; 4 | 5 | /** 6 | * This class is useful to set a configuration for a job which can than be used by {@link CommonJobTrigger}. 7 | * 8 | * @author André Schmer 9 | * 10 | */ 11 | public class JobConfig { 12 | 13 | private Class jobClass; 14 | private String jobName; 15 | private String expression; 16 | 17 | public JobConfig() {} 18 | 19 | public static Builder newBuilder() { 20 | return new Builder(); 21 | } 22 | 23 | public void setJobClass(final Class clazz) { 24 | jobClass = clazz; 25 | } 26 | 27 | public void setExpression(final String expression) { 28 | this.expression = expression; 29 | } 30 | 31 | public void setJobName(final String jobname) { 32 | jobName = jobname; 33 | } 34 | 35 | public String getJobName() { 36 | return jobName; 37 | } 38 | 39 | public Class getJobClazz() { 40 | return jobClass; 41 | } 42 | 43 | public String getExpression() { 44 | return expression; 45 | } 46 | 47 | public static class Builder { 48 | 49 | private final JobConfig config; 50 | 51 | public Builder() { 52 | config = new JobConfig(); 53 | } 54 | 55 | public Builder setJobClass(final Class clazz) { 56 | config.setJobClass(clazz); 57 | return this; 58 | } 59 | 60 | public Builder setJobName(final String jobname) { 61 | config.setJobName(jobname); 62 | return this; 63 | } 64 | 65 | public Builder setExpression(final String expression) { 66 | config.setExpression(expression); 67 | return this; 68 | } 69 | 70 | /** 71 | * Creates the {@link JobConfig} This is a terminal Method. 72 | * 73 | * @return JobConfig 74 | */ 75 | public JobConfig build() { 76 | return config; 77 | } 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/job/JobService.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system.job; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.Map.Entry; 6 | 7 | import com.atg.openssp.common.jobservice.CommonJobTrigger; 8 | 9 | /** 10 | * @author André Schmer 11 | * 12 | */ 13 | public class JobService { 14 | 15 | public static final JobService instance = new JobService(); 16 | 17 | private final Map triggerList; 18 | 19 | private JobService() { 20 | triggerList = new HashMap<>(); 21 | System.setProperty("org.quartz.scheduler.skipUpdateCheck", "true"); 22 | System.setProperty("org.quartz.scheduler.interruptJobsOnShutdownWithWait", "true"); 23 | } 24 | 25 | public void initJob(final JobConfig jobConfig) { 26 | final CommonJobTrigger trigger = new CommonJobTrigger(); 27 | trigger.initJob(jobConfig.getJobClazz(), jobConfig.getJobName(), jobConfig.getExpression()); 28 | trigger.startScheduling(); 29 | triggerList.put(jobConfig.getJobName(), trigger); 30 | } 31 | 32 | public void shutdown() { 33 | for (final Entry commonJobTrigger : triggerList.entrySet()) { 34 | commonJobTrigger.getValue().shutdown(); 35 | } 36 | } 37 | 38 | CommonJobTrigger getJobByName(final String jobName) { 39 | return triggerList.get(jobName); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/job/ResetCounterJob.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system.job; 2 | 3 | import org.quartz.Job; 4 | import org.quartz.JobExecutionContext; 5 | import org.quartz.JobExecutionException; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import com.atg.openssp.common.core.entry.RequestMonitor; 10 | import com.atg.openssp.core.system.LocalContext; 11 | 12 | /** 13 | * 14 | * @author André Schmer 15 | * 16 | */ 17 | public class ResetCounterJob implements Job { 18 | 19 | private static final Logger log = LoggerFactory.getLogger(ResetCounterJob.class); 20 | 21 | @Override 22 | public void execute(final JobExecutionContext context) throws JobExecutionException { 23 | if (LocalContext.isVerboseEnabled()) { 24 | log.info(this.getClass().getSimpleName() + " fired ... next fire time: " + context.getNextFireTime()); 25 | } 26 | 27 | RequestMonitor.resetCounter(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/job/WatchdogService.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system.job; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.concurrent.ExecutorService; 6 | import java.util.concurrent.Executors; 7 | import java.util.concurrent.ThreadFactory; 8 | 9 | import com.atg.openssp.common.watchdog.Watchdog; 10 | import com.atg.openssp.core.system.loader.AbstractConfigurationLoader; 11 | import com.google.common.util.concurrent.ThreadFactoryBuilder; 12 | 13 | /** 14 | * @author André Schmer 15 | * 16 | */ 17 | public class WatchdogService { 18 | 19 | public static WatchdogService instance = new WatchdogService(); 20 | 21 | private final List watchdogs; 22 | 23 | private final ExecutorService executorService; 24 | 25 | private WatchdogService() { 26 | watchdogs = new ArrayList<>(); 27 | final ThreadFactory watchdogThreadFactory = new ThreadFactoryBuilder().setNameFormat("CoreEngine-WatchDog-%d").setDaemon(true).build(); 28 | executorService = Executors.newCachedThreadPool(watchdogThreadFactory); 29 | } 30 | 31 | public WatchdogService initLoaderWatchdog(final AbstractConfigurationLoader loader, final boolean startJobImmediately) { 32 | watchdogs.add(new Watchdog(loader, startJobImmediately)); 33 | return this; 34 | } 35 | 36 | /** 37 | * Terminal Method 38 | */ 39 | public void startWatchdogs() { 40 | for (final Runnable r : watchdogs) { 41 | executorService.execute(r); 42 | } 43 | } 44 | 45 | public void shutdown() { 46 | for (final Watchdog w : watchdogs) { 47 | w.shutDown(); 48 | } 49 | 50 | executorService.shutdown(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/loader/ConfigLoader.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system.loader; 2 | 3 | import java.util.concurrent.CountDownLatch; 4 | 5 | import com.atg.openssp.common.configuration.Context; 6 | import com.atg.openssp.common.configuration.ContextProperties; 7 | import com.atg.openssp.common.configuration.GlobalContext; 8 | 9 | /** 10 | * @author André Schmer 11 | * 12 | */ 13 | public class ConfigLoader extends AbstractConfigurationLoader { 14 | 15 | public ConfigLoader() { 16 | super(Context.CONFIG_XML); 17 | } 18 | 19 | public ConfigLoader(final CountDownLatch cdl) { 20 | super(Context.CONFIG_XML, cdl); 21 | } 22 | 23 | @Override 24 | protected void readSpecials(final ContextProperties key, final String value) { 25 | // noting to do 26 | } 27 | 28 | @Override 29 | protected void finalWork() { 30 | GlobalContext.refreshContext(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/loader/GlobalContextLoader.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system.loader; 2 | 3 | import java.util.concurrent.CountDownLatch; 4 | 5 | import com.atg.openssp.common.configuration.Context; 6 | import com.atg.openssp.common.configuration.ContextProperties; 7 | import com.atg.openssp.common.configuration.GlobalContext; 8 | import com.atg.openssp.core.system.job.CacheTriggerController; 9 | 10 | /** 11 | * @author André Schmer 12 | * 13 | */ 14 | public class GlobalContextLoader extends AbstractConfigurationLoader { 15 | 16 | public GlobalContextLoader() { 17 | super(Context.RUNTIME_GLOBAL_XML); 18 | } 19 | 20 | public GlobalContextLoader(final CountDownLatch cdl) { 21 | super(Context.RUNTIME_GLOBAL_XML, cdl); 22 | } 23 | 24 | @Override 25 | protected void readSpecials(final ContextProperties key, final String value) { 26 | if (ContextProperties.TRIGGER_EXPESSION == key) { 27 | CacheTriggerController.checkForExpressionUpdate(value, "CoreCacheLoaderJob"); 28 | } 29 | } 30 | 31 | @Override 32 | protected void finalWork() { 33 | GlobalContext.refreshContext(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/loader/LocalContextLoader.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system.loader; 2 | 3 | import java.util.concurrent.CountDownLatch; 4 | 5 | import com.atg.openssp.common.configuration.Context; 6 | import com.atg.openssp.common.configuration.ContextProperties; 7 | import com.atg.openssp.core.system.LocalContext; 8 | 9 | /** 10 | * @author André Schmer 11 | * 12 | */ 13 | public class LocalContextLoader extends AbstractConfigurationLoader { 14 | 15 | public LocalContextLoader() { 16 | super(Context.RUNTIME_LOCAL_XML); 17 | } 18 | 19 | public LocalContextLoader(final CountDownLatch cdl) { 20 | super(Context.RUNTIME_LOCAL_XML, cdl); 21 | } 22 | 23 | @Override 24 | protected void readSpecials(final ContextProperties key, final String value) { 25 | if (ContextProperties.DEBUG == key) { 26 | // TODO: enable if necessary 27 | if ("true".equals(value)) { 28 | // LogFacade.initLogging(Level.DEBUG); 29 | } else { 30 | // LogFacade.initLogging(Level.INFO); 31 | } 32 | } 33 | } 34 | 35 | @Override 36 | protected void finalWork() { 37 | LocalContext.refreshContext(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/java/com/atg/openssp/core/system/properties/MavenProperties.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.core.system.properties; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.util.Properties; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | /** 11 | * @author André Schmer 12 | * 13 | */ 14 | public class MavenProperties { 15 | 16 | private static final Logger log = LoggerFactory.getLogger(MavenProperties.class); 17 | 18 | private String version = ""; 19 | 20 | /** 21 | * Uses the resource path from class to load the pom.properties of the given groupID and artifactID. {final-name}, {groupId}, {artifactId} 22 | */ 23 | public MavenProperties() { 24 | try { 25 | final InputStream is = this.getClass().getResourceAsStream("/app.properties"); 26 | final Properties properties = new Properties(); 27 | properties.load(is); 28 | version = properties.getProperty("version"); 29 | } catch (final IOException e) { 30 | log.error(e.getMessage()); 31 | } 32 | } 33 | 34 | /** 35 | * Returns the version number from the Maven generated pom.properies or "" if not available. 36 | * 37 | * @return version as String 38 | */ 39 | public String getVersion() { 40 | return version; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/resources/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | false 10 | 11 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/resources/global.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 0.3 11 | 12 | 13 | 14 | 500 15 | 16 | 17 | http 18 | 19 | localhost 20 | 21 | 9090 22 | 23 | 24 | frogs 25 | 26 | 27 | izod 28 | 29 | 30 | http 31 | 32 | localhost 33 | 34 | 8082 35 | 36 | /dsp-sim/myAds 37 | 38 | io.freestar.ssp.entry.FreestarEntryValidatorForVideoHandler 39 | 40 | io.freestar.ssp.entry.FreestarEntryValidatorForBannerHandler 41 | 42 | io.freestar.ssp.channel.adserving.FreestarAdserverBrokerHandler 43 | 44 | io.freestar.ssp.exchange.FreestarBidRequestBuilderHandler 45 | 46 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/resources/local.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | 7 | 8 | false 9 | 10 | 11 | false 12 | 13 | 14 | true 15 | 16 | 17 | false 18 | 19 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/resources/price_layer.json: -------------------------------------------------------------------------------- 1 | { 2 | "pricelayer": [{ 3 | "siteid": "1", 4 | "bidfloor": 1.2, 5 | "currency": "USD" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/resources/site_db.json: -------------------------------------------------------------------------------- 1 | { 2 | "sites": [{ 3 | "id": "1", 4 | "name": "site_1", 5 | "domain": "size_1.com", 6 | "cat": ["1"], 7 | "page": "www.site_1.com", 8 | "publisher": { 9 | "id": "pubisher_1", 10 | "name": "publisher_1_name", 11 | "cat": [], 12 | "domain": "www.publisher_1.com", 13 | "ext": null 14 | }, 15 | "ext": null 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/resources/supplier_db.json: -------------------------------------------------------------------------------- 1 | { 2 | "supplier": [{ 3 | "shortName": "dsp_1", 4 | "endPoint": "http://localhost:8082/dsp-sim/DemandService", 5 | "connectionKeepAlive": true, 6 | "openRtbVersion": 2.2, 7 | "contentType": "application/json", 8 | "supplierId": "1", 9 | "currency": "USD", 10 | "underTest": 0, 11 | "active": 0 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ATG SSP 4 | 5 | ApplicationInit 6 | com.atg.openssp.core.system.ApplicationInit 7 | 1 8 | 9 | -------------------------------------------------------------------------------- /open-ssp-parent/core/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Root logger option 2 | log4j.rootLogger=debug, stdout 3 | 4 | # Direct log messages to stdout 5 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 6 | log4j.appender.stdout.Target=System.out 7 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 8 | log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/.gitignore: -------------------------------------------------------------------------------- 1 | /.settings/ 2 | /target/ 3 | /.classpath 4 | /.project 5 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/annotation/RuntimeConfig.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import com.atg.openssp.common.configuration.ContextProperties; 10 | 11 | /** 12 | * @author André Schmer 13 | * 14 | */ 15 | @Documented 16 | @Retention(value = RetentionPolicy.RUNTIME) 17 | @Target({ ElementType.FIELD, ElementType.METHOD }) 18 | public @interface RuntimeConfig { 19 | 20 | ContextProperties type(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/annotation/RuntimeMeta.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * @author André Schmer 11 | * 12 | */ 13 | @Documented 14 | @Retention(value = RetentionPolicy.RUNTIME) 15 | @Target({ ElementType.FIELD, ElementType.METHOD }) 16 | public @interface RuntimeMeta { 17 | 18 | Scope type(); 19 | 20 | boolean printable() default true; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/annotation/Scope.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.annotation; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public enum Scope { 8 | 9 | LOCAL("Local Property"), 10 | 11 | GLOBAL("Global Property"); 12 | 13 | private String value; 14 | 15 | private Scope(final String value) { 16 | this.value = value; 17 | } 18 | 19 | public String getValue() { 20 | return value; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/buffer/AdservingLatencyBuffer.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.buffer; 2 | 3 | import java.time.LocalDate; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import com.atg.openssp.common.configuration.Context; 9 | 10 | /** 11 | * @author André Schmer 12 | */ 13 | public class AdservingLatencyBuffer extends LongTypedBuffer implements Runnable { 14 | 15 | private static final Logger log = LoggerFactory.getLogger(AdservingLatencyBuffer.class); 16 | 17 | private static final AdservingLatencyBuffer instance = new AdservingLatencyBuffer(); 18 | 19 | public static AdservingLatencyBuffer getBuffer() { 20 | return instance; 21 | } 22 | 23 | private AdservingLatencyBuffer() { 24 | super(100); 25 | new Thread(this).start(); 26 | } 27 | 28 | @Override 29 | public void run() { 30 | try { 31 | latch.await(); 32 | } catch (final InterruptedException e) { 33 | log.error("{} latch interrupted", LocalDate.now(Context.zoneId)); 34 | // clear state 35 | latch = null; 36 | // Moved into catch to make more clear interrupting throw after exception ... 37 | Thread.currentThread().interrupt(); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/buffer/LongTypedBuffer.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.buffer; 2 | 3 | import java.util.concurrent.CountDownLatch; 4 | 5 | import util.SimpleRingBuffer; 6 | 7 | /** 8 | * @author André Schmer 9 | * 10 | */ 11 | class LongTypedBuffer { 12 | 13 | private final SimpleRingBuffer rb; 14 | protected CountDownLatch latch; 15 | 16 | LongTypedBuffer(final int capacity) { 17 | rb = new SimpleRingBuffer<>(capacity, Long.class); 18 | latch = new CountDownLatch(1); 19 | } 20 | 21 | public void bufferValue(final long item) { 22 | rb.add(item); 23 | } 24 | 25 | public Long[] getBufferedData() { 26 | return rb.getAll(); 27 | } 28 | 29 | public void shutDown() { 30 | latch.countDown(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/buffer/SSPLatencyBuffer.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.buffer; 2 | 3 | import java.time.LocalDate; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import com.atg.openssp.common.configuration.Context; 9 | 10 | /** 11 | * @author André Schmer 12 | */ 13 | public class SSPLatencyBuffer extends LongTypedBuffer implements Runnable { 14 | 15 | private static final Logger log = LoggerFactory.getLogger(SSPLatencyBuffer.class); 16 | 17 | private static final SSPLatencyBuffer instance = new SSPLatencyBuffer(); 18 | 19 | public static SSPLatencyBuffer getBuffer() { 20 | return instance; 21 | } 22 | 23 | private SSPLatencyBuffer() { 24 | super(100); 25 | new Thread(this).start(); 26 | } 27 | 28 | @Override 29 | public void run() { 30 | try { 31 | latch.await(); 32 | } catch (final InterruptedException e) { 33 | log.error("{} latch interrupted", LocalDate.now(Context.zoneId)); 34 | // clear state 35 | latch = null; 36 | // Moved into catch to make more clear interrupting throw after exception ... 37 | Thread.currentThread().interrupt(); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/buffer/VastResolverLatencyBuffer.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.buffer; 2 | 3 | import java.time.LocalDate; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import com.atg.openssp.common.configuration.Context; 9 | 10 | /** 11 | * @author André Schmer 12 | */ 13 | public class VastResolverLatencyBuffer extends LongTypedBuffer implements Runnable { 14 | 15 | private static final Logger log = LoggerFactory.getLogger(VastResolverLatencyBuffer.class); 16 | 17 | private static final VastResolverLatencyBuffer instance = new VastResolverLatencyBuffer(); 18 | 19 | public static VastResolverLatencyBuffer getBuffer() { 20 | return instance; 21 | } 22 | 23 | private VastResolverLatencyBuffer() { 24 | super(100); 25 | new Thread(this).start(); 26 | } 27 | 28 | @Override 29 | public void run() { 30 | try { 31 | latch.await(); 32 | } catch (final InterruptedException e) { 33 | log.error("{} latch interrupted" + LocalDate.now(Context.zoneId)); 34 | // clear state 35 | latch = null; 36 | // Moved into catch to make more clear interrupting throw after exception ... 37 | Thread.currentThread().interrupt(); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/cache/CurrencyCache.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.cache; 2 | 3 | /** 4 | * Cache implementation for storing currency rates for EUR as base. 5 | * 6 | * @author André Schmer 7 | * 8 | */ 9 | public final class CurrencyCache extends MapCache { 10 | 11 | public static final CurrencyCache instance = new CurrencyCache(); 12 | 13 | private CurrencyCache() { 14 | super(); 15 | } 16 | 17 | @Override 18 | public Float get(final String key) { 19 | if (key != null && wcache.containsKey(key)) { 20 | return wcache.get(key) != 0.0f ? wcache.get(key) : 1.0f; 21 | } 22 | return 1.0f; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/cache/DynamicCache.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.cache; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public interface DynamicCache { 8 | 9 | void switchCache(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/cache/ListCache.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.cache; 2 | 3 | import java.time.LocalDateTime; 4 | import java.util.List; 5 | import java.util.concurrent.CopyOnWriteArrayList; 6 | 7 | import com.atg.openssp.common.configuration.Context; 8 | 9 | /** 10 | * @author André Schmer 11 | * 12 | */ 13 | public class ListCache implements DynamicCache { 14 | 15 | // the working cache. holds the actual data for working 16 | protected List wcache; 17 | // the temporarily cache, to serve as for updating the cache 18 | private final List tcache; 19 | 20 | // reference holder for working cache 21 | private final List b; 22 | private final List a; 23 | 24 | private boolean ab = true; 25 | 26 | private String updateTime; 27 | 28 | public ListCache() { 29 | this.tcache = new CopyOnWriteArrayList<>(); 30 | this.wcache = new CopyOnWriteArrayList<>(); 31 | this.b = new CopyOnWriteArrayList<>(); 32 | this.a = new CopyOnWriteArrayList<>(); 33 | } 34 | 35 | public final void add(final T key) { 36 | this.tcache.add(key); 37 | } 38 | 39 | /** 40 | * Creates a new copy of this cache. 41 | * 42 | * @return 43 | */ 44 | public final List getAll() { 45 | return new CopyOnWriteArrayList<>(this.wcache); 46 | } 47 | 48 | public final boolean contains(final T key) { 49 | return this.wcache.contains(key); 50 | } 51 | 52 | @Override 53 | public final void switchCache() { 54 | if (!this.tcache.isEmpty()) { 55 | if (this.ab) { 56 | this.a.addAll(this.tcache); 57 | this.wcache = this.a; 58 | this.b.clear(); 59 | } else { 60 | this.b.addAll(this.tcache); 61 | this.wcache = this.b; 62 | this.a.clear(); 63 | } 64 | this.ab = !this.ab; 65 | this.tcache.clear(); 66 | this.updateTime = LocalDateTime.now().format(Context.dateFormatter); 67 | } 68 | } 69 | 70 | public String getUpdateTime() { 71 | return this.updateTime; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/cache/broker/AbstractDataBroker.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.cache.broker; 2 | 3 | import com.atg.openssp.common.configuration.ContextCache; 4 | import com.atg.openssp.common.configuration.ContextProperties; 5 | import com.atg.openssp.common.exception.EmptyHostException; 6 | 7 | import restful.client.JsonDataProviderConnector; 8 | import restful.context.PathBuilder; 9 | import restful.exception.RestException; 10 | 11 | /** 12 | * Generic Broker to connect to a remote webservice. 13 | * 14 | * @author André Schmer 15 | * 16 | */ 17 | public abstract class AbstractDataBroker extends DataBrokerObserver { 18 | 19 | protected T connect(final Class clazz) throws RestException, EmptyHostException { 20 | return new JsonDataProviderConnector<>(clazz).connectDataProvider(getRestfulContext()); 21 | } 22 | 23 | protected PathBuilder getDefaulPathBuilder() { 24 | final PathBuilder pathBuilder = new PathBuilder(); 25 | pathBuilder.setMaster_pw(ContextCache.instance.get(ContextProperties.MASTER_PW)); 26 | pathBuilder.setMaster_user(ContextCache.instance.get(ContextProperties.MASTER_USER)); 27 | pathBuilder.setScheme(ContextCache.instance.get(ContextProperties.DATA_PROVIDER_SCHEME)); 28 | pathBuilder.setHost(ContextCache.instance.get(ContextProperties.DATA_PROVIDER_HOST)); 29 | pathBuilder.setPort(ContextCache.instance.get(ContextProperties.DATA_PROVIDER_PORT)); 30 | return pathBuilder; 31 | } 32 | 33 | /** 34 | * @return the context of the restful service to connect with {see PathBuilder}. 35 | * @throws EmptyHostException 36 | */ 37 | public abstract PathBuilder getRestfulContext() throws EmptyHostException; 38 | } 39 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/cache/broker/DataBrokerObserver.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.cache.broker; 2 | 3 | import java.util.Observable; 4 | import java.util.Observer; 5 | 6 | /** 7 | * @author André Schmer 8 | * 9 | */ 10 | public abstract class DataBrokerObserver implements Observer { 11 | 12 | public DataBrokerObserver() {} 13 | 14 | @Override 15 | public void update(final Observable o, final Object arg) { 16 | boolean isCacheSuccees = false; 17 | try { 18 | isCacheSuccees = doCaching(); 19 | } finally { 20 | if (isCacheSuccees) { 21 | finalWork(); 22 | } 23 | } 24 | } 25 | 26 | /** 27 | * Enforces the caching. 28 | * 29 | * @return true if caching was succeeded, false otherwise. 30 | */ 31 | protected abstract boolean doCaching(); 32 | 33 | /** 34 | * Do some final works on the special caches such as switch the key value store. 35 | */ 36 | protected abstract void finalWork(); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/cache/dto/VideoAd.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.cache.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.google.gson.annotations.SerializedName; 6 | 7 | /** 8 | * @author André Schmer 9 | * 10 | */ 11 | public class VideoAd implements Serializable { 12 | 13 | private static final long serialVersionUID = 2035631518654057068L; 14 | 15 | @SerializedName("videoad_id") 16 | private int videoadId; 17 | 18 | @SerializedName("bidfloor_currency") 19 | private String bidfloorCurrency = "EUR"; 20 | 21 | @SerializedName("bidfloor_price") 22 | private float bidfloorPrice; 23 | 24 | @SerializedName("min_duration") 25 | private int minDuration; 26 | 27 | @SerializedName("max_duration") 28 | private int maxDuration; 29 | 30 | public VideoAd() {} 31 | 32 | public int getVideoadId() { 33 | return videoadId; 34 | } 35 | 36 | public void setVideoadId(final int videoadId) { 37 | this.videoadId = videoadId; 38 | } 39 | 40 | public String getBidfloorCurrency() { 41 | return bidfloorCurrency; 42 | } 43 | 44 | public void setBidfloorCurrency(final String bidfloorCurrency) { 45 | this.bidfloorCurrency = bidfloorCurrency; 46 | } 47 | 48 | public float getBidfloorPrice() { 49 | return bidfloorPrice; 50 | } 51 | 52 | public void setBidfloorPrice(final float bidfloorPrice) { 53 | this.bidfloorPrice = bidfloorPrice; 54 | } 55 | 56 | public int getMinDuration() { 57 | return minDuration; 58 | } 59 | 60 | public void setMinDuration(final int minDuration) { 61 | this.minDuration = minDuration; 62 | } 63 | 64 | public int getMaxDuration() { 65 | return maxDuration; 66 | } 67 | 68 | public void setMaxDuration(final int maxDuration) { 69 | this.maxDuration = maxDuration; 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return String.format("VideoAd [videoadId=%s, bidfloorCurrency=%s, bidfloorPrice=%s, minDuration=%s, maxDuration=%s]", videoadId, bidfloorCurrency, bidfloorPrice, 75 | minDuration, maxDuration); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/cache/dto/Zone.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.cache.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.Arrays; 5 | 6 | import com.google.gson.annotations.SerializedName; 7 | 8 | /** 9 | * @author André Schmer 10 | * 11 | */ 12 | public class Zone implements Serializable { 13 | 14 | private static final long serialVersionUID = -1326925356645010127L; 15 | 16 | @SerializedName("zone_id") 17 | private int zoneId; 18 | 19 | // @SerializedName("website_id") 20 | private int websiteId; 21 | 22 | @SerializedName("site_id") 23 | private String siteId; 24 | 25 | @SerializedName("site_name") 26 | private String siteName; 27 | 28 | @SerializedName("iab_categories") 29 | private String[] categories; 30 | 31 | public Zone() {} 32 | 33 | public int getZoneId() { 34 | return zoneId; 35 | } 36 | 37 | public void setZoneId(final int zoneId) { 38 | this.zoneId = zoneId; 39 | } 40 | 41 | public int getWebsiteId() { 42 | return websiteId; 43 | } 44 | 45 | public void setWebsiteId(final int websiteId) { 46 | this.websiteId = websiteId; 47 | } 48 | 49 | public String getSiteId() { 50 | return siteId; 51 | } 52 | 53 | public void setSiteId(final String siteId) { 54 | this.siteId = siteId; 55 | } 56 | 57 | public String getSiteName() { 58 | return siteName; 59 | } 60 | 61 | public void setSiteName(final String siteName) { 62 | this.siteName = siteName; 63 | } 64 | 65 | public String[] getCategories() { 66 | return categories; 67 | } 68 | 69 | public void setCategories(final String[] categories) { 70 | this.categories = categories; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return String.format("Zone [zoneId=%s, siteId=%s, siteName=%s, categories=%s]", zoneId, siteId, siteName, Arrays.toString(categories)); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/configuration/Context.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.configuration; 2 | 3 | import java.time.ZoneId; 4 | import java.time.format.DateTimeFormatter; 5 | 6 | /** 7 | * @author André Schmer 8 | * 9 | */ 10 | public class Context { 11 | 12 | /** 13 | * yyyy-MM-dd HH:mm 14 | */ 15 | public static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); 16 | 17 | /** 18 | * yyyy-MM-dd 19 | */ 20 | public static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); 21 | 22 | /** 23 | * "Europe/Berlin" 24 | */ 25 | public static final ZoneId zoneId = ZoneId.of("Europe/Berlin"); 26 | 27 | /** 28 | * {@value #RUNTIME_LOCAL_XML} 29 | */ 30 | public static final String RUNTIME_LOCAL_XML = "local.runtime.xml"; 31 | 32 | /** 33 | * {@value #RUNTIME_GLOBAL_XML} 34 | */ 35 | public static final String RUNTIME_GLOBAL_XML = "global.runtime.xml"; 36 | 37 | /** 38 | * {@value #CONFIG_XML} 39 | */ 40 | public static final String CONFIG_XML = "config.xml"; 41 | 42 | /** 43 | * {@value #SOCKET_TO} 44 | */ 45 | public static final int SOCKET_TO = 2000; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/configuration/ContextCache.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.configuration; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.ConcurrentHashMap; 5 | 6 | /** 7 | * Cache for System Properties. 8 | * 9 | * @author André Schmer 10 | * 11 | */ 12 | public final class ContextCache { 13 | 14 | public static final ContextCache instance = new ContextCache(); 15 | 16 | private final Map cache; 17 | 18 | private ContextCache() { 19 | cache = new ConcurrentHashMap<>(); 20 | } 21 | 22 | public String get(final ContextProperties key) { 23 | return cache.get(key); 24 | } 25 | 26 | public void put(final ContextProperties key, final String value) { 27 | if (key == null) { 28 | throw new IllegalArgumentException("key is null"); 29 | } 30 | if (value != null) { 31 | cache.put(key, value); 32 | } 33 | } 34 | 35 | public String remove(final ContextProperties key) { 36 | try { 37 | return cache.remove(key); 38 | } catch (final NullPointerException ignore) {} 39 | return null; 40 | } 41 | 42 | public boolean isEmpty() { 43 | return cache.isEmpty(); 44 | } 45 | 46 | public int size() { 47 | return cache.size(); 48 | } 49 | 50 | public Map getAll() { 51 | return new ConcurrentHashMap<>(cache); 52 | } 53 | 54 | public void clear() { 55 | cache.clear(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/core/broker/AbstractBroker.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.core.broker; 2 | 3 | import com.atg.openssp.common.core.entry.SessionAgent; 4 | 5 | /** 6 | * @author André Schmer 7 | * 8 | */ 9 | public class AbstractBroker { 10 | 11 | protected SessionAgent sessionAgent; 12 | 13 | public SessionAgent getSessionAgent() { 14 | return sessionAgent; 15 | } 16 | 17 | public void setSessionAgent(final SessionAgent sessionAgent) { 18 | this.sessionAgent = sessionAgent; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/core/connector/DefaultConnector.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.core.connector; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import org.apache.http.client.HttpRequestRetryHandler; 6 | import org.apache.http.config.SocketConfig; 7 | import org.apache.http.impl.client.CloseableHttpClient; 8 | import org.apache.http.impl.client.DefaultHttpRequestRetryHandler; 9 | import org.apache.http.impl.client.HttpClients; 10 | import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; 11 | 12 | import com.atg.openssp.common.configuration.Context; 13 | 14 | /** 15 | * @author André Schmer 16 | * 17 | */ 18 | public class DefaultConnector { 19 | 20 | protected CloseableHttpClient httpClient; 21 | 22 | /** 23 | * 24 | */ 25 | public DefaultConnector() { 26 | final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); 27 | cm.closeIdleConnections(120, TimeUnit.SECONDS); 28 | 29 | // would be nice to set this from outside -> keep alive 30 | final SocketConfig sConfig = SocketConfig.custom().setSoKeepAlive(true).setSoTimeout(Context.SOCKET_TO).build(); 31 | cm.setDefaultSocketConfig(sConfig); 32 | 33 | cm.setMaxTotal(150); 34 | cm.setDefaultMaxPerRoute(150); 35 | cm.setValidateAfterInactivity(0); 36 | 37 | final HttpRequestRetryHandler rh = new DefaultHttpRequestRetryHandler(3, true); 38 | httpClient = HttpClients.custom().setRetryHandler(rh).setConnectionManager(cm).build(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/core/entry/RequestMonitor.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.core.entry; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | /** 6 | * @author André Schmer 7 | * 8 | */ 9 | public final class RequestMonitor { 10 | 11 | private static AtomicLong atomicIntermediateRequestCounter = new AtomicLong(0); 12 | 13 | private static AtomicLong atomicTotalRequest = new AtomicLong(0); 14 | 15 | public static void monitorRequests() { 16 | atomicIntermediateRequestCounter.incrementAndGet(); 17 | atomicTotalRequest.incrementAndGet(); 18 | } 19 | 20 | public static void resetCounter() { 21 | atomicIntermediateRequestCounter.set(0); 22 | atomicTotalRequest.set(0); 23 | } 24 | 25 | public static long getCurrentCounter() { 26 | return RequestMonitor.atomicTotalRequest.longValue(); 27 | } 28 | 29 | public static long getIntermediateRequestCounter() { 30 | final long t = RequestMonitor.atomicIntermediateRequestCounter.longValue(); 31 | RequestMonitor.atomicIntermediateRequestCounter.set(0); 32 | return t; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/core/entry/SessionAgent.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.core.entry; 2 | 3 | import java.util.Random; 4 | import java.util.UUID; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | import com.atg.openssp.common.demand.BidExchange; 10 | import com.atg.openssp.common.demand.ParamValue; 11 | 12 | /** 13 | * Holding meta data. 14 | * 15 | * @author André Schmer 16 | * 17 | */ 18 | public abstract class SessionAgent { 19 | 20 | protected final String requestid; 21 | 22 | protected final HttpServletRequest httpRequest; 23 | 24 | protected final HttpServletResponse httpResponse; 25 | 26 | protected ParamValue paramValue; 27 | 28 | protected BidExchange bidExchange; 29 | 30 | public SessionAgent(final HttpServletRequest request, final HttpServletResponse response) { 31 | httpRequest = request; 32 | httpResponse = response; 33 | final Random r = new Random(); 34 | requestid = new UUID(r.nextLong(), r.nextLong()).toString(); 35 | } 36 | 37 | public HttpServletRequest getHttpRequest() { 38 | return httpRequest; 39 | } 40 | 41 | public HttpServletResponse getHttpResponse() { 42 | return httpResponse; 43 | } 44 | 45 | public String getRequestid() { 46 | return requestid; 47 | } 48 | 49 | public void cleanUp() { 50 | bidExchange = null; 51 | paramValue = null; 52 | } 53 | 54 | public ParamValue getParamValues() { 55 | return paramValue; 56 | } 57 | 58 | public BidExchange getBidExchange() { 59 | return bidExchange; 60 | } 61 | 62 | public String getRemoteIP() { 63 | return httpRequest.getRemoteAddr(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/core/exchange/Exchange.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.core.exchange; 2 | 3 | import com.atg.openssp.common.core.entry.SessionAgent; 4 | 5 | /** 6 | * @author André Schmer 7 | * 8 | */ 9 | public interface Exchange { 10 | 11 | boolean processExchange(T agent); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/demand/ResponseContainer.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.demand; 2 | 3 | import openrtb.bidresponse.model.BidResponse; 4 | 5 | /** 6 | * @author André Schmer 7 | * 8 | */ 9 | public class ResponseContainer { 10 | 11 | private final Supplier supplier; 12 | 13 | private final BidResponse bidResponse; 14 | 15 | public ResponseContainer(final Supplier supplier, final BidResponse bidResponse) { 16 | this.supplier = supplier; 17 | this.bidResponse = bidResponse; 18 | } 19 | 20 | public Supplier getSupplier() { 21 | return supplier; 22 | } 23 | 24 | public BidResponse getBidResponse() { 25 | return bidResponse; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/exception/BidProcessingException.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.exception; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class BidProcessingException extends Exception { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | private ERROR_CODE code; 12 | 13 | public BidProcessingException() { 14 | super(); 15 | } 16 | 17 | public BidProcessingException(final String msg) { 18 | super(msg); 19 | } 20 | 21 | public BidProcessingException(final ERROR_CODE code) { 22 | super(code.getValue()); 23 | this.code = code; 24 | } 25 | 26 | public ERROR_CODE getCode() { 27 | return code; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/exception/ERROR_CODE.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.exception; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public enum ERROR_CODE { 8 | 9 | /** 10 | * 400, Request Invalid. 11 | */ 12 | E400(400, "Request Invalid."), 13 | 14 | /** 15 | * 901, Technical Error. 16 | */ 17 | E901(901, "Technical Error."), 18 | 19 | /** 20 | * 906, parameter incomplete. 21 | */ 22 | E906(906, "Parameter Incomplete."), 23 | 24 | /** 25 | * 907, website not connected. 26 | */ 27 | E907(907, "website not connected."), 28 | 29 | /** 30 | * 908, zone not connected. 31 | */ 32 | E908(908, "zone not connected."), 33 | 34 | /** 35 | * 909, VideoAd not connected. 36 | */ 37 | E909(909, "VideoAd not connected."), 38 | 39 | /** 40 | * 204, no content 41 | */ 42 | E204(204, "no content"), 43 | 44 | /** 45 | * 999, gen. error 46 | */ 47 | E999(999, "gen. error"); 48 | 49 | private String value; 50 | private int code; 51 | 52 | ERROR_CODE(final int code, final String errorValue) { 53 | this.code = code; 54 | value = errorValue; 55 | } 56 | 57 | public String getValue() { 58 | return value; 59 | } 60 | 61 | public int getCode() { 62 | return code; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/exception/EmptyCacheException.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.exception; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class EmptyCacheException extends Exception { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public EmptyCacheException(final String msg) { 12 | super(msg); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/exception/EmptyHostException.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.exception; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class EmptyHostException extends Exception { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public EmptyHostException(final String msg) { 12 | super(msg); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/exception/InvalidBidException.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.exception; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class InvalidBidException extends Exception { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public InvalidBidException() { 12 | super(); 13 | } 14 | 15 | public InvalidBidException(final String msg) { 16 | super(msg); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/exception/InvalidDatePattern.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.exception; 2 | 3 | /** 4 | * 5 | * @author André Schmer 6 | * 7 | */ 8 | public class InvalidDatePattern extends Exception { 9 | 10 | private static final long serialVersionUID = 1L; 11 | 12 | public InvalidDatePattern(final String msg) { 13 | super(msg); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/exception/NotifyingException.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.exception; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class NotifyingException extends Exception { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public NotifyingException(final String message) { 12 | super(message); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/exception/RequestException.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.exception; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class RequestException extends Exception { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public RequestException(final ERROR_CODE code, final String msg) { 12 | super(msg + " " + code.getValue()); 13 | } 14 | 15 | public RequestException(final String msg) { 16 | super(msg); 17 | } 18 | 19 | public RequestException(final ERROR_CODE code) { 20 | super(code.getValue()); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/exception/RtbValidationException.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.exception; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class RtbValidationException extends Exception { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public RtbValidationException() { 12 | super(); 13 | } 14 | 15 | public RtbValidationException(final String msg) { 16 | super(msg); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/logadapter/ParamMessage.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.logadapter; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class ParamMessage { 8 | 9 | private String message; 10 | 11 | private String[] params; 12 | 13 | public String getMessage() { 14 | return message; 15 | } 16 | 17 | public void setMessage(final String message) { 18 | this.message = message; 19 | } 20 | 21 | public String[] getParams() { 22 | return params; 23 | } 24 | 25 | public void setParams(final String[] params) { 26 | this.params = params; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/model/Category.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.google.gson.annotations.SerializedName; 6 | 7 | /** 8 | * This class is also known as factual category 9 | * 10 | * @author André Schmer 11 | * 12 | */ 13 | public class Category implements Serializable { 14 | 15 | private static final long serialVersionUID = -4580169816336361287L; 16 | 17 | private int id; 18 | 19 | private String name; 20 | 21 | private String name_de; 22 | 23 | @SerializedName("factual-id") 24 | private int factual_id; 25 | 26 | @SerializedName("factual-parent-id") 27 | private int factual_parent_id; 28 | 29 | public Category() {} 30 | 31 | public int getId() { 32 | return id; 33 | } 34 | 35 | public void setId(final int id) { 36 | this.id = id; 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | public void setName(final String name) { 44 | this.name = name; 45 | } 46 | 47 | public String getName_de() { 48 | return name_de; 49 | } 50 | 51 | public void setName_de(final String name_de) { 52 | this.name_de = name_de; 53 | } 54 | 55 | public int getFactual_id() { 56 | return factual_id; 57 | } 58 | 59 | public void setFactual_id(final int factual_id) { 60 | this.factual_id = factual_id; 61 | } 62 | 63 | public int getFactual_parent_id() { 64 | return factual_parent_id; 65 | } 66 | 67 | public void setFactual_parent_id(final int factual_parent_id) { 68 | this.factual_parent_id = factual_parent_id; 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return String.format("Category [id=%s, name=%s, name_de=%s, factual_id=%s, factual_parent_id=%s]", id, name, name_de, factual_id, factual_parent_id); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/model/Country.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.model; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class Country { 8 | 9 | private String iso2; 10 | 11 | private String iso3; 12 | 13 | public Country() { 14 | } 15 | 16 | public String getIso2() { 17 | return iso2; 18 | } 19 | 20 | public void setIso2(final String iso2) { 21 | this.iso2 = iso2; 22 | } 23 | 24 | public String getIso3() { 25 | return iso3; 26 | } 27 | 28 | public void setIso3(final String iso3) { 29 | this.iso3 = iso3; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/model/EurRef.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | 7 | /** 8 | * @author André Schmer 9 | * 10 | */ 11 | @XmlRootElement 12 | public class EurRef implements Serializable { 13 | 14 | private static final long serialVersionUID = 3042644082029166306L; 15 | 16 | private String currency; 17 | 18 | private float rate; 19 | 20 | public EurRef() { 21 | } 22 | 23 | public String getCurrency() { 24 | return currency; 25 | } 26 | 27 | public void setCurrency(final String currency) { 28 | this.currency = currency; 29 | } 30 | 31 | public float getRate() { 32 | return rate; 33 | } 34 | 35 | public void setRate(final float rate) { 36 | this.rate = rate; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-common/src/main/java/com/atg/openssp/common/model/Productcategory.java: -------------------------------------------------------------------------------- 1 | package com.atg.openssp.common.model; 2 | 3 | /** 4 | * 5 | * http://www.google.com/basepages/producttype/taxonomy.en-US.txt 6 | * 7 | * @author André Schmer 8 | * 9 | */ 10 | public class Productcategory { 11 | 12 | private int id; 13 | 14 | private int gpid;// google product id, als referenz in campaign.productcategory.id 15 | 16 | private int parent_id; 17 | 18 | private int lft;// id muss >lft sein und 12 | org.openrtb 13 | openrtb-validator 14 | 2.3.2 15 | jar 16 | 17 | 18 | To ascertain whether a given JSON String, File, Reader, or Resource is a valid bid request according to OpenRTB v2.4 specifications: 19 | 20 | OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, OpenRtbVersion.V2_4); 21 | boolean valid = validator.isValid(json); 22 | 23 | To get a detailed validation report including reasons why the JSON is invalid: 24 | 25 | ValidationResult validationResult = validator.validate(json); 26 | System.out.println("valid: " + validationResult.isValid() + ", result: " + validationResult.getResult()); 27 | 28 | ## Specification Documents 29 | 30 | The specification documents used to create these OpenRTB validation schemas can be found under src/main/resources/specification and at http://www.iab.net/guidelines/rtbproject. 31 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Millennial Media, Inc. 2 | All rights reserved. 3 | Provided under BSD License as follows: 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of Millennial Media, Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from this 15 | software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTB-API-Specification-Version-2-1-FINAL.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ad-tech-group/openssp/649283da51b1de6a8f7cc8f623148eb37418f51b/open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTB-API-Specification-Version-2-1-FINAL.pdf -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTB-API-Specification-Version-2-3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ad-tech-group/openssp/649283da51b1de6a8f7cc8f623148eb37418f51b/open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTB-API-Specification-Version-2-3.pdf -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTB-API-Specification-Version-2-4-FINAL.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ad-tech-group/openssp/649283da51b1de6a8f7cc8f623148eb37418f51b/open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTB-API-Specification-Version-2-4-FINAL.pdf -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTBAPISpecificationVersion2_2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ad-tech-group/openssp/649283da51b1de6a8f7cc8f623148eb37418f51b/open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTBAPISpecificationVersion2_2.pdf -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTB_API_Specification_Version2.0_FINAL.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ad-tech-group/openssp/649283da51b1de6a8f7cc8f623148eb37418f51b/open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTB_API_Specification_Version2.0_FINAL.PDF -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTB_Mobile_RTB_API-1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ad-tech-group/openssp/649283da51b1de6a8f7cc8f623148eb37418f51b/open-ssp-parent/open-ssp-openrtb-validator/src/main/resources/specifications/OpenRTB_Mobile_RTB_API-1.0.pdf -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/java/org/openrtb/validator/OpenRtbValidatorV2_xTestRunner.java: -------------------------------------------------------------------------------- 1 | package org.openrtb.validator; 2 | 3 | import org.junit.runner.RunWith; 4 | 5 | import cucumber.api.CucumberOptions; 6 | import cucumber.api.junit.Cucumber; 7 | 8 | @RunWith(Cucumber.class) 9 | @CucumberOptions( 10 | features = {"src/test/resources/features/"}, 11 | plugin = { 12 | "pretty", 13 | "html:target", 14 | }, 15 | glue = {"org.openrtb.validator.steps"} 16 | ) 17 | 18 | public class OpenRtbValidatorV2_xTestRunner { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v1_0/bid_requests/full_bid_request_app.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "some_id", 3 | "at": 1, 4 | "tmax": 120, 5 | "imp": [ 6 | { 7 | "impid": "some_imp_id", 8 | "wseat": [ 9 | "seat1", 10 | "seat2" 11 | ], 12 | "h": 50, 13 | "w": 320, 14 | "pos": 1, 15 | "instl": 0, 16 | "btype": [ 17 | 1 18 | ], 19 | "battr": [ 20 | 1 21 | ] 22 | } 23 | ], 24 | "app": { 25 | "aid": "some_sid", 26 | "name": "some_name", 27 | "domain": "foo.com", 28 | "pid": "some_pid", 29 | "pub": "some_publisher_name", 30 | "pdomain": "foopub.com", 31 | "cat": [ 32 | "IAB1" 33 | ], 34 | "keywords": "some_keyword1,some_keyword2", 35 | "ver": "some_version", 36 | "bundle": "com.foo.mygame", 37 | "paid": 0 38 | }, 39 | "device": { 40 | "did": "some_did", 41 | "dpid": "some_dpid", 42 | "ip": "127.0.0.1", 43 | "country": "USA", 44 | "carrier": "some_carrier", 45 | "ua": "some_user_agent", 46 | "make": "some_make", 47 | "model": "some_model", 48 | "os": "some_os", 49 | "osv": "some_os_version", 50 | "js": 0, 51 | "loc": "-999.99,-999.99" 52 | }, 53 | "user": { 54 | "uid": "some_uid", 55 | "yob": 1981, 56 | "gender": "F", 57 | "zip": "02116", 58 | "country": "USA", 59 | "keywords": "some_keyword1,some_keyword2" 60 | }, 61 | "restrictions": { 62 | "bcat": [ 63 | "IAB1" 64 | ], 65 | "badv": [ 66 | "blockeduserdomain.com" 67 | ] 68 | } 69 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v1_0/bid_requests/full_bid_request_site.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "some_id", 3 | "at": 1, 4 | "tmax": 120, 5 | "imp": [ 6 | { 7 | "impid": "some_imp_id", 8 | "wseat": [ 9 | "seat1", 10 | "seat2" 11 | ], 12 | "h": 50, 13 | "w": 320, 14 | "pos": 1, 15 | "instl": 0, 16 | "btype": [ 17 | 1 18 | ], 19 | "battr": [ 20 | 1 21 | ] 22 | } 23 | ], 24 | "site": { 25 | "sid": "some_sid", 26 | "name": "some_name", 27 | "domain": "foo.com", 28 | "pid": "some_pid", 29 | "pub": "some_publisher_name", 30 | "pdomain": "foopub.com", 31 | "cat": [ 32 | "IAB1" 33 | ], 34 | "keywords": "some_keyword1,some_keyword2", 35 | "page": "http://siteabcd.com/page.htm", 36 | "ref": "http://referringsite.com/referringpage.htm", 37 | "search": "some_search" 38 | }, 39 | "device": { 40 | "did": "some_did", 41 | "dpid": "some_dpid", 42 | "ip": "127.0.0.1", 43 | "country": "USA", 44 | "carrier": "some_carrier", 45 | "ua": "some_user_agent", 46 | "make": "some_make", 47 | "model": "some_model", 48 | "os": "some_os", 49 | "osv": "some_os_version", 50 | "js": 0, 51 | "loc": "-999.99,-999.99" 52 | }, 53 | "user": { 54 | "uid": "some_uid", 55 | "yob": 1981, 56 | "gender": "F", 57 | "zip": "02116", 58 | "country": "USA", 59 | "keywords": "some_keyword1,some_keyword2" 60 | }, 61 | "restrictions": { 62 | "bcat": [ 63 | "IAB1" 64 | ], 65 | "badv": [ 66 | "blockeduserdomain.com" 67 | ] 68 | } 69 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v1_0/bid_responses/full_bid_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "some_id", 3 | "bidid": "some_bid_id", 4 | "nbr": 0, 5 | "cur": "USD", 6 | "units": 0, 7 | "seatbid": [ 8 | { 9 | "seat": "some_seat_id", 10 | "group": 0, 11 | "bid": [ 12 | { 13 | "impid": "some_impression_id", 14 | "price": 0.05, 15 | "adid": "some_ad_id", 16 | "nurl": "http://winnoticeurl.com", 17 | "adm": "", 18 | "adomain": "adomain.com", 19 | "iurl": "http://imageurl.com", 20 | "cid": "some_campaign_id", 21 | "crid": "some_creative_id", 22 | "attr": [ 23 | 1 24 | ] 25 | } 26 | ] 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_0/bid_requests/example1_simple_banner.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234534625254", 3 | "at": 2, 4 | "tmax": 120, 5 | "imp": [ 6 | { 7 | "id": "1", 8 | "banner": { 9 | "w": 300, 10 | "h": 250, 11 | "pos": 1, 12 | "battr": [ 13 | 13 14 | ] 15 | } 16 | } 17 | ], 18 | "badv": [ 19 | "company1.com", 20 | "company2.com" 21 | ], 22 | "site": { 23 | "id": "234563", 24 | "name": "Site ABCD", 25 | "domain": "siteabcd.com", 26 | "cat": [ 27 | "IAB2-1", 28 | "IAB2-2" 29 | ], 30 | "privacypolicy": 1, 31 | "page": "http://siteabcd.com/page.htm", 32 | "ref": "http://referringsite.com/referringpage.htm", 33 | "publisher": { 34 | "id": "pub12345", 35 | "name": "Publisher A" 36 | }, 37 | "content": { 38 | "keywords": "keyword a, keyword b, keyword c" 39 | } 40 | }, 41 | "device": { 42 | "ip": "64.124.253.1", 43 | "ua": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16", 44 | "os": "OS X", 45 | "flashver": "10.1", 46 | "js": 1 47 | }, 48 | "user": { 49 | "id": "45asdf987656789adfad4678rew656789", 50 | "buyeruid": "5df678asd8987656asdf78987654" 51 | } 52 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_0/bid_requests/example3_mobile.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567893", 3 | "at": 2, 4 | "tmax": 120, 5 | "imp": [ 6 | { 7 | "id": "1", 8 | "banner": { 9 | "w": 300, 10 | "h": 50, 11 | "pos": 1, 12 | "battr": [ 13 | 13 14 | ] 15 | } 16 | } 17 | ], 18 | "app": { 19 | "id": "123123", 20 | "name": "App 123", 21 | "domain": "app123.com", 22 | "appcat": [ 23 | "IAB2-1", 24 | "IAB2-2" 25 | ], 26 | "privacypolicy": 1, 27 | "publisher": { 28 | "id": "pub12345", 29 | "name": "Publisher A" 30 | }, 31 | "content": { 32 | "keyword": [ 33 | "keyword1", 34 | "keyword2", 35 | "keyword3" 36 | ] 37 | } 38 | }, 39 | "device": { 40 | "ip": "192.168.1.8", 41 | "make": "Apple", 42 | "model": "iPhone 3GS", 43 | "os": "iOS", 44 | "osv": "4.2.1", 45 | "connectiontype": 2, 46 | "geo": { 47 | "country": "USA", 48 | "city": "US SFO" 49 | } 50 | }, 51 | "user": { 52 | "id": "456789876567897654678987656789", 53 | "buyeruid": "545678765467876567898765678987654", 54 | "data": [ 55 | { 56 | "id": "6", 57 | "name": "Data Provider 1", 58 | "segment": [ 59 | { 60 | "id": "12341318394918", 61 | "name": "auto intenders" 62 | }, 63 | { 64 | "id": "1234131839491234", 65 | "name": "auto enthusiasts" 66 | } 67 | ] 68 | } 69 | ] 70 | } 71 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_0/bid_requests/fixed/example3_mobile.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567893", 3 | "at": 2, 4 | "tmax": 120, 5 | "imp": [ 6 | { 7 | "id": "1", 8 | "banner": { 9 | "w": 300, 10 | "h": 50, 11 | "pos": 1, 12 | "battr": [ 13 | 13 14 | ] 15 | } 16 | } 17 | ], 18 | "app": { 19 | "id": "123123", 20 | "name": "App 123", 21 | "domain": "app123.com", 22 | "cat": [ 23 | "IAB2-1", 24 | "IAB2-2" 25 | ], 26 | "privacypolicy": 1, 27 | "publisher": { 28 | "id": "pub12345", 29 | "name": "Publisher A" 30 | }, 31 | "content": { 32 | "keywords": "keyword1,keyword2,keyword3" 33 | } 34 | }, 35 | "device": { 36 | "ip": "192.168.1.8", 37 | "make": "Apple", 38 | "model": "iPhone 3GS", 39 | "os": "iOS", 40 | "osv": "4.2.1", 41 | "connectiontype": 2, 42 | "geo": { 43 | "country": "USA", 44 | "city": "US SFO" 45 | } 46 | }, 47 | "user": { 48 | "id": "456789876567897654678987656789", 49 | "buyeruid": "545678765467876567898765678987654", 50 | "data": [ 51 | { 52 | "id": "6", 53 | "name": "Data Provider 1", 54 | "segment": [ 55 | { 56 | "id": "12341318394918", 57 | "name": "auto intenders" 58 | }, 59 | { 60 | "id": "1234131839491234", 61 | "name": "auto enthusiasts" 62 | } 63 | ] 64 | } 65 | ] 66 | } 67 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_0/bid_responses/example1_ad_served_on_win_notice.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567890", 3 | "seatbid": [ 4 | { 5 | "bid": [ 6 | { 7 | "id": "1", 8 | "impid": "102", 9 | "price": 9.43, 10 | "adid": "314", 11 | "nurl": "http://adserver.com/winnotice?impid=102", 12 | "adm": "%3C!DOCTYPE%20html%20PUBLIC%20%5C%22-%2F%2FW3C%2F%2FDTD%20XHTML%201.0%20Transitional%2F%2FEN%5C%22%20%5C%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%5C%22%3E%3Chtml%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%20xml%3Alang%3D%5C%22en%5C%22%20lang%3D%5C%22en%5C%22%3E...%3C%2Fhtml%3E", 13 | "adomain": [ 14 | "advertiserdomain.com" 15 | ], 16 | "iurl": "http://adserver.com/pathtosampleimage", 17 | "cid": "campaign111", 18 | "crid": "creative112", 19 | "attr": [ 20 | 1, 21 | 2, 22 | 3, 23 | 4, 24 | 5, 25 | 6, 26 | 7, 27 | 12 28 | ] 29 | } 30 | ], 31 | "seat": "512" 32 | } 33 | ], 34 | "bidid": "abc1123", 35 | "cur": "USD" 36 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_0/bid_responses/example2_vast_url_returned.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567890", 3 | "seatbid": [ 4 | { 5 | "bid": [ 6 | { 7 | "id": "kljaf9", 8 | "impid": "1", 9 | "price": 9.43, 10 | "nurl": "http://adserver.com/WinNoticeUrlThatReturnsVAST" 11 | } 12 | ] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_0/bid_responses/example3_vast_xml_document_returned_inline.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567890", 3 | "seatbid": [ 4 | { 5 | "bid": [ 6 | { 7 | "id": "1", 8 | "price": 9.43, 9 | "nurl": "http://adserver.com/winnoticeurl", 10 | "adm": "%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%20%3F%3E%3CVAST%20version%3D%222.0%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xsi%3AnoNamespaceSchemaLocation%3D%22vast.xsd%22%3E%3CAd%3E%3CInLine%3E%3CAdSystem%20version%3D%222.0%22%3EAd%20Server%3C%2FAdSystem%3E%3CAdTitle%3EIn-Stream%20Video%3C%2FAdTitle%3E%3CDescription%3EA%20test%20creative%20with%20a%20description.%3C%2FDescription%3E%3CImpression%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fimp%5D%5D%3E%3C%2FImpression%3E%3CCreatives%3E%3CCreative%20sequence%3D%221%22%20AdID%3D%22%22%3E%3CLinear%3E%3CDuration%3E00%3A00%3A58%3C%2FDuration%3E%3CVideoClicks%3E%3CClickThrough%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fclick%5D%5D%3E%3C%2FClickThrough%3E%3C%2FVideoClicks%3E%3CMediaFiles%3E%3CMediaFile%20id%3D%221%22%20delivery%3D%22progressive%22%20type%3D%22video%2Fx-flv%22%20bitrate%3D%22457%22%20width%3D%22300%22%20height%3D%22225%22%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fvideo.flv%5D%5D%3E%3C%2FMediaFile%3E%3C%2FMediaFiles%3E%3C%2FLinear%3E%3C%2FCreative%3E%3C%2FCreatives%3E%3C%2FInLine%3E%3C%2FAd%3E%3C%2FVAST%3E%0A" 11 | } 12 | ] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_0/bid_responses/fixed/example3_vast_xml_document_returned_inline.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567890", 3 | "seatbid": [ 4 | { 5 | "bid": [ 6 | { 7 | "id": "1", 8 | "impid": "q", 9 | "price": 9.43, 10 | "nurl": "http://adserver.com/winnoticeurl", 11 | "adm": "%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%20%3F%3E%3CVAST%20version%3D%222.0%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xsi%3AnoNamespaceSchemaLocation%3D%22vast.xsd%22%3E%3CAd%3E%3CInLine%3E%3CAdSystem%20version%3D%222.0%22%3EAd%20Server%3C%2FAdSystem%3E%3CAdTitle%3EIn-Stream%20Video%3C%2FAdTitle%3E%3CDescription%3EA%20test%20creative%20with%20a%20description.%3C%2FDescription%3E%3CImpression%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fimp%5D%5D%3E%3C%2FImpression%3E%3CCreatives%3E%3CCreative%20sequence%3D%221%22%20AdID%3D%22%22%3E%3CLinear%3E%3CDuration%3E00%3A00%3A58%3C%2FDuration%3E%3CVideoClicks%3E%3CClickThrough%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fclick%5D%5D%3E%3C%2FClickThrough%3E%3C%2FVideoClicks%3E%3CMediaFiles%3E%3CMediaFile%20id%3D%221%22%20delivery%3D%22progressive%22%20type%3D%22video%2Fx-flv%22%20bitrate%3D%22457%22%20width%3D%22300%22%20height%3D%22225%22%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fvideo.flv%5D%5D%3E%3C%2FMediaFile%3E%3C%2FMediaFiles%3E%3C%2FLinear%3E%3C%2FCreative%3E%3C%2FCreatives%3E%3C%2FInLine%3E%3C%2FAd%3E%3C%2FVAST%3E%0A" 12 | } 13 | ] 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_1/bid_requests/example1_simple_banner.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234534625254", 3 | "at": 2, 4 | "tmax": 120, 5 | "imp": [ 6 | { 7 | "id": "1", 8 | "banner": { 9 | "w": 300, 10 | "h": 250, 11 | "pos": 1, 12 | "battr": [ 13 | 13 14 | ] 15 | } 16 | } 17 | ], 18 | "badv": [ 19 | "company1.com", 20 | "company2.com" 21 | ], 22 | "site": { 23 | "id": "234563", 24 | "name": "Site ABCD", 25 | "domain": "siteabcd.com", 26 | "cat": [ 27 | "IAB2-1", 28 | "IAB2-2" 29 | ], 30 | "privacypolicy": 1, 31 | "page": "http://siteabcd.com/page.htm", 32 | "ref": "http://referringsite.com/referringpage.htm", 33 | "publisher": { 34 | "id": "pub12345", 35 | "name": "Publisher A" 36 | }, 37 | "content": { 38 | "keywords": [ 39 | "keyword a", 40 | "keyword b", 41 | "keyword c" 42 | ] 43 | } 44 | }, 45 | "device": { 46 | "ip": "64.124.253.1", 47 | "ua": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.16) Gecko/20110319Firefox/3.6.16", 48 | "os": "OS X", 49 | "flashver": "10.1", 50 | "js": 1 51 | }, 52 | "user": { 53 | "id": "45asdf987656789adfad4678rew656789", 54 | "buyeruid": "5df678asd8987656asdf78987654" 55 | } 56 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_1/bid_requests/example3_mobile.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567893", 3 | "at": 2, 4 | "tmax": 120, 5 | "imp": [ 6 | { 7 | "id": "1", 8 | "banner": { 9 | "w": 300, 10 | "h": 50, 11 | "pos": 1, 12 | "battr": [ 13 | 13 14 | ] 15 | } 16 | } 17 | ], 18 | "app": { 19 | "id": "123123", 20 | "name": "App 123", 21 | "domain": "app123.com", 22 | "appcat": [ 23 | "IAB2-1", 24 | "IAB2-2" 25 | ], 26 | "privacypolicy": 1, 27 | "publisher": { 28 | "id": "pub12345", 29 | "name": "Publisher A" 30 | }, 31 | "content": { 32 | "keyword": [ 33 | "keyword1", 34 | "keyword2", 35 | "keyword3" 36 | ] 37 | } 38 | }, 39 | "device": { 40 | "ip": "192.168.1.8", 41 | "make": "Apple", 42 | "model": "iPhone 3GS", 43 | "os": "iOS", 44 | "osv": "4.2.1", 45 | "connectiontype": 2, 46 | "geo": { 47 | "country": "USA", 48 | "city": "US SFO" 49 | } 50 | }, 51 | "user": { 52 | "id": "456789876567897654678987656789", 53 | "buyeruid": "545678765467876567898765678987654", 54 | "data": [ 55 | { 56 | "id": "6", 57 | "name": "Data Provider 1", 58 | "segment": [ 59 | { 60 | "id": "12341318394918", 61 | "name": "auto intenders" 62 | }, 63 | { 64 | "id": "1234131839491234", 65 | "name": "auto enthusiasts" 66 | } 67 | ] 68 | } 69 | ] 70 | } 71 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_1/bid_requests/fixed/example1_simple_banner.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234534625254", 3 | "at": 2, 4 | "tmax": 120, 5 | "imp": [ 6 | { 7 | "id": "1", 8 | "banner": { 9 | "w": 300, 10 | "h": 250, 11 | "pos": 1, 12 | "battr": [ 13 | 13 14 | ] 15 | } 16 | } 17 | ], 18 | "badv": [ 19 | "company1.com", 20 | "company2.com" 21 | ], 22 | "site": { 23 | "id": "234563", 24 | "name": "Site ABCD", 25 | "domain": "siteabcd.com", 26 | "cat": [ 27 | "IAB2-1", 28 | "IAB2-2" 29 | ], 30 | "privacypolicy": 1, 31 | "page": "http://siteabcd.com/page.htm", 32 | "ref": "http://referringsite.com/referringpage.htm", 33 | "publisher": { 34 | "id": "pub12345", 35 | "name": "Publisher A" 36 | }, 37 | "content": { 38 | "keywords": "keyword a,keyword b,keyword c" 39 | } 40 | }, 41 | "device": { 42 | "ip": "64.124.253.1", 43 | "ua": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.16) Gecko/20110319Firefox/3.6.16", 44 | "os": "OS X", 45 | "flashver": "10.1", 46 | "js": 1 47 | }, 48 | "user": { 49 | "id": "45asdf987656789adfad4678rew656789", 50 | "buyeruid": "5df678asd8987656asdf78987654" 51 | } 52 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_1/bid_requests/fixed/example3_mobile.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567893", 3 | "at": 2, 4 | "tmax": 120, 5 | "imp": [ 6 | { 7 | "id": "1", 8 | "banner": { 9 | "w": 300, 10 | "h": 50, 11 | "pos": 1, 12 | "battr": [ 13 | 13 14 | ] 15 | } 16 | } 17 | ], 18 | "app": { 19 | "id": "123123", 20 | "name": "App 123", 21 | "domain": "app123.com", 22 | "cat": [ 23 | "IAB2-1", 24 | "IAB2-2" 25 | ], 26 | "privacypolicy": 1, 27 | "publisher": { 28 | "id": "pub12345", 29 | "name": "Publisher A" 30 | }, 31 | "content": { 32 | "keywords": "keyword1,keyword2,keyword3" 33 | } 34 | }, 35 | "device": { 36 | "ip": "192.168.1.8", 37 | "make": "Apple", 38 | "model": "iPhone 3GS", 39 | "os": "iOS", 40 | "osv": "4.2.1", 41 | "connectiontype": 2, 42 | "geo": { 43 | "country": "USA", 44 | "city": "US SFO" 45 | } 46 | }, 47 | "user": { 48 | "id": "456789876567897654678987656789", 49 | "buyeruid": "545678765467876567898765678987654", 50 | "data": [ 51 | { 52 | "id": "6", 53 | "name": "Data Provider 1", 54 | "segment": [ 55 | { 56 | "id": "12341318394918", 57 | "name": "auto intenders" 58 | }, 59 | { 60 | "id": "1234131839491234", 61 | "name": "auto enthusiasts" 62 | } 63 | ] 64 | } 65 | ] 66 | } 67 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_1/bid_responses/example1_ad_served_on_win_notice.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567890", 3 | "seatbid": [ 4 | { 5 | "bid": [ 6 | { 7 | "id": "1", 8 | "impid": "102", 9 | "price": 9.43, 10 | "adid": "314", 11 | "nurl": "http://adserver.com/winnotice?impid=102", 12 | "adm": "%3C!DOCTYPE%20html%20PUBLIC%20%5C%22-%2F%2FW3C%2F%2FDTD%20XHTML%201.0%20Transitional%2F%2FEN%5C%22%20%5C%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%5C%22%3E%3Chtml%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%20xml%3Alang%3D%5C%22en%5C%22%20lang%3D%5C%22en%5C%22%3E...%3C%2Fhtml%3E", 13 | "adomain": [ 14 | "advertiserdomain.com" 15 | ], 16 | "iurl": "http://adserver.com/pathtosampleimage", 17 | "cid": "campaign111", 18 | "crid": "creative112", 19 | "attr": [ 20 | 1, 21 | 2, 22 | 3, 23 | 4, 24 | 5, 25 | 6, 26 | 7, 27 | 12 28 | ] 29 | } 30 | ], 31 | "seat": "512" 32 | } 33 | ], 34 | "bidid": "abc1123", 35 | "cur": "USD" 36 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_1/bid_responses/example2_vast_url_returned.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567890", 3 | "seatbid": [ 4 | { 5 | "bid": [ 6 | { 7 | "id": "kljaf9", 8 | "impid": "1", 9 | "price": 9.43, 10 | "nurl": "http://adserver.com/WinNoticeUrlThatReturnsVAST" 11 | } 12 | ] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_1/bid_responses/example3_vast_xml_document_returned_inline.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567890", 3 | "seatbid": [ 4 | { 5 | "bid": [ 6 | { 7 | "id": "1", 8 | "price": 9.43, 9 | "nurl": "http://adserver.com/winnoticeurl", 10 | "adm": "%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%20%3F%3E%3CVAST%20version%3D%222.0%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xsi%3AnoNamespaceSchemaLocation%3D%22vast.xsd%22%3E%3CAd%3E%3CInLine%3E%3CAdSystem%20version%3D%222.0%22%3EAd%20Server%3C%2FAdSystem%3E%3CAdTitle%3EIn-Stream%20Video%3C%2FAdTitle%3E%3CDescription%3EA%20test%20creative%20with%20a%20description.%3C%2FDescription%3E%3CImpression%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fimp%5D%5D%3E%3C%2FImpression%3E%3CCreatives%3E%3CCreative%20sequence%3D%221%22%20AdID%3D%22%22%3E%3CLinear%3E%3CDuration%3E00%3A00%3A58%3C%2FDuration%3E%3CVideoClicks%3E%3CClickThrough%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fclick%5D%5D%3E%3C%2FClickThrough%3E%3C%2FVideoClicks%3E%3CMediaFiles%3E%3CMediaFile%20id%3D%221%22%20delivery%3D%22progressive%22%20type%3D%22video%2Fx-flv%22%20bitrate%3D%22457%22%20width%3D%22300%22%20height%3D%22225%22%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fvideo.flv%5D%5D%3E%3C%2FMediaFile%3E%3C%2FMediaFiles%3E%3C%2FLinear%3E%3C%2FCreative%3E%3C%2FCreatives%3E%3C%2FInLine%3E%3C%2FAd%3E%3C%2FVAST%3E%0A" 11 | } 12 | ] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_1/bid_responses/fixed/example3_vast_xml_document_returned_inline.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567890", 3 | "seatbid": [ 4 | { 5 | "bid": [ 6 | { 7 | "id": "1", 8 | "impid": "q", 9 | "price": 9.43, 10 | "nurl": "http://adserver.com/winnoticeurl", 11 | "adm": "%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%20%3F%3E%3CVAST%20version%3D%222.0%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xsi%3AnoNamespaceSchemaLocation%3D%22vast.xsd%22%3E%3CAd%3E%3CInLine%3E%3CAdSystem%20version%3D%222.0%22%3EAd%20Server%3C%2FAdSystem%3E%3CAdTitle%3EIn-Stream%20Video%3C%2FAdTitle%3E%3CDescription%3EA%20test%20creative%20with%20a%20description.%3C%2FDescription%3E%3CImpression%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fimp%5D%5D%3E%3C%2FImpression%3E%3CCreatives%3E%3CCreative%20sequence%3D%221%22%20AdID%3D%22%22%3E%3CLinear%3E%3CDuration%3E00%3A00%3A58%3C%2FDuration%3E%3CVideoClicks%3E%3CClickThrough%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fclick%5D%5D%3E%3C%2FClickThrough%3E%3C%2FVideoClicks%3E%3CMediaFiles%3E%3CMediaFile%20id%3D%221%22%20delivery%3D%22progressive%22%20type%3D%22video%2Fx-flv%22%20bitrate%3D%22457%22%20width%3D%22300%22%20height%3D%22225%22%3E%3C!%5BCDATA%5Bhttp%3A%2F%2Fadserver.com%2Fvideo.flv%5D%5D%3E%3C%2FMediaFile%3E%3C%2FMediaFiles%3E%3C%2FLinear%3E%3C%2FCreative%3E%3C%2FCreatives%3E%3C%2FInLine%3E%3C%2FAd%3E%3C%2FVAST%3E%0A" 12 | } 13 | ] 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_2/bid_requests/example1_simple_banner.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"80ce30c53c16e6ede735f123ef6e32361bfc7b22", 3 | "imp":[ 4 | { 5 | "id":"1", 6 | "banner":{ 7 | "h":250, 8 | "w":300, 9 | "pos":0 10 | }, 11 | "bidfloor":0.03 12 | } 13 | ], 14 | "site":{ 15 | "id":"102855", 16 | "domain":"http://www.foobar.com", 17 | "cat":"IAB3-1", 18 | "page":"http://www.foobar.com/1234.html", 19 | "publisher":{ 20 | "id":"8953", 21 | "name":"foobar.com", 22 | "cat":"IAB3-1", 23 | "domain":"foobar.com" 24 | } 25 | }, 26 | "device":{ 27 | "ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 28 | "ip":"123.145.167.*" 29 | }, 30 | "user":{ 31 | "id":"55816b39711f9b5acf3b90e313ed29e51665623f" 32 | }, 33 | "at":1, 34 | "cur":[ 35 | "USD" 36 | ] 37 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_2/bid_requests/example5_pmp_with_direct_deal.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"80ce30c53c16e6ede735f123ef6e32361bfc7b22", 3 | "imp":[ 4 | { 5 | "id":"1", 6 | "banner":{ 7 | "h":250, 8 | "w":300, 9 | "pos":0 10 | }, 11 | "bidfloor":0.03, 12 | "pmp":{ 13 | "private_auction":1, 14 | "deals":[ 15 | { 16 | "id":"AB-Agency1-0001", 17 | "bidfloor":2.5, 18 | "wseat":[ 19 | "Agency1" 20 | ], 21 | "at":1, 22 | "ext":{ 23 | } 24 | }, 25 | { 26 | "id":"XY-Agency2-0001", 27 | "bidfloor":2, 28 | "wseat":[ 29 | "Agency2" 30 | ], 31 | "at":2 32 | } 33 | ] 34 | } 35 | } 36 | ], 37 | "site":{ 38 | "id":"102855", 39 | "domain":"http://www.foobar.com", 40 | "cat":"IAB3-1", 41 | "page":"http://www.foobar.com/1234.html", 42 | "publisher":{ 43 | "id":"8953", 44 | "name":"foobar.com", 45 | "cat":"IAB3-1", 46 | "domain":"foobar.com" 47 | } 48 | }, 49 | "device":{ 50 | "ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 51 | "ip":"123.145.167.*" 52 | }, 53 | "user":{ 54 | "id":"55816b39711f9b5acf3b90e313ed29e51665623f" 55 | }, 56 | "at":1, 57 | "cur":[ 58 | "USD" 59 | ] 60 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_2/bid_requests/fixed/example1_simple_banner.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"80ce30c53c16e6ede735f123ef6e32361bfc7b22", 3 | "imp":[ 4 | { 5 | "id":"1", 6 | "banner":{ 7 | "h":250, 8 | "w":300, 9 | "pos":0 10 | }, 11 | "bidfloor":0.03 12 | } 13 | ], 14 | "site":{ 15 | "id":"102855", 16 | "domain":"http://www.foobar.com", 17 | "cat":["IAB3-1"], 18 | "page":"http://www.foobar.com/1234.html", 19 | "publisher":{ 20 | "id":"8953", 21 | "name":"foobar.com", 22 | "cat":["IAB3-1"], 23 | "domain":"foobar.com" 24 | } 25 | }, 26 | "device":{ 27 | "ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 28 | "ip":"123.145.167.0" 29 | }, 30 | "user":{ 31 | "id":"55816b39711f9b5acf3b90e313ed29e51665623f" 32 | }, 33 | "at":1, 34 | "cur":[ 35 | "USD" 36 | ] 37 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_2/bid_requests/fixed/example5_pmp_with_direct_deal.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"80ce30c53c16e6ede735f123ef6e32361bfc7b22", 3 | "imp":[ 4 | { 5 | "id":"1", 6 | "banner":{ 7 | "h":250, 8 | "w":300, 9 | "pos":0 10 | }, 11 | "bidfloor":0.03, 12 | "pmp":{ 13 | "private_auction":1, 14 | "deals":[ 15 | { 16 | "id":"AB-Agency1-0001", 17 | "bidfloor":2.5, 18 | "wseat":[ 19 | "Agency1" 20 | ], 21 | "at":1, 22 | "ext":{ 23 | } 24 | }, 25 | { 26 | "id":"XY-Agency2-0001", 27 | "bidfloor":2, 28 | "wseat":[ 29 | "Agency2" 30 | ], 31 | "at":2 32 | } 33 | ] 34 | } 35 | } 36 | ], 37 | "site":{ 38 | "id":"102855", 39 | "domain":"http://www.foobar.com", 40 | "cat":["IAB3-1"], 41 | "page":"http://www.foobar.com/1234.html", 42 | "publisher":{ 43 | "id":"8953", 44 | "name":"foobar.com", 45 | "cat":["IAB3-1"], 46 | "domain":"foobar.com" 47 | } 48 | }, 49 | "device":{ 50 | "ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 51 | "ip":"123.145.167.0" 52 | }, 53 | "user":{ 54 | "id":"55816b39711f9b5acf3b90e313ed29e51665623f" 55 | }, 56 | "at":1, 57 | "cur":[ 58 | "USD" 59 | ] 60 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_2/bid_responses/example1_ad_served_on_win_notice.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"1234567890", 3 | "seatbid":[ 4 | { 5 | "bid":[ 6 | { 7 | "id":"1", 8 | "impid":"102", 9 | "price":9.43, 10 | "adid":"314", 11 | "nurl":"http://adserver.com/winnotice?impid=102", 12 | "adm":"%3C!DOCTYPE%20html%20PUBLIC%20%5C%22-%2F%2FW3C%2F%2FDTD%20XHTML%201.0%20Transitional%2F%2FEN%5C%22%20%5C%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%5C%22%3E%3Chtml%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%20xml%3Alang%3D%5C%22en%5C%22%20lang%3D%5C%22en%5C%22%3E...%3C%2Fhtml%3E", 13 | "adomain":[ 14 | "advertiserdomain.com" 15 | ], 16 | "iurl":"http://adserver.com/pathtosampleimage", 17 | "cid":"campaign111", 18 | "crid":"creative112", 19 | "attr":[ 20 | 1, 21 | 2, 22 | 3, 23 | 4, 24 | 5, 25 | 6, 26 | 7, 27 | 12 28 | ] 29 | } 30 | ], 31 | "seat":"512" 32 | } 33 | ], 34 | "bidid":"abc1123", 35 | "cur":"USD" 36 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_2/bid_responses/example2_vast_url_returned.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"1234567890", 3 | "seatbid":[ 4 | { 5 | "bid":[ 6 | { 7 | "id":"kljaf9", 8 | "impid":"1", 9 | "price":9.43, 10 | "nurl":"http://adserver.com/WinNoticeUrlThatReturnsVAST" 11 | } 12 | ] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_2/bid_responses/example4_direct_deal_ad_served_on_win_notice.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"1234567890", 3 | "seatbid":[ 4 | { 5 | "bid":[ 6 | { 7 | "id":"1", 8 | "impid":"102", 9 | "price":5.00, 10 | "dealid":"ABC-1234-6789", 11 | "adid":"314", 12 | "nurl":"http://adserver.com/winnotice?impid=102", 13 | "adm":"%3C!DOCTYPE%20html%20PUBLIC%20%5C%22-%2F%2FW3C%2F%2FDTD%20XHTML%201.0%20Transitional%2F%2FEN%5C%22%20%5C%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%5C%22%3E%3Chtml%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%5C%22%20xml%3Alang%3D%5C%22en%5C%22%20lang%3D%5C%22en%5C%22%3E...%3C%2Fhtml%3E", 14 | "adomain":[ 15 | "advertiserdomain.com" 16 | ], 17 | "iurl":"http://adserver.com/pathtosampleimage", 18 | "cid":"campaign111", 19 | "crid":"creative112", 20 | "attr":[ 21 | 1, 22 | 2, 23 | 3, 24 | 4 25 | ] 26 | } 27 | ], 28 | "seat":"512" 29 | } 30 | ], 31 | "bidid":"abc1123", 32 | "cur":"USD" 33 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_3/bid_requests/example1_simple_banner.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"80ce30c53c16e6ede735f123ef6e32361bfc7b22", 3 | "at":1, 4 | "cur":[ 5 | "USD" 6 | ], 7 | "imp":[ 8 | { 9 | "id":"1", 10 | "bidfloor":0.03, 11 | "banner":{ 12 | "h":250, 13 | "w":300, 14 | "pos":0 15 | } 16 | } 17 | ], 18 | "site":{ 19 | "id":"102855", 20 | "cat":[ 21 | "IAB3-1" 22 | ], 23 | "domain":"www.foobar.com", 24 | "page":"http://www.foobar.com/1234.html ", 25 | "publisher":{ 26 | "id":"8953", 27 | "name":"foobar.com", 28 | "cat":[ 29 | "IAB3-1" 30 | ], 31 | "domain":"foobar.com" 32 | } 33 | }, 34 | "device":{ 35 | "ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 36 | "ip":"123.145.167.10" 37 | }, 38 | "user":{ 39 | "id":"55816b39711f9b5acf3b90e313ed29e51665623f" 40 | } 41 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_3/bid_requests/example5_pmp_with_direct_deal.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"80ce30c53c16e6ede735f123ef6e32361bfc7b22", 3 | "at":1, 4 | "cur":[ 5 | "USD" 6 | ], 7 | "imp":[ 8 | { 9 | "id":"1", 10 | "bidfloor":0.03, 11 | "banner":{ 12 | "h":250, 13 | "w":300, 14 | "pos":0 15 | }, 16 | "pmp":{ 17 | "private_auction":1, 18 | "deals":[ 19 | { 20 | "id":"AB-Agency1-0001", 21 | "at":1, 22 | "bidfloor":2.5, 23 | "wseat":[ 24 | "Agency1" 25 | ] 26 | }, 27 | { 28 | "id":"XY-Agency2-0001", 29 | "at":2, 30 | "bidfloor":2, 31 | "wseat":[ 32 | "Agency2" 33 | ] 34 | } 35 | ] 36 | } 37 | } 38 | ], 39 | "site":{ 40 | "id":"102855", 41 | "domain":"www.foobar.com", 42 | "cat":[ 43 | "IAB3-1" 44 | ], 45 | "page":"http://www.foobar.com/1234.html", 46 | "publisher":{ 47 | "id":"8953", 48 | "name":"foobar.com", 49 | "cat":[ 50 | "IAB3-1" 51 | ], 52 | "domain":"foobar.com" 53 | } 54 | }, 55 | "device":{ 56 | "ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 57 | "ip":"123.145.167.10" 58 | }, 59 | "user":{ 60 | "id":"55816b39711f9b5acf3b90e313ed29e51665623f" 61 | } 62 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_3/bid_requests/example6_native_ad.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"80ce30c53c16e6ede735f123ef6e32361bfc7b22", 3 | "at":1, 4 | "cur":[ 5 | "USD" 6 | ], 7 | "imp":[ 8 | { 9 | "id":"1", 10 | "bidfloor":0.03, 11 | "native":{ 12 | "request":"...Native Spec request as an encoded string...", 13 | "ver":"1.0", 14 | "api":[ 15 | 3 16 | ], 17 | "battr":[ 18 | 13, 19 | 14 20 | ] 21 | } 22 | } 23 | ], 24 | "site":{ 25 | "id":"102855", 26 | "cat":[ 27 | "IAB3-1" 28 | ], 29 | "domain":"www.foobar.com", 30 | "page":"http://www.foobar.com/1234.html ", 31 | "publisher":{ 32 | "id":"8953", 33 | "name":"foobar.com", 34 | "cat":[ 35 | "IAB3-1" 36 | ], 37 | "domain":"foobar.com" 38 | } 39 | }, 40 | "device":{ 41 | "ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 42 | "ip":"123.145.167.10" 43 | }, 44 | "user":{ 45 | "id":"55816b39711f9b5acf3b90e313ed29e51665623f" 46 | } 47 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_3/bid_responses/example1_ad_served_on_win_notice.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"1234567890", 3 | "bidid":"abc1123", 4 | "cur":"USD", 5 | "seatbid":[ 6 | { 7 | "seat":"512", 8 | "bid":[ 9 | { 10 | "id":"1", 11 | "impid":"102", 12 | "price":9.43, 13 | "nurl":"http://adserver.com/winnotice?impid=102", 14 | "iurl":"http://adserver.com/pathtosampleimage", 15 | "adomain":[ 16 | "advertiserdomain.com" 17 | ], 18 | "cid":"campaign111", 19 | "crid":"creative112", 20 | "attr":[ 21 | 1, 22 | 2, 23 | 3, 24 | 4, 25 | 5, 26 | 6, 27 | 7, 28 | 12 29 | ] 30 | } 31 | ] 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_3/bid_responses/example3_direct_deal_ad_served_on_win_notice.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"1234567890", 3 | "bidid":"abc1123", 4 | "cur":"USD", 5 | "seatbid":[ 6 | { 7 | "seat":"512", 8 | "bid":[ 9 | { 10 | "id":"1", 11 | "impid":"102", 12 | "price":5.00, 13 | "dealid":"ABC-1234-6789", 14 | "nurl":"http: //adserver.com/winnotice?impid=102", 15 | "adomain":[ 16 | "advertiserdomain.com" 17 | ], 18 | "iurl":"http: //adserver.com/pathtosampleimage", 19 | "cid":"campaign111", 20 | "crid":"creative112", 21 | "adid":"314", 22 | "attr":[ 23 | 1, 24 | 2, 25 | 3, 26 | 4 27 | ] 28 | } 29 | ] 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_3/bid_responses/example4_native_markup_returned_inline.json: -------------------------------------------------------------------------------- 1 | { 2 | "id":"123", 3 | "seatbid":[ 4 | { 5 | "bid":[ 6 | { 7 | "id":"12345", 8 | "impid":"2", 9 | "price":3.00, 10 | "nurl":"http://example.com/winnoticeurl", 11 | "adm":"...Native Spec response as an encoded string..." 12 | } 13 | ] 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_4/bid_requests/example1_simple_banner.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "80ce30c53c16e6ede735f123ef6e32361bfc7b22", 3 | "at": 1, 4 | "cur": [ "USD" ], 5 | "imp": [ 6 | { 7 | "id": "1", 8 | "bidfloor": 0.03, 9 | "banner": { 10 | "h": 250, 11 | "w": 300, 12 | "pos": 0 13 | } 14 | } 15 | ], 16 | "site": { 17 | "id": "102855", 18 | "cat": [ "IAB3-1" ], 19 | "domain": "www.foobar.com", 20 | "page": "http://www.foobar.com/1234.html ", 21 | "publisher": { 22 | "id": "8953", 23 | "name": "foobar.com", 24 | "cat": [ "IAB3-1" ], 25 | "domain": "foobar.com" 26 | } 27 | }, 28 | "device": { 29 | "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.1(KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 30 | "ip": "123.145.167.10" 31 | }, 32 | "user": { 33 | "id": "55816b39711f9b5acf3b90e313ed29e51665623f" 34 | } 35 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_4/bid_requests/example2_expandable_creative.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "123456789316e6ede735f123ef6e32361bfc7b22", 3 | "at": 2, 4 | "cur": [ "USD" ], 5 | "imp": [ 6 | { 7 | "id": "1", 8 | "bidfloor": 0.03, 9 | "iframebuster": [ "vendor1.com", "vendor2.com" ], 10 | "banner": { 11 | "h": 250, 12 | "w": 300, 13 | "pos": 0, 14 | "battr": [ 13 ], 15 | "expdir": [ 2, 4 ] 16 | } 17 | } 18 | ], 19 | "site": { 20 | "id": "102855", 21 | "cat": [ "IAB3-1" ], 22 | "domain": "www.foobar.com", 23 | "page": "http://www.foobar.com/1234.html", 24 | "publisher": { 25 | "id": "8953", 26 | "name": "foobar.com", 27 | "cat": [ "IAB3-1" ], 28 | "domain": "foobar.com" 29 | } 30 | }, 31 | "device": { 32 | "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13(KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 33 | "ip": "123.145.167.10" 34 | }, 35 | "user": { 36 | "id": "55816b39711f9b5acf3b90e313ed29e51665623f", 37 | "buyeruid": "545678765467876567898765678987654", 38 | "data": [ 39 | { 40 | "id": "6", 41 | "name": "Data Provider 1", 42 | "segment": [ 43 | { 44 | "id": "12341318394918", 45 | "name": "auto intenders" 46 | }, 47 | { 48 | "id": "1234131839491234", 49 | "name": "auto enthusiasts" 50 | }, 51 | { 52 | "id": "23423424", 53 | "name": "data-provider1-age", 54 | "value": "30-40" 55 | } 56 | ] 57 | } 58 | ] 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_4/bid_requests/example3_mobile.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "IxexyLDIIk", 3 | "at": 2, 4 | "bcat": [ "IAB25", "IAB7-39", "IAB8-18", "IAB8-5", "IAB9-9" ], 5 | "badv": [ "apple.com", "go-text.me", "heywire.com" ], 6 | "imp": [ 7 | { 8 | "id": "1", 9 | "bidfloor": 0.5, 10 | "instl": 0, 11 | "tagid": "agltb3B1Yi1pbmNyDQsSBFNpdGUY7fD0FAw", 12 | "banner": { 13 | "w": 728, 14 | "h": 90, 15 | "pos": 1, 16 | "btype": [ 4 ], 17 | "battr": [ 14 ], 18 | "api": [ 3 ] 19 | } 20 | } 21 | ], 22 | "app": { 23 | "id": "agltb3B1Yi1pbmNyDAsSA0FwcBiJkfIUDA", 24 | "name": "Yahoo Weather", 25 | "cat": [ "IAB15", "IAB15-10" ], 26 | "ver": "1.0.2", 27 | "bundle": "com.yahoo.wxapp", 28 | "storeurl": "https://itunes.apple.com/id628677149", 29 | "publisher": { 30 | "id": "agltb3B1Yi1pbmNyDAsSA0FwcBiJkfTUCV", 31 | "name": "yahoo", 32 | "domain": "www.yahoo.com" 33 | } 34 | }, 35 | "device": { 36 | "dnt": 0, 37 | "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X)AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3", 38 | "ip": "123.145.167.189", 39 | "ifa": "AA000DFE74168477C70D291f574D344790E0BB11", 40 | "carrier": "VERIZON", 41 | "language": "en", 42 | "make": "Apple", 43 | "model": "iPhone", 44 | "os": "iOS", 45 | "osv": "6.1", 46 | "js": 1, 47 | "connectiontype": 3, 48 | "devicetype": 1, 49 | "geo": { 50 | "lat": 35.012345, 51 | "lon": -115.12345, 52 | "country": "USA", 53 | "metro": "803", 54 | "region": "CA", 55 | "city": "Los Angeles", 56 | "zip": "90049" 57 | } 58 | }, 59 | "user": { 60 | "id": "ffffffd5135596709273b3a1a07e466ea2bf4fff", 61 | "yob": 1984, 62 | "gender": "M" 63 | } 64 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_4/bid_requests/example5_pmp_with_direct_deal.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "80ce30c53c16e6ede735f123ef6e32361bfc7b22", 3 | "at": 1, "cur": [ "USD" ], 4 | "imp": [ 5 | { 6 | "id": "1", 7 | "bidfloor": 0.03, 8 | "banner": { 9 | "h": 250, 10 | "w": 300, 11 | "pos": 0 12 | }, 13 | "pmp": { 14 | "private_auction": 1, 15 | "deals": [ 16 | { 17 | "id":"AB-Agency1-0001", 18 | "at": 1, 19 | "bidfloor": 2.5, 20 | "wseat": [ "Agency1" ] 21 | }, 22 | { 23 | "id":"XY-Agency2-0001", 24 | "at": 2, 25 | "bidfloor": 2, 26 | "wseat": [ "Agency2" ] 27 | } 28 | ] 29 | } 30 | } 31 | ], 32 | "site": { 33 | "id": "102855", 34 | "domain": "www.foobar.com", 35 | "cat": [ "IAB3-1" ], 36 | "page": "http://www.foobar.com/1234.html", 37 | "publisher": { 38 | "id": "8953", 39 | "name": "foobar.com", 40 | "cat": [ "IAB3-1" ], 41 | "domain": "foobar.com" 42 | } 43 | }, 44 | "device": { 45 | "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13(KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 46 | "ip": "123.145.167.10" 47 | }, 48 | "user": { 49 | "id": "55816b39711f9b5acf3b90e313ed29e51665623f" 50 | } 51 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_4/bid_requests/example6_native_ad.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "80ce30c53c16e6ede735f123ef6e32361bfc7b22", 3 | "at": 1, 4 | "cur": [ "USD" ], 5 | "imp": [ 6 | { 7 | "id": "1", 8 | "bidfloor": 0.03, 9 | "native": { 10 | "request": "{\"native\":{\"ver\":\"1.0\",\"assets\":[ ... ]}}", 11 | "ver": "1.0", 12 | "api": [ 3 ], 13 | "battr": [ 13, 14 ] 14 | } 15 | } 16 | ], 17 | "site": { 18 | "id": "102855", 19 | "cat": [ "IAB3-1" ], 20 | "domain": "www.foobar.com", 21 | "page": "http://www.foobar.com/1234.html ", 22 | "publisher": { 23 | "id": "8953", 24 | "name": "foobar.com", 25 | "cat": [ "IAB3-1" ], 26 | "domain": "foobar.com" 27 | } 28 | }, 29 | "device": { 30 | "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13(KHTML, like Gecko) Version/5.1.7 Safari/534.57.2", 31 | "ip": "123.145.167.10" 32 | }, 33 | "user": { 34 | "id": "55816b39711f9b5acf3b90e313ed29e51665623f" 35 | } 36 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_4/bid_responses/example1_ad_served_on_win_notice.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567890", "bidid": "abc1123", "cur": "USD", 3 | "seatbid": [ 4 | { 5 | "seat": "512", 6 | "bid": [ 7 | { 8 | "id": "1", "impid": "102", "price": 9.43, 9 | "nurl": "http://adserver.com/winnotice?impid=102", 10 | "iurl": "http://adserver.com/pathtosampleimage", 11 | "adomain": [ "advertiserdomain.com" ], 12 | "cid": "campaign111", 13 | "crid": "creative112", 14 | "attr": [ 1, 2, 3, 4, 5, 6, 7, 12 ] 15 | } 16 | ] 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_4/bid_responses/example3_direct_deal_ad_served_on_win_notice.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1234567890", 3 | "bidid": "abc1123", 4 | "cur": "USD", 5 | "seatbid": [ 6 | { 7 | "seat": "512", 8 | "bid": [ 9 | { 10 | "id": "1", 11 | "impid": "102", 12 | "price": 5.00, 13 | "dealid": "ABC-1234-6789", 14 | "nurl": "http: //adserver.com/winnotice?impid=102", 15 | "adomain": [ "advertiserdomain.com" ], 16 | "iurl": "http: //adserver.com/pathtosampleimage", 17 | "cid": "campaign111", 18 | "crid": "creative112", 19 | "adid": "314", 20 | "attr": [ 1, 2, 3, 4 ] 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb-validator/src/test/resources/v2_4/bid_responses/example4_native_markup_returned_inline.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "123", 3 | "seatbid": [ 4 | { 5 | "bid": [ 6 | { 7 | "id": "12345", 8 | "impid": "2", 9 | "price": 3.00, 10 | "nurl": "http://example.com/winnoticeurl", 11 | "adm": "{\"native\":{\"ver\":\"1.0\",\"link\":{ ... },\"imptrackers\":[ ... ],\"assets\":[ ... ]}}" 12 | } 13 | ] 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.classpath 3 | /.project 4 | /.settings/ 5 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.atg.openssp 5 | open-ssp-parent 6 | 0.3 7 | 8 | open-ssp-openrtb 9 | 10 | 11 | 12 | com.google.code.gson 13 | gson 14 | 2.6.2 15 | 16 | 17 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/bidrequest/exception/BuilderException.java: -------------------------------------------------------------------------------- 1 | package openrtb.bidrequest.exception; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class BuilderException extends Exception { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | public BuilderException(final String message) { 12 | super(message); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/bidrequest/model/Gender.java: -------------------------------------------------------------------------------- 1 | package openrtb.bidrequest.model; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public enum Gender { 8 | 9 | /** 10 | * m 11 | */ 12 | MALE("M"), 13 | 14 | /** 15 | * f 16 | */ 17 | FEMALE("F"), 18 | 19 | /** 20 | * O 21 | */ 22 | OTHER("O"); 23 | 24 | private String value; 25 | 26 | private Gender(final String value) { 27 | this.value = value; 28 | } 29 | 30 | public String getValue() { 31 | return value; 32 | } 33 | 34 | public static Gender convert(final String value) { 35 | for (final Gender gender : values()) { 36 | if (gender.value.equalsIgnoreCase(value)) { 37 | return gender; 38 | } 39 | } 40 | return OTHER; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/bidrequest/model/PMP.java: -------------------------------------------------------------------------------- 1 | package openrtb.bidrequest.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * 8 | * @author André Schmer 9 | * 10 | */ 11 | public class PMP implements Cloneable { 12 | 13 | private int private_auction; 14 | private List deals; 15 | private Object ext; 16 | 17 | public PMP() {} 18 | 19 | public int getPrivate_auction() { 20 | return private_auction; 21 | } 22 | 23 | public void setPrivate_auction(final int private_auction) { 24 | this.private_auction = private_auction; 25 | } 26 | 27 | public List getDeals() { 28 | return deals; 29 | } 30 | 31 | public void setDeals(final List deals) { 32 | this.deals = deals; 33 | } 34 | 35 | public void addDirectDeal(final DirectDeal directDeal) { 36 | if (deals == null) { 37 | deals = new ArrayList<>(); 38 | } 39 | deals.add(directDeal); 40 | } 41 | 42 | public Object getExt() { 43 | return ext; 44 | } 45 | 46 | public void setExt(final Object ext) { 47 | this.ext = ext; 48 | } 49 | 50 | @Override 51 | public PMP clone() { 52 | try { 53 | final PMP clone = (PMP) super.clone(); 54 | if (deals != null) { 55 | final List cloneArray = new ArrayList<>(deals.size()); 56 | deals.forEach(d -> cloneArray.add(d.clone())); 57 | clone.setDeals(cloneArray); 58 | } 59 | return clone; 60 | } catch (final CloneNotSupportedException e) { 61 | throw new AssertionError("clone operation failed. " + getClass()); 62 | } 63 | } 64 | 65 | public static class Builder { 66 | private final PMP pmp; 67 | 68 | public Builder() { 69 | pmp = new PMP(); 70 | } 71 | 72 | public Builder addDirectDeal(final DirectDeal.Builder directDeal) { 73 | pmp.addDirectDeal(directDeal.build()); 74 | return this; 75 | } 76 | 77 | public PMP build() { 78 | return pmp; 79 | } 80 | 81 | public Builder setPrivateAuction(final int privateAuction) { 82 | pmp.setPrivate_auction(privateAuction); 83 | return this; 84 | } 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/bidrequest/model/Pricelayer.java: -------------------------------------------------------------------------------- 1 | package openrtb.bidrequest.model; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class Pricelayer { 8 | 9 | private String siteid; 10 | 11 | private float bidfloor; 12 | 13 | private String currency; 14 | 15 | public String getSiteid() { 16 | return siteid; 17 | } 18 | 19 | public void setSiteid(final String siteid) { 20 | this.siteid = siteid; 21 | } 22 | 23 | public float getBidfloor() { 24 | return bidfloor; 25 | } 26 | 27 | public void setBidfloor(final float bidfloor) { 28 | this.bidfloor = bidfloor; 29 | } 30 | 31 | public String getCurrency() { 32 | return currency; 33 | } 34 | 35 | public void setCurrency(final String currency) { 36 | this.currency = currency; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/bidresponse/model/BidOrBuilder.java: -------------------------------------------------------------------------------- 1 | package openrtb.bidresponse.model; 2 | 3 | public interface BidOrBuilder { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/bidresponse/model/SeatBidOrBuilder.java: -------------------------------------------------------------------------------- 1 | package openrtb.bidresponse.model; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public interface SeatBidOrBuilder { 8 | 9 | boolean hasSeat(); 10 | 11 | String getSeat(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/tables/CreativeAttribute.java: -------------------------------------------------------------------------------- 1 | package openrtb.tables; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public abstract class CreativeAttribute { 8 | 9 | public static final int POP = 8; 10 | 11 | public static final int ANNOYING = 9; 12 | 13 | public static final int SURVEYS = 11; 14 | 15 | public static final int TEXT_ONLY = 12; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/tables/DeviceType.java: -------------------------------------------------------------------------------- 1 | package openrtb.tables; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public abstract class DeviceType { 8 | 9 | public static final int MOBILE_OR_TABLET = 1; 10 | 11 | public static final int PERSONAL_COMPUTER = 2; 12 | 13 | public static final int CONNECTED_TV = 3; 14 | 15 | public static final int PHONE = 4; 16 | 17 | public static final int TABLET = 5; 18 | 19 | public static final int CONNECTED_DEVICE = 6; 20 | 21 | public static final int SET_TOP_BOX = 7; 22 | 23 | public static final int OUT_OF_HOME = 8; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/tables/NoBidreason.java: -------------------------------------------------------------------------------- 1 | package openrtb.tables; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public enum NoBidreason { 8 | 9 | UNKNOWN_ERROR(0), 10 | 11 | TECHNICAL_ERROR(1), 12 | 13 | INVALID_REQUEST(2), 14 | 15 | KNOWN_WEB_SPIDER(3), 16 | 17 | SUSPECTED_NON_HUMAN_TRAFFIC(4), 18 | 19 | CLOUD_DATACENTER_OR_PROXY_IP(5), 20 | 21 | UNSUPPORTED_DEVICE(6), 22 | 23 | BLOCKED_PUBLISHER_OR_SITE(7), 24 | 25 | UNMATCHED_USER(8); 26 | 27 | private int value; 28 | 29 | private NoBidreason(final int value) { 30 | this.value = value; 31 | } 32 | 33 | public int getValue() { 34 | return value; 35 | } 36 | 37 | public static NoBidreason convertValue(final int value) { 38 | for (final NoBidreason reason : values()) { 39 | if (reason.getValue() == value) { 40 | return reason; 41 | } 42 | } 43 | return null; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/tables/VideoApiFramework.java: -------------------------------------------------------------------------------- 1 | package openrtb.tables; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public abstract class VideoApiFramework { 8 | 9 | public static final int VPAID_1_0 = 1; 10 | 11 | public static final int VPAID_2_0 = 2; 12 | 13 | public static final int MRAID_1 = 3; 14 | 15 | public static final int ORMMA = 4; 16 | 17 | public static final int MRAID_2 = 5; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/tables/VideoBidResponseProtocol.java: -------------------------------------------------------------------------------- 1 | package openrtb.tables; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public enum VideoBidResponseProtocol { 8 | 9 | /** 10 | * 1 (VAST 1.0) 11 | */ 12 | VAST_1_0(1), 13 | 14 | /** 15 | * 2 (VAST 2.0) 16 | */ 17 | VAST_2_0(2), 18 | 19 | /** 20 | * 3 (VAST 3.0) 21 | */ 22 | VAST_3_0(3), 23 | 24 | /** 25 | * 4 (VAST 1.0 WRAPPER) 26 | */ 27 | VAST_1_0_WRAPPER(4), 28 | 29 | /** 30 | * 5 (VAST 2.0 WRAPPER) 31 | */ 32 | VAST_2_0_WRAPPER(5), 33 | 34 | /** 35 | * 6 (VAST 3.0 WRAPPER) 36 | */ 37 | VAST_3_0_WRAPPER(6), 38 | 39 | /** 40 | * 7 (VAST 4.0) 41 | */ 42 | VAST_4_0(7), 43 | 44 | /** 45 | * 8 (VAST 4.0 WRAPPER) 46 | */ 47 | VAST_4_0_WRAPPER(8), 48 | 49 | /** 50 | * 9 (DAAST 1.0) 51 | */ 52 | DAAST_1_0(9), 53 | 54 | /** 55 | * 10 (DAAST 1.0 WRAPPER) 56 | */ 57 | DAAST_1_0_WRAPPER(10); 58 | 59 | private int value; 60 | 61 | private VideoBidResponseProtocol(final int value) { 62 | this.value = value; 63 | } 64 | 65 | public int getValue() { 66 | return value; 67 | } 68 | 69 | public static int convertFromString(final String value) { 70 | for (final VideoBidResponseProtocol protocolValue : values()) { 71 | if (protocolValue.value == Integer.valueOf(value).intValue()) { 72 | return protocolValue.value; 73 | } 74 | } 75 | 76 | return VAST_3_0.value; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-openrtb/src/main/java/openrtb/tables/VideoLinearity.java: -------------------------------------------------------------------------------- 1 | package openrtb.tables; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public abstract class VideoLinearity { 8 | 9 | public static final int LINEAR = 1; 10 | 11 | public static final int NON_LINEAR = 2; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-restful-client/.gitignore: -------------------------------------------------------------------------------- 1 | /.settings/ 2 | /target/ 3 | /.classpath 4 | /.project 5 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-restful-client/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.atg.openssp 6 | open-ssp-parent 7 | 0.3 8 | 9 | open-ssp-restful-client 10 | 11 | 12 | 13 | 14 | org.springframework.boot 15 | spring-boot-starter 16 | 1.3.3.RELEASE 17 | 18 | 19 | 20 | org.springframework 21 | spring-web 22 | 4.2.5.RELEASE 23 | 24 | 25 | 26 | com.fasterxml.jackson.core 27 | jackson-databind 28 | 2.9.10.1 29 | 30 | 31 | 32 | org.apache.httpcomponents 33 | httpclient 34 | 4.5.2 35 | 36 | 37 | 38 | junit 39 | junit 40 | 4.12 41 | test 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-restful-client/src/main/java/restful/client/DataProviderConnector.java: -------------------------------------------------------------------------------- 1 | package restful.client; 2 | 3 | import restful.context.PathBuilder; 4 | import restful.exception.RestException; 5 | 6 | /** 7 | * @author André Schmer 8 | * 9 | */ 10 | public interface DataProviderConnector { 11 | 12 | /** 13 | * Doing the connection to the remote using the configuration data {@code config}. 14 | * 15 | * @param config 16 | * @return T {@link T} 17 | * @throws RestException 18 | */ 19 | T connectDataProvider(PathBuilder config) throws RestException; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-restful-client/src/main/java/restful/client/HttpComponentsClientHttpRequestFactoryBasicAuth.java: -------------------------------------------------------------------------------- 1 | package restful.client; 2 | 3 | import java.net.URI; 4 | 5 | import org.apache.http.HttpHost; 6 | import org.apache.http.client.AuthCache; 7 | import org.apache.http.client.protocol.HttpClientContext; 8 | import org.apache.http.impl.auth.BasicScheme; 9 | import org.apache.http.impl.client.BasicAuthCache; 10 | import org.apache.http.protocol.BasicHttpContext; 11 | import org.apache.http.protocol.HttpContext; 12 | import org.springframework.http.HttpMethod; 13 | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; 14 | 15 | /** 16 | * @author André Schmer 17 | * 18 | */ 19 | public class HttpComponentsClientHttpRequestFactoryBasicAuth extends HttpComponentsClientHttpRequestFactory { 20 | 21 | private final HttpHost host; 22 | 23 | public HttpComponentsClientHttpRequestFactoryBasicAuth(final HttpHost host) { 24 | super(); 25 | this.host = host; 26 | } 27 | 28 | @Override 29 | protected HttpContext createHttpContext(final HttpMethod httpMethod, final URI uri) { 30 | return createHttpContext(); 31 | } 32 | 33 | private HttpContext createHttpContext() { 34 | // Create AuthCache instance 35 | final AuthCache authCache = new BasicAuthCache(); 36 | // Generate BASIC scheme object and add it to the local auth cache 37 | final BasicScheme basicAuth = new BasicScheme(); 38 | authCache.put(host, basicAuth); 39 | 40 | // Add AuthCache to the execution context 41 | final BasicHttpContext localcontext = new BasicHttpContext(); 42 | localcontext.setAttribute(HttpClientContext.AUTH_CACHE, authCache); 43 | return localcontext; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-restful-client/src/main/java/restful/context/Path.java: -------------------------------------------------------------------------------- 1 | package restful.context; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public enum Path { 8 | 9 | /** 10 | * ssp-data-provider 11 | */ 12 | CORE("ssp-data-provider/lookup"), 13 | 14 | /** 15 | * supplier 16 | */ 17 | SUPPLIER("supplier"), 18 | 19 | /** 20 | * sspAdapter 21 | */ 22 | SSP_ADAPTER("sspAdapter"), 23 | 24 | /** 25 | * eurref 26 | */ 27 | EUR_REF("eurref"), 28 | 29 | /** 30 | * ?website=1 31 | */ 32 | WEBSITE("?website=1"); 33 | 34 | private String value; 35 | 36 | private Path(final String value) { 37 | this.value = value; 38 | } 39 | 40 | public String getValue() { 41 | return value; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-restful-client/src/main/java/restful/context/RestfulContext.java: -------------------------------------------------------------------------------- 1 | package restful.context; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class RestfulContext { 8 | 9 | private static String token; 10 | 11 | public static void setToken(final String logintoken) { 12 | token = logintoken; 13 | } 14 | 15 | public static String getToken() { 16 | return token; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-restful-client/src/main/java/restful/exception/RestException.java: -------------------------------------------------------------------------------- 1 | package restful.exception; 2 | 3 | /** 4 | * @author André Schmer 5 | * 6 | */ 7 | public class RestException extends Exception { 8 | 9 | private static final long serialVersionUID = -980000547004160218L; 10 | 11 | public RestException(final String message) { 12 | super(message); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-utilities/.gitignore: -------------------------------------------------------------------------------- 1 | /.classpath 2 | /.project 3 | /.settings/ 4 | /target/ 5 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-utilities/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.atg.openssp 6 | open-ssp-parent 7 | 0.3 8 | 9 | open-ssp-utilities 10 | 11 | 12 | 13 | commons-codec 14 | commons-codec 15 | 1.10 16 | 17 | 18 | 19 | org.apache.commons 20 | commons-lang3 21 | 3.5 22 | 23 | 24 | 25 | com.google.truth 26 | truth 27 | test 28 | 29 | 30 | 31 | org.apache.logging.log4j 32 | log4j-slf4j-impl 33 | 2.8 34 | 35 | 36 | -------------------------------------------------------------------------------- /open-ssp-parent/open-ssp-utilities/src/main/java/util/SimpleRingBuffer.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import java.io.Serializable; 4 | import java.lang.reflect.Array; 5 | import java.util.ArrayList; 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | /** 10 | * 11 | * @author André Schmer 12 | * 13 | * @param 14 | */ 15 | public class SimpleRingBuffer implements Serializable { 16 | 17 | private static final long serialVersionUID = -725298200872218297L; 18 | private final T[] buffer; 19 | private int pointer = 0; 20 | private final int capacity; 21 | 22 | @SuppressWarnings("unchecked") 23 | public SimpleRingBuffer(final int capacity, final Class clazz) { 24 | if (capacity < 0) { 25 | throw new IllegalArgumentException("capacity may not be negative"); 26 | } 27 | if (clazz == null) { 28 | throw new IllegalArgumentException("null injection is not allowed"); 29 | } 30 | this.capacity = capacity; 31 | this.buffer = (T[]) Array.newInstance(clazz, capacity); 32 | } 33 | 34 | public void add(final T l) { 35 | pointer = pointer % this.capacity; 36 | buffer[pointer++] = l; 37 | } 38 | 39 | public T[] getAll() { 40 | return buffer; 41 | } 42 | 43 | public List asList() { 44 | final List l = new ArrayList<>(); 45 | for (final T t : buffer) { 46 | if (t != null) { 47 | l.add(t); 48 | } 49 | } 50 | return l; 51 | } 52 | 53 | public int capacity() { 54 | return capacity; 55 | } 56 | 57 | public int size() { 58 | return this.buffer.length; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return String.format("SimpleRingBuffer [buffer=%s, pointer=%s, capacity=%s]", Arrays.toString(buffer), pointer, capacity); 64 | } 65 | 66 | } 67 | --------------------------------------------------------------------------------