當前位置: 首頁>>代碼示例>>Java>>正文


Java Duration.standardSeconds方法代碼示例

本文整理匯總了Java中org.joda.time.Duration.standardSeconds方法的典型用法代碼示例。如果您正苦於以下問題:Java Duration.standardSeconds方法的具體用法?Java Duration.standardSeconds怎麽用?Java Duration.standardSeconds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.Duration的用法示例。


在下文中一共展示了Duration.standardSeconds方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import org.joda.time.Duration; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    PrivateKey privateKey = new PrivateKeyStoreFactory().create(TestEntityIds.TEST_RP).getEncryptionPrivateKeys().get(0);
    ResponseFactory responseFactory = new ResponseFactory(privateKey, privateKey);

    EntityDescriptor entityDescriptor = anEntityDescriptor()
        .withIdpSsoDescriptor(anIdpSsoDescriptor()
            .addKeyDescriptor(aKeyDescriptor()
                .withX509ForSigning(TEST_RP_MS_PUBLIC_SIGNING_CERT)
                .build())
            .build())
        .build();

    MetadataResolver msaMetadataResolver = mock(MetadataResolver.class);
    DateTimeComparator dateTimeComparator = new DateTimeComparator(Duration.standardSeconds(5));
    when(msaMetadataResolver.resolve(any())).thenReturn(ImmutableList.of(entityDescriptor));

    translator = responseFactory.createAssertionTranslator(msaMetadataResolver, dateTimeComparator);
}
 
開發者ID:alphagov,項目名稱:verify-service-provider,代碼行數:20,代碼來源:AssertionTranslatorTest.java

示例2: setUp

import org.joda.time.Duration; //導入方法依賴的package包/類
@Before
public void setUp() throws ComponentInitializationException {
    // Note: the private key and the encrypting credential need to be from the same keypair
    PrivateKey privateKey = new PrivateKeyStoreFactory().create(TestEntityIds.TEST_RP).getEncryptionPrivateKeys().get(0);
    encryptionCredentialFactory = new TestCredentialFactory(TEST_RP_PUBLIC_ENCRYPTION_CERT, TEST_RP_PRIVATE_ENCRYPTION_KEY);
    testRpSigningCredential = new TestCredentialFactory(TEST_RP_PUBLIC_SIGNING_CERT, TEST_RP_PRIVATE_SIGNING_KEY).getSigningCredential();

    hubMetadataResolver = mock(MetadataResolver.class);

    ResponseFactory responseFactory = new ResponseFactory(privateKey, privateKey);
    DateTimeComparator dateTimeComparator = new DateTimeComparator(Duration.standardSeconds(5));
    TimeRestrictionValidator timeRestrictionValidator = new TimeRestrictionValidator(dateTimeComparator);

    SamlAssertionsSignatureValidator samlAssertionsSignatureValidator = mock(SamlAssertionsSignatureValidator.class);
    InstantValidator instantValidator = new InstantValidator(dateTimeComparator);
    SubjectValidator subjectValidator = new SubjectValidator(timeRestrictionValidator);
    ConditionsValidator conditionsValidator = new ConditionsValidator(timeRestrictionValidator, new AudienceRestrictionValidator());
    AssertionValidator assertionValidator = new AssertionValidator(instantValidator, subjectValidator, conditionsValidator);
    AssertionTranslator assertionTranslator = new AssertionTranslator(samlAssertionsSignatureValidator, assertionValidator);

    responseService = responseFactory.createResponseService(
        hubMetadataResolver,
        assertionTranslator,
        dateTimeComparator
    );
}
 
開發者ID:alphagov,項目名稱:verify-service-provider,代碼行數:27,代碼來源:ResponseServiceTest.java

示例3: main

import org.joda.time.Duration; //導入方法依賴的package包/類
public static void main(String args[]) throws InterruptedException, ExecutionException, IncompleteOfferingQueryException, IOException, AccessToNonSubscribedOfferingException, AccessToNonActivatedOfferingException {
		
		// Initialize consumer with Consumer ID and Marketplace URL
		Consumer consumer = new Consumer(CONSUMER_ID, MARKETPLACE_URI);
		
//		consumer.setProxy("127.0.0.1", 3128); //Enable this line if you are behind a proxy
//		consumer.addProxyBypass("172.17.17.100"); //Enable this line and the addresses for internal hosts
		
		// Authenticate consumer on the marketplace
		consumer.authenticate(CONSUMER_SECRET);
				
	    // Construct Offering Query incrementally
		OfferingQuery query = OfferingQuery.create("RandomNumberQuery")
				.withInformation(new Information("Random Number Query", "bigiot:RandomNumber"))
	    		//.addOutputData("value", new RDFType("schema:random"), ValueType.NUMBER)
				//.inRegion(RegionFilter.city(""))
				.withPricingModel(PricingModel.PER_ACCESS)
				.withMaxPrice(Euros.amount(0.002))             
				.withLicenseType(LicenseType.OPEN_DATA_LICENSE);

		// Discover available offerings based on Offering Query
		CompletableFuture<List<SubscribableOfferingDescription>> listFuture = consumer.discover(query);
		listFuture.thenApply(SubscribableOfferingDescription::showOfferingDescriptions);			
		List<SubscribableOfferingDescription> list = listFuture.get();	
		
		// Select Offering that has been offered by a local provider instance 
		SubscribableOfferingDescription selectedOfferingDescription = list.get(0); 
		
		if (selectedOfferingDescription != null) { 
			
			// Subscribe to a selected OfferingDescription (if successful, returns accessible Offering instance)		
			CompletableFuture<Offering> offeringFuture = selectedOfferingDescription.subscribe();
			Offering offering = offeringFuture.get();
	
			// Prepare Access Parameters
			AccessParameters accessParameters = AccessParameters.create();
			
			// EXAMPLE 1: ONE-TIME ACCESS to the Offering
			AccessResponse response = offering.accessOneTime(accessParameters).get();
            System.out.println("Received data: " + response.asJsonNode().toString());
            
            // EXAMPLE 2: CONTINUOUS ACCESS to the Offering 
			// Create an Access Feed with callbacks for the received results		
			Duration feedDuration = Duration.standardHours(2);
			Duration feedInterval = Duration.standardSeconds(2);
			AccessFeed accessFeed = offering.accessContinuous(accessParameters, 
										feedDuration.getMillis(), 
										feedInterval.getMillis(), 
										(f,r) -> {
											System.out.println("Received data: " + r.asJsonNode().toString());
										},
										(f,r) -> {
											System.out.println("Feed operation failed");
											f.stop();
										});
			
			// Run until user presses the ENTER key
			System.out.println(">>>>>>  Terminate ExampleConsumer by pressing ENTER  <<<<<<");
			Scanner keyboard = new Scanner(System.in);
			keyboard.nextLine();
	
			// Stop Access Feed
			accessFeed.stop();
			
			// Unsubscribe the Offering
			offering.unsubscribe();
	
		}
		else {
			// No active Offerings could be discovered 
			System.out.println(">>>>>>  No matching offering found  <<<<<<");
		}
		
		// Terminate consumer instance
		consumer.terminate();
			
	}
 
開發者ID:BIG-IoT,項目名稱:example-projects,代碼行數:78,代碼來源:ExampleConsumer.java


注:本文中的org.joda.time.Duration.standardSeconds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。