Example usage for org.eclipse.jgit.lib ObjectId fromRaw

List of usage examples for org.eclipse.jgit.lib ObjectId fromRaw

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib ObjectId fromRaw.

Prototype

public static final ObjectId fromRaw(int[] is) 

Source Link

Document

Convert an ObjectId from raw binary representation.

Usage

From source file:com.centurylink.mdw.dataaccess.file.VersionControlGit.java

License:Apache License

/**
 * Seems slightly slower than gitHash().
 *//*from  w  ww  . j  av a2s . c om*/
protected ObjectId gitHashJgit(File input) throws IOException {
    String path = getLogicalPath(input);
    String blob = "blob " + path.length() + "\0" + path;
    MessageDigest md = null;
    try {
        md = MessageDigest.getInstance("SHA-1");
        byte[] bytes = md.digest(blob.getBytes());
        return ObjectId.fromRaw(bytes);
    } catch (NoSuchAlgorithmException ex) {
        throw new IOException(ex.getMessage(), ex);
    }
}

From source file:com.google.gerrit.gpg.PublicKeyStore.java

License:Apache License

static ObjectId keyObjectId(long keyId) {
    byte[] buf = new byte[Constants.OBJECT_ID_LENGTH];
    NB.encodeInt64(buf, 0, keyId);//from   w  ww . j  a va  2 s .co m
    return ObjectId.fromRaw(buf);
}

From source file:com.google.gerrit.httpd.raw.CatServlet.java

License:Apache License

private String rand(final HttpServletRequest req, final String suffix) throws UnsupportedEncodingException {
    // Produce a random suffix that is difficult (or nearly impossible)
    // for an attacker to guess in advance. This reduces the risk that
    // an attacker could upload a *.class file and have us send a ZIP
    // that can be invoked through an applet tag in the victim's browser.
    ///*from   w  ww . j a v  a2 s .  c  o m*/
    final MessageDigest md = Constants.newMessageDigest();
    final byte[] buf = new byte[8];

    NB.encodeInt32(buf, 0, req.getRemotePort());
    md.update(req.getRemoteAddr().getBytes("UTF-8"));
    md.update(buf, 0, 4);

    NB.encodeInt64(buf, 0, TimeUtil.nowMs());
    md.update(buf, 0, 8);

    rng.nextBytes(buf);
    md.update(buf, 0, 8);

    return suffix + "-" + ObjectId.fromRaw(md.digest()).name();
}

From source file:com.google.gerrit.server.account.GroupUUID.java

License:Apache License

public static AccountGroup.UUID make(String groupName, PersonIdent creator) {
    MessageDigest md = Constants.newMessageDigest();
    md.update(Constants.encode("group " + groupName + "\n"));
    md.update(Constants.encode("creator " + creator.toExternalString() + "\n"));
    return new AccountGroup.UUID(ObjectId.fromRaw(md.digest()).name());
}

From source file:com.google.gerrit.server.git.gpg.PublicKeyStore.java

License:Apache License

static ObjectId keyObjectId(long keyId) {
    ByteBuffer buf = ByteBuffer.wrap(new byte[Constants.OBJECT_ID_LENGTH]);
    buf.putLong(keyId);/*  w  ww .j  ava 2s  .  co m*/
    return ObjectId.fromRaw(buf.array());
}

From source file:org.gitective.core.filter.commit.CommitImpact.java

License:Open Source License

/**
 * @return commit
 */
public ObjectId getCommit() {
    return ObjectId.fromRaw(commit);
}

From source file:org.gitective.core.stat.UserCommitActivity.java

License:Open Source License

/**
 * Get commits as array of object ids/*from  www.j  ava 2 s. c  o  m*/
 *
 * @return non-null but possibly empty array
 */
public ObjectId[] getIds() {
    final ObjectId[] ids = new ObjectId[index];
    for (int i = 0; i < index; i++)
        ids[i] = ObjectId.fromRaw(commits[i]);
    return ids;
}

From source file:org.gitective.core.stat.UserCommitActivity.java

License:Open Source License

/**
 * Get id of first commit
 *
 * @return commit id or null if no commits
 */
public ObjectId getFirst() {
    return index > 0 ? ObjectId.fromRaw(commits[index - 1]) : null;
}

From source file:org.gitective.core.stat.UserCommitActivity.java

License:Open Source License

/**
 * Get id of latest commit
 *
 * @return commit id or null if no commits
 */
public ObjectId getLast() {
    return index > 0 ? ObjectId.fromRaw(commits[0]) : null;
}

From source file:org.kuali.student.git.model.branch.utils.GitBranchUtils.java

License:Educational Community License

/**
 * Compute the objectid of the branch name given.
 * /* w  w  w  . j  av a  2s  . c  o m*/
 * @param branchName
 * @return
 */
public static ObjectId getBranchNameObjectId(String branchName) {

    try {
        MessageDigest md = MessageDigest.getInstance("SHA-1");

        byte[] branchNameBytes = Constants.encode(branchName);

        md.update(branchNameBytes);

        return ObjectId.fromRaw(md.digest());
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException("failed to get SHA-1 digest Message Digest.", e);
    }
}