use of java.util.Date in project buck by facebook.
the class ProvisioningProfileStore method getBestProvisioningProfile.
// If multiple valid ones, find the one which matches the most specifically. I.e.,
// XXXXXXXXXX.com.example.* will match over XXXXXXXXXX.* for com.example.TestApp
public Optional<ProvisioningProfileMetadata> getBestProvisioningProfile(String bundleID, ApplePlatform platform, Optional<ImmutableMap<String, NSObject>> entitlements, Optional<? extends Iterable<CodeSignIdentity>> identities) {
final Optional<String> prefix;
if (entitlements.isPresent()) {
prefix = ProvisioningProfileMetadata.prefixFromEntitlements(entitlements.get());
} else {
prefix = Optional.empty();
}
int bestMatchLength = -1;
Optional<ProvisioningProfileMetadata> bestMatch = Optional.empty();
for (ProvisioningProfileMetadata profile : getProvisioningProfiles()) {
if (profile.getExpirationDate().after(new Date())) {
Pair<String, String> appID = profile.getAppID();
LOG.debug("Looking at provisioning profile " + profile.getUUID() + "," + appID.toString());
if (!prefix.isPresent() || prefix.get().equals(appID.getFirst())) {
String profileBundleID = appID.getSecond();
boolean match;
if (profileBundleID.endsWith("*")) {
// Chop the ending * if wildcard.
profileBundleID = profileBundleID.substring(0, profileBundleID.length() - 1);
match = bundleID.startsWith(profileBundleID);
} else {
match = (bundleID.equals(profileBundleID));
}
if (!match) {
LOG.debug("Ignoring non-matching ID for profile " + profile.getUUID() + ". Expected: " + profileBundleID + ", actual: " + bundleID);
continue;
}
Optional<String> platformName = platform.getProvisioningProfileName();
if (platformName.isPresent() && !profile.getPlatforms().contains(platformName.get())) {
LOG.debug("Ignoring incompatible platform " + platformName.get() + " for profile " + profile.getUUID());
continue;
}
// For example: get-task-allow, aps-environment, etc.
if (entitlements.isPresent()) {
ImmutableMap<String, NSObject> entitlementsDict = entitlements.get();
ImmutableMap<String, NSObject> profileEntitlements = profile.getEntitlements();
for (Entry<String, NSObject> entry : entitlementsDict.entrySet()) {
if (!(entry.getKey().equals("keychain-access-groups") || entry.getKey().equals("application-identifier") || entry.getKey().equals("com.apple.developer.associated-domains") || matchesOrArrayIsSubsetOf(entry.getValue(), profileEntitlements.get(entry.getKey())))) {
match = false;
LOG.debug("Ignoring profile " + profile.getUUID() + " with mismatched entitlement " + entry.getKey() + "; value is " + profileEntitlements.get(entry.getKey()) + " but expected " + entry.getValue());
break;
}
}
}
// Reject any certificate which we know we can't sign with the supplied identities.
ImmutableSet<HashCode> validFingerprints = profile.getDeveloperCertificateFingerprints();
if (match && identities.isPresent() && !validFingerprints.isEmpty()) {
match = false;
for (CodeSignIdentity identity : identities.get()) {
Optional<HashCode> fingerprint = identity.getFingerprint();
if (fingerprint.isPresent() && validFingerprints.contains(fingerprint.get())) {
match = true;
break;
}
}
if (!match) {
LOG.debug("Ignoring profile " + profile.getUUID() + " because it can't be signed with any valid identity in the current keychain.");
continue;
}
}
if (match && profileBundleID.length() > bestMatchLength) {
bestMatchLength = profileBundleID.length();
bestMatch = Optional.of(profile);
}
}
} else {
LOG.debug("Ignoring expired profile " + profile.getUUID());
}
}
LOG.debug("Found provisioning profile " + bestMatch.toString());
return bestMatch;
}
use of java.util.Date in project sharding-jdbc by dangdangdotcom.
the class ShardingValueWrapperTest method testDateValue.
@Test
public void testDateValue() throws Exception {
Date now = new Date();
assertThat(new ShardingValueWrapper(now).dateValue(), is(now));
assertThat(new ShardingValueWrapper(now.getTime()).dateValue(), is(now));
assertThat(new ShardingValueWrapper(format.format(date)).dateValue(FORMAT_TEXT), is(date));
}
use of java.util.Date in project sharding-jdbc by dangdangdotcom.
the class ShardingValueWrapperTest method testLongValue.
@Test
public void testLongValue() throws Exception {
assertThat(new ShardingValueWrapper((short) 1).longValue(), is(1L));
assertThat(new ShardingValueWrapper(1).longValue(), is(1L));
assertThat(new ShardingValueWrapper(1L).longValue(), is(1L));
assertThat(new ShardingValueWrapper(1.0F).longValue(), is(1L));
assertThat(new ShardingValueWrapper(1.0D).longValue(), is(1L));
assertThat(new ShardingValueWrapper("1").longValue(), is(1L));
Date now = new Date();
assertThat(new ShardingValueWrapper(now).longValue(), is(now.getTime()));
}
use of java.util.Date in project Meizhi by drakeet.
the class FloatView method setNotification.
public void setNotification(final HeadsUp headsUp) {
this.headsUp = headsUp;
mHandle = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (headsUp.isActivateStatusBar()) {
HeadsUpManager.getInstant(getContext()).silencerNotify(headsUp);
}
HeadsUpManager.getInstant(getContext()).animDismiss(headsUp);
}
};
cutDownTime = new CutDownTime();
if (!headsUp.isSticky()) {
cutDownTime.start();
}
cutDown = headsUp.getDuration();
if (headsUp.getCustomView() == null) {
View defaultView = LayoutInflater.from(getContext()).inflate(R.layout.notification, rootView, false);
rootView.addView(defaultView);
ImageView imageView = (ImageView) defaultView.findViewById(R.id.iconIM);
TextView titleTV = (TextView) defaultView.findViewById(R.id.titleTV);
TextView timeTV = (TextView) defaultView.findViewById(R.id.timeTV);
TextView messageTV = (TextView) defaultView.findViewById(R.id.messageTV);
imageView.setImageResource(headsUp.getIcon());
titleTV.setText(headsUp.getTitleStr());
messageTV.setText(headsUp.getMsgStr());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
timeTV.setText(simpleDateFormat.format(new Date()));
if (headsUp.isExpand() && headsUp.getActions().size() > 0) {
defaultView.findViewById(R.id.menuL).setVisibility(VISIBLE);
defaultView.findViewById(R.id.line).setVisibility(VISIBLE);
defaultView.findViewById(R.id.menu1).setVisibility(VISIBLE);
ImageView imageView1 = (ImageView) defaultView.findViewById(R.id.menuIM1);
ImageView imageView2 = (ImageView) defaultView.findViewById(R.id.menuIM2);
ImageView imageView3 = (ImageView) defaultView.findViewById(R.id.menuIM3);
TextView text1 = (TextView) defaultView.findViewById(R.id.menuText1);
TextView text2 = (TextView) defaultView.findViewById(R.id.menuText2);
TextView text3 = (TextView) defaultView.findViewById(R.id.menuText3);
imageView1.setImageResource(headsUp.getActions().get(0).icon);
text1.setText(headsUp.getActions().get(0).title);
defaultView.findViewById(R.id.menu1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
headsUp.getActions().get(0).actionIntent.send();
cancel();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
});
if (headsUp.getActions().size() > 1) {
defaultView.findViewById(R.id.menu2).setVisibility(VISIBLE);
imageView2.setImageResource(headsUp.getActions().get(1).icon);
text2.setText(headsUp.getActions().get(1).title);
defaultView.findViewById(R.id.menu2).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
headsUp.getActions().get(1).actionIntent.send();
cancel();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
});
}
if (headsUp.getActions().size() > 2) {
defaultView.findViewById(R.id.menu3).setVisibility(VISIBLE);
imageView3.setImageResource(headsUp.getActions().get(2).icon);
text3.setText(headsUp.getActions().get(2).title);
defaultView.findViewById(R.id.menu3).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
headsUp.getActions().get(2).actionIntent.send();
cancel();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
});
}
}
} else {
setCustomView(headsUp.getCustomView());
}
}
use of java.util.Date in project druid by druid-io.
the class S3DataSegmentPullerTest method testSimpleGetVersion.
@Test
public void testSimpleGetVersion() throws ServiceException, IOException {
String bucket = "bucket";
String keyPrefix = "prefix/dir/0";
RestS3Service s3Client = EasyMock.createStrictMock(RestS3Service.class);
S3Object object0 = new S3Object();
object0.setBucketName(bucket);
object0.setKey(keyPrefix + "/renames-0.gz");
object0.setLastModifiedDate(new Date(0));
EasyMock.expect(s3Client.getObjectDetails(EasyMock.eq(bucket), EasyMock.eq(object0.getKey()))).andReturn(object0).once();
S3DataSegmentPuller puller = new S3DataSegmentPuller(s3Client);
EasyMock.replay(s3Client);
String version = puller.getVersion(URI.create(String.format("s3://%s/%s", bucket, object0.getKey())));
EasyMock.verify(s3Client);
Assert.assertEquals(String.format("%d", new Date(0).getTime()), version);
}
Aggregations