Search in sources :

Example 51 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project pac4j by pac4j.

the class SAML2ClientConfiguration method createSelfSignedCert.

/**
 * Generate a self-signed certificate for dn using the provided signature algorithm and key pair.
 *
 * @param dn X.500 name to associate with certificate issuer/subject.
 * @param sigName name of the signature algorithm to use.
 * @param sigAlgID algorithm ID associated with the signature algorithm name.
 * @param keyPair the key pair to associate with the certificate.
 * @return an X509Certificate containing the public key in keyPair.
 * @throws Exception
 */
private X509Certificate createSelfSignedCert(X500Name dn, String sigName, AlgorithmIdentifier sigAlgID, KeyPair keyPair) throws Exception {
    V3TBSCertificateGenerator certGen = new V3TBSCertificateGenerator();
    certGen.setSerialNumber(new ASN1Integer(BigInteger.valueOf(1)));
    certGen.setIssuer(dn);
    certGen.setSubject(dn);
    certGen.setStartDate(new Time(new Date(System.currentTimeMillis() - 1000L)));
    final Calendar c = Calendar.getInstance();
    c.setTime(new Date());
    c.add(Calendar.YEAR, 1);
    certGen.setEndDate(new Time(c.getTime()));
    certGen.setSignature(sigAlgID);
    certGen.setSubjectPublicKeyInfo(SubjectPublicKeyInfo.getInstance(keyPair.getPublic().getEncoded()));
    Signature sig = Signature.getInstance(sigName);
    sig.initSign(keyPair.getPrivate());
    sig.update(certGen.generateTBSCertificate().getEncoded(ASN1Encoding.DER));
    TBSCertificate tbsCert = certGen.generateTBSCertificate();
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(tbsCert);
    v.add(sigAlgID);
    v.add(new DERBitString(sig.sign()));
    X509Certificate cert = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(new DERSequence(v).getEncoded(ASN1Encoding.DER)));
    // check the certificate - this will confirm the encoded sig algorithm ID is correct.
    cert.verify(keyPair.getPublic());
    return cert;
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) Calendar(java.util.Calendar) Signature(java.security.Signature) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) V3TBSCertificateGenerator(org.bouncycastle.asn1.x509.V3TBSCertificateGenerator) Time(org.bouncycastle.asn1.x509.Time) DERBitString(org.bouncycastle.asn1.DERBitString) ASN1Integer(org.bouncycastle.asn1.ASN1Integer) TBSCertificate(org.bouncycastle.asn1.x509.TBSCertificate) Date(java.util.Date) X509Certificate(java.security.cert.X509Certificate)

Example 52 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project Etar-Calendar by Etar-Group.

the class SimpleWeekView method onHoverEvent.

@Override
public boolean onHoverEvent(MotionEvent event) {
    Context context = getContext();
    // only send accessibility events if accessibility and exploration are
    // on.
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Service.ACCESSIBILITY_SERVICE);
    if (!am.isEnabled() || !am.isTouchExplorationEnabled()) {
        return super.onHoverEvent(event);
    }
    if (event.getAction() != MotionEvent.ACTION_HOVER_EXIT) {
        Time hover = getDayFromLocation(event.getX());
        if (hover != null && (mLastHoverTime == null || hover.compareTo(mLastHoverTime) != 0)) {
            Long millis = hover.toMillis();
            String date = Utils.formatDateRange(context, millis, millis, DateUtils.FORMAT_SHOW_DATE);
            AccessibilityEvent accessEvent = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
            accessEvent.getText().add(date);
            sendAccessibilityEventUnchecked(accessEvent);
            mLastHoverTime = hover;
        }
    }
    return true;
}
Also used : Context(android.content.Context) AccessibilityManager(android.view.accessibility.AccessibilityManager) Time(com.android.calendarcommon2.Time) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 53 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project Etar-Calendar by Etar-Group.

the class SimpleWeekView method setWeekParams.

/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in. See
 * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
 *
 * @param params A map of the new parameters, see
 *            {@link #VIEW_PARAMS_HEIGHT}
 * @param tz The time zone this view should reference times in
 */
public void setWeekParams(HashMap<String, Integer> params, String tz) {
    if (!params.containsKey(VIEW_PARAMS_WEEK)) {
        throw new InvalidParameterException("You must specify the week number for this view");
    }
    setTag(params);
    mTimeZone = tz;
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mHeight < MIN_HEIGHT) {
            mHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }
    mHasSelectedDay = mSelectedDay != -1;
    if (params.containsKey(VIEW_PARAMS_NUM_DAYS)) {
        mNumDays = params.get(VIEW_PARAMS_NUM_DAYS);
    }
    if (params.containsKey(VIEW_PARAMS_SHOW_WK_NUM)) {
        if (params.get(VIEW_PARAMS_SHOW_WK_NUM) != 0) {
            mShowWeekNum = true;
        } else {
            mShowWeekNum = false;
        }
    }
    mNumCells = mShowWeekNum ? mNumDays + 1 : mNumDays;
    // Allocate space for caching the day numbers and focus values
    mDayNumbers = new String[mNumCells];
    mFocusDay = new boolean[mNumCells];
    mOddMonth = new boolean[mNumCells];
    mWeek = params.get(VIEW_PARAMS_WEEK);
    int julianMonday = Utils.getJulianMondayFromWeeksSinceEpoch(mWeek);
    Time time = new Time(tz);
    time.setJulianDay(julianMonday);
    // If we're showing the week number calculate it based on Monday
    int i = 0;
    if (mShowWeekNum) {
        mDayNumbers[0] = NumberFormat.getInstance().format(time.getWeekNumber());
        i++;
    }
    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    }
    // Dec 27th 1969 -Jan 2nd, 1970
    if (time.getWeekDay() != mWeekStart) {
        int diff = time.getWeekDay() - mWeekStart;
        if (diff < 0) {
            diff += 7;
        }
        time.setDay(time.getDay() - diff);
        time.normalize();
    }
    mFirstJulianDay = Time.getJulianDay(time.toMillis(), time.getGmtOffset());
    mFirstMonth = time.getMonth();
    // Figure out what day today is
    Time today = new Time(tz);
    today.set(System.currentTimeMillis());
    mHasToday = false;
    mToday = -1;
    int focusMonth = params.containsKey(VIEW_PARAMS_FOCUS_MONTH) ? params.get(VIEW_PARAMS_FOCUS_MONTH) : DEFAULT_FOCUS_MONTH;
    for (; i < mNumCells; i++) {
        if (time.getDay() == 1) {
            mFirstMonth = time.getMonth();
        }
        mOddMonth[i] = (time.getMonth() % 2) == 1;
        if (time.getMonth() == focusMonth) {
            mFocusDay[i] = true;
        } else {
            mFocusDay[i] = false;
        }
        if (time.getYear() == today.getYear() && time.getYearDay() == today.getYearDay()) {
            mHasToday = true;
            mToday = i;
        }
        mDayNumbers[i] = NumberFormat.getInstance().format(time.getDay());
        time.setDay(time.getDay() + 1);
        time.normalize();
    }
    // new month undo it
    if (time.getDay() == 1) {
        time.setDay(time.getDay() - 1);
        time.normalize();
    }
    mLastMonth = time.getMonth();
    updateSelectionPositions();
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Time(com.android.calendarcommon2.Time) Paint(android.graphics.Paint)

Example 54 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project Etar-Calendar by Etar-Group.

the class SimpleWeeksAdapter method onTouch.

@Override
public boolean onTouch(View v, MotionEvent event) {
    if (mGestureDetector.onTouchEvent(event)) {
        SimpleWeekView view = (SimpleWeekView) v;
        Time day = ((SimpleWeekView) v).getDayFromLocation(event.getX());
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "Touched day at Row=" + view.mWeek + " day=" + day.toString());
        }
        if (day != null) {
            onDayTapped(day);
        }
        return true;
    }
    return false;
}
Also used : Time(com.android.calendarcommon2.Time)

Example 55 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project Etar-Calendar by Etar-Group.

the class RecurrencePickerDialog method copyEventRecurrenceToModel.

// TODO don't lose data when getting data that our UI can't handle
private static void copyEventRecurrenceToModel(final EventRecurrence er, RecurrenceModel model) {
    // Freq:
    switch(er.freq) {
        case EventRecurrence.DAILY:
            model.freq = RecurrenceModel.FREQ_DAILY;
            break;
        case EventRecurrence.MONTHLY:
            model.freq = RecurrenceModel.FREQ_MONTHLY;
            break;
        case EventRecurrence.YEARLY:
            model.freq = RecurrenceModel.FREQ_YEARLY;
            break;
        case EventRecurrence.WEEKLY:
            model.freq = RecurrenceModel.FREQ_WEEKLY;
            break;
        default:
            throw new IllegalStateException("freq=" + er.freq);
    }
    // Interval:
    if (er.interval > 0) {
        model.interval = er.interval;
    }
    // End:
    // End by count:
    model.endCount = er.count;
    if (model.endCount > 0) {
        model.end = RecurrenceModel.END_BY_COUNT;
    }
    // End by date:
    if (!TextUtils.isEmpty(er.until)) {
        if (model.endDate == null) {
            model.endDate = new Time();
        }
        try {
            model.endDate.parse(er.until);
        } catch (TimeFormatException e) {
            model.endDate = null;
        }
        // LIMITATION: The UI can only handle END_BY_DATE or END_BY_COUNT
        if (model.end == RecurrenceModel.END_BY_COUNT && model.endDate != null) {
            throw new IllegalStateException("freq=" + er.freq);
        }
        model.end = RecurrenceModel.END_BY_DATE;
    }
    // Weekly: repeat by day of week or Monthly: repeat by nth day of week
    // in the month
    Arrays.fill(model.weeklyByDayOfWeek, false);
    if (er.bydayCount > 0) {
        int count = 0;
        for (int i = 0; i < er.bydayCount; i++) {
            int dayOfWeek = EventRecurrence.day2TimeDay(er.byday[i]);
            model.weeklyByDayOfWeek[dayOfWeek] = true;
            if (model.freq == RecurrenceModel.FREQ_MONTHLY && isSupportedMonthlyByNthDayOfWeek(er.bydayNum[i])) {
                // LIMITATION: Can handle only (one) weekDayNum in nth or last and only
                // when
                // monthly
                model.monthlyByDayOfWeek = dayOfWeek;
                model.monthlyByNthDayOfWeek = er.bydayNum[i];
                model.monthlyRepeat = RecurrenceModel.MONTHLY_BY_NTH_DAY_OF_WEEK;
                count++;
            }
        }
        if (model.freq == RecurrenceModel.FREQ_MONTHLY) {
            if (er.bydayCount != 1) {
                // Can't handle 1st Monday and 2nd Wed
                throw new IllegalStateException("Can handle only 1 byDayOfWeek in monthly");
            }
            if (count != 1) {
                throw new IllegalStateException("Didn't specify which nth day of week to repeat for a monthly");
            }
        }
    }
    // Monthly by day of month
    if (model.freq == RecurrenceModel.FREQ_MONTHLY) {
        if (er.bymonthdayCount == 1) {
            if (model.monthlyRepeat == RecurrenceModel.MONTHLY_BY_NTH_DAY_OF_WEEK) {
                throw new IllegalStateException("Can handle only by monthday or by nth day of week, not both");
            }
            model.monthlyByMonthDay = er.bymonthday[0];
            model.monthlyRepeat = RecurrenceModel.MONTHLY_BY_DATE;
        } else if (er.bymonthCount > 1) {
            // LIMITATION: Can handle only one month day
            throw new IllegalStateException("Can handle only one bymonthday");
        }
    }
}
Also used : Time(com.android.calendarcommon2.Time) TimeFormatException(android.util.TimeFormatException)

Aggregations

Time (com.android.calendarcommon2.Time)178 Paint (android.graphics.Paint)20 ArrayList (java.util.ArrayList)15 Time (org.bouncycastle.asn1.x509.Time)15 Intent (android.content.Intent)12 Uri (android.net.Uri)12 TextPaint (android.text.TextPaint)12 TextView (android.widget.TextView)12 Resources (android.content.res.Resources)10 ContentValues (android.content.ContentValues)8 Context (android.content.Context)8 Cursor (android.database.Cursor)8 View (android.view.View)8 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)8 EventRecurrence (com.android.calendarcommon2.EventRecurrence)8 DERSequence (org.bouncycastle.asn1.DERSequence)8 Date (java.util.Date)7 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)7 MotionEvent (android.view.MotionEvent)6 Calendar (java.util.Calendar)5