/** * Returns Manifest-Attributes for MANIFEST.MF, if running for a .jar file * * @return Manifest Attributes (may be empty but never null) * @throws IOException If something went wrong finding the MANIFEST file * @see <a href="http://stackoverflow.com/a/1273432">stackoverflow article</a> */ private static Attributes getAttributes() throws IOException { Class clazz = BuildInfoReader.class; String className = clazz.getSimpleName() + ".class"; String classPath = clazz.getResource(className).toString(); if (!classPath.startsWith("jar")) { // Class not from JAR return new Attributes(0); } String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + FILE_NAME; Manifest manifest = new Manifest(new URL(manifestPath).openStream()); return manifest.getMainAttributes(); }
attr = input.getAttributes(name); attr = attr != null ? new Attributes(attr) : new Attributes(); attr.putValue(digName, encodeBase64(md.digest())); output.getEntries().put(name, attr);
Attributes mainAttrs = new Attributes(); for (String entryName : sortedEntryNames) { byte[] entryDigest = jarEntryDigests.get(entryName); Attributes entryAttrs = new Attributes(); entryAttrs.putValue( entryDigestAttributeName,
byte[] sectionContents = manifestSection.getValue(); byte[] sectionDigest = md.digest(sectionContents); Attributes attrs = new Attributes(); attrs.putValue( entryDigestAttributeName,
final JavaClass clazz = (JavaClass)classes.nextElement(); final String className = clazz.getClassName().replace('.','/'); final java.util.jar.Attributes attr = new java.util.jar.Attributes(); attr.put(dateAttr, now); map.put(className+".class", attr);
public void readEntries(Map<String, Attributes> entries, Map<String, Manifest.Chunk> chunks) throws IOException { int mark = pos; while (readHeader()) { if (!Attributes.Name.NAME.equals(name)) { throw new IOException("Entry is not named"); } String entryNameValue = value; Attributes entry = entries.get(entryNameValue); if (entry == null) { entry = new Attributes(12); } while (readHeader()) { entry.put(name, value); } if (chunks != null) { if (chunks.get(entryNameValue) != null) { // TODO A bug: there might be several verification chunks for // the same name. I believe they should be used to update // signature in order of appearance; there are two ways to fix // this: either use a list of chunks, or decide on used // signature algorithm in advance and reread the chunks while // updating the signature; for now a defensive error is thrown throw new IOException("A jar verifier does not support more than one entry with the same name"); } chunks.put(entryNameValue, new Manifest.Chunk(mark, pos)); mark = pos; } entries.put(entryNameValue, entry); } }
print.flush(); Attributes sfAttr = new Attributes(); sfAttr.putValue(digName, encodeBase64(md.digest())); sf.getEntries().put(entry.getKey(), sfAttr);
Attributes temp = new Attributes(3); temp.map.put("hidden", null); mEntry.setAttributes(temp);
Attributes attributes = new Attributes(); HashMap<String, Attributes> entries = new HashMap<String, Attributes>(); try {
private Attributes getOrCreateAttributes( String name ) { Attributes attributes = getAttributes( name ); if ( attributes == null ) { attributes = new Attributes(); getEntries().put( name, attributes ); } return attributes; }
/** * Creates a new manifest entry (attributes) for the given name */ public void addEntry(String entryName) { Attributes attr = new Attributes(); addEntry(entryName, attr); }
Attributes attrs = new BasicAttributes(true); attr = new BasicAttribute("PTR"); attr.add(0, "eg-www.apple.com."); attr.add(1, "www.apple.com."); attrs.put(attr);
@Override public void run() { Manifest manifest = new Manifest(); Attributes attributes = new Attributes(); attributes.put(VERSION_ATTRIBUTE, String.valueOf(expectedCacheVersion)); manifest.getEntries().put("robolectric", attributes); saveAllClassesToCache(cacheJarFile, manifest); } });
String DN = "cn="+a.get("cn").replaceAll(" ","")+",ou=Users"+",dc=example,dc=com"; Attribute dn = new BasicAttribute("dn",DN); Attribute cn = new BasicAttribute("cn",a.get("cn")); Attribute objectClass = new BasicAttribute("objectClass", "inetOrgPerson"); ... Attributes atts = new BasicAttributes(); atts.put(dn); atts.put(cn); atts.put(objectClass); ctx.createSubcontext(DN, atts);
@Override void includeAttribute(Name attribute, String value) { Map<String, Attributes> entries = manifest.getEntries(); Attributes attributes = entries.containsKey(entryName) ? manifest.getAttributes(entryName) : new Attributes(); attributes.put(attribute, value); entries.put(entryName, attributes); }
@Override void includeAttribute(Name attribute, String value) { Map<String, Attributes> entries = manifest.getEntries(); Attributes attributes = entries.containsKey(entryName) ? manifest.getAttributes(entryName) : new Attributes(); attributes.put(attribute, value); entries.put(entryName, attributes); }
public Attributes getManifestAttributes(boolean fixPackage) { Attributes a = new Attributes(); a.putValue("Bundle-SymbolicName", getSymbolicName()); a.putValue("Bundle-Version", getVersion()); return a; }
public Attributes getRawAttributes() { Attributes _attributes = new Attributes(); _attributes.putAll(attributes); _attributes.putAll(directives); return _attributes; } }
public Attributes getRawAttributes() { Attributes _attributes = new Attributes(); _attributes.putAll(attributes); _attributes.putAll(directives); return _attributes; } }
private static Manifest createManifest(Object...entries) { Preconditions.checkArgument(entries.length % 2 == 0); Attributes attributes = new Attributes(); for (int i = 0; i < entries.length; i += 2) { attributes.put(entries[i], entries[i + 1]); } Manifest manifest = new Manifest(); manifest.getMainAttributes().putAll(attributes); return manifest; } }