当前位置: 首页>>代码示例>>Java>>正文


Java Utils.calcFingerprint方法代码示例

本文整理汇总了Java中org.fdroid.fdroid.Utils.calcFingerprint方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.calcFingerprint方法的具体用法?Java Utils.calcFingerprint怎么用?Java Utils.calcFingerprint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.fdroid.fdroid.Utils的用法示例。


在下文中一共展示了Utils.calcFingerprint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertRepos

import org.fdroid.fdroid.Utils; //导入方法依赖的package包/类
private void insertRepos(SQLiteDatabase db) {
    String pubKey = "3082035e30820246a00302010202044c49cd00300d06092a864886f70d01010505003071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b73301e170d3130303732333137313032345a170d3337313230383137313032345a3071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b7330820122300d06092a864886f70d01010105000382010f003082010a028201010096d075e47c014e7822c89fd67f795d23203e2a8843f53ba4e6b1bf5f2fd0e225938267cfcae7fbf4fe596346afbaf4070fdb91f66fbcdf2348a3d92430502824f80517b156fab00809bdc8e631bfa9afd42d9045ab5fd6d28d9e140afc1300917b19b7c6c4df4a494cf1f7cb4a63c80d734265d735af9e4f09455f427aa65a53563f87b336ca2c19d244fcbba617ba0b19e56ed34afe0b253ab91e2fdb1271f1b9e3c3232027ed8862a112f0706e234cf236914b939bcf959821ecb2a6c18057e070de3428046d94b175e1d89bd795e535499a091f5bc65a79d539a8d43891ec504058acb28c08393b5718b57600a211e803f4a634e5c57f25b9b8c4422c6fd90203010001300d06092a864886f70d0101050500038201010008e4ef699e9807677ff56753da73efb2390d5ae2c17e4db691d5df7a7b60fc071ae509c5414be7d5da74df2811e83d3668c4a0b1abc84b9fa7d96b4cdf30bba68517ad2a93e233b042972ac0553a4801c9ebe07bf57ebe9a3b3d6d663965260e50f3b8f46db0531761e60340a2bddc3426098397fda54044a17e5244549f9869b460ca5e6e216b6f6a2db0580b480ca2afe6ec6b46eedacfa4aa45038809ece0c5978653d6c85f678e7f5a2156d1bedd8117751e64a4b0dcd140f3040b021821a8d93aed8d01ba36db6c82372211fed714d9a32607038cdfd565bd529ffc637212aaa2c224ef22b603eccefb5bf1e085c191d4b24fe742b17ab3f55d4e6f05ef"; // NOCHECKSTYLE LineLength
    String fingerprint = Utils.calcFingerprint(pubKey);

    ContentValues fdroidValues = new ContentValues();
    fdroidValues.put("address", "https://f-droid.org/repo");
    fdroidValues.put("name", "F-Droid");
    fdroidValues.put("description", "The official FDroid repository. Applications in this repository are mostly built directory from the source code. Some are official binaries built by the original application developers - these will be replaced by source-built versions over time."); // NOCHECKSTYLE LineLength
    fdroidValues.put("pubkey", pubKey);
    fdroidValues.put("fingerprint", fingerprint);
    fdroidValues.put("maxage", 0);
    fdroidValues.put("inuse", 1);
    fdroidValues.put("priority", 10);
    fdroidValues.put("lastetag", (String) null);
    db.insert(TABLE_REPO, null, fdroidValues);

    ContentValues archiveValues = new ContentValues();
    archiveValues.put("address", "https://f-droid.org/archive");
    archiveValues.put("name", "F-Droid Archive");
    archiveValues.put("description", "The archive repository of the F-Droid client. This contains older versions of applications from the main repository."); // NOCHECKSTYLE LineLength
    archiveValues.put("pubkey", pubKey);
    archiveValues.put("fingerprint", fingerprint);
    archiveValues.put("maxage", 0);
    archiveValues.put("inuse", 0);
    archiveValues.put("priority", 20);
    archiveValues.put("lastetag", (String) null);
    db.insert(TABLE_REPO, null, archiveValues);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:29,代码来源:DatabaseMigration.java

示例2: update

import org.fdroid.fdroid.Utils; //导入方法依赖的package包/类
/**
 * Updates the repo metadata in the database.  All data comes from the
 * index file except {@link Repo#id}, which is generated by the database.
 * That makes for an two cycle workflow, where first this must be called
 * to fetch the {@code Repo.id} from the database, then it is called a
 * second time to actually set the repo metadata.
 */
public static void update(Context context, Repo repo, ContentValues values) {
    ContentResolver resolver = context.getContentResolver();

    // Change the name to the new address. Next time we update the repo
    // index file, it will populate the name field with the proper
    // name, but the best we can do is guess right now.
    if (values.containsKey(Cols.ADDRESS) &&
            !values.containsKey(Cols.NAME)) {
        String name = Repo.addressToName(values.getAsString(Cols.ADDRESS));
        values.put(Cols.NAME, name);
    }

    /*
     * If the repo is signed and has a public key, then guarantee that
     * the fingerprint is also set. The stored fingerprint is checked
     * when a repo URI is received by FDroid to prevent bad actors from
     * overriding repo configs with other keys. So if the fingerprint is
     * not stored yet, calculate it and store it. If the fingerprint is
     * stored, then check it against the calculated fingerprint just to
     * make sure it is correct. If the fingerprint is empty, then store
     * the calculated one.
     */
    if (values.containsKey(Cols.SIGNING_CERT)) {
        String publicKey = values.getAsString(Cols.SIGNING_CERT);
        String calcedFingerprint = Utils.calcFingerprint(publicKey);
        if (values.containsKey(Cols.FINGERPRINT)) {
            String fingerprint = values.getAsString(Cols.FINGERPRINT);
            if (!TextUtils.isEmpty(publicKey)) {
                if (TextUtils.isEmpty(fingerprint)) {
                    values.put(Cols.FINGERPRINT, calcedFingerprint);
                } else if (!fingerprint.equals(calcedFingerprint)) {
                    // TODO the UI should represent this error!
                    Log.e(TAG, "The stored and calculated fingerprints do not match!");
                    Log.e(TAG, "Stored: " + fingerprint);
                    Log.e(TAG, "Calculated: " + calcedFingerprint);
                }
            }
        } else if (!TextUtils.isEmpty(publicKey)) {
            // no fingerprint in 'values', so put one there
            values.put(Cols.FINGERPRINT, calcedFingerprint);
        }
    }

    if (values.containsKey(Cols.IN_USE)) {
        Integer inUse = values.getAsInteger(Cols.IN_USE);
        if (inUse != null && inUse == 0) {
            values.put(Cols.LAST_ETAG, (String) null);
        }
    }

    final Uri uri = getContentUri(repo.getId());
    final String[] args = {Long.toString(repo.getId())};
    resolver.update(uri, values, Cols._ID + " = ?", args);
    repo.setValues(values);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:63,代码来源:RepoProvider.java


注:本文中的org.fdroid.fdroid.Utils.calcFingerprint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。