本文整理汇总了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);
}
示例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
);
}
示例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();
}