Package com.yworks.yguard.obf
Class GuardDB
- java.lang.Object
-
- com.yworks.yguard.obf.GuardDB
-
- All Implemented Interfaces:
ClassConstants
public class GuardDB extends java.lang.Object implements ClassConstants
Classfile database for obfuscation.
-
-
Field Summary
-
Fields inherited from interface com.yworks.yguard.obf.classfile.ClassConstants
ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ATTR_AnnotationDefault, ATTR_BootstrapMethods, ATTR_Bridge, ATTR_Code, ATTR_ConstantValue, ATTR_Deprecated, ATTR_EnclosingMethod, ATTR_Enum, ATTR_Exceptions, ATTR_InnerClasses, ATTR_LineNumberTable, ATTR_LocalVariableTable, ATTR_LocalVariableTypeTable, ATTR_MethodParameters, ATTR_Module, ATTR_ModuleMainClass, ATTR_ModulePackages, ATTR_NestHost, ATTR_NestMembers, ATTR_PermittedSubclasses, ATTR_Record, ATTR_RuntimeInvisibleAnnotations, ATTR_RuntimeInvisibleParameterAnnotations, ATTR_RuntimeInvisibleTypeAnnotations, ATTR_RuntimeVisibleAnnotations, ATTR_RuntimeVisibleParameterAnnotations, ATTR_RuntimeVisibleTypeAnnotations, ATTR_Signature, ATTR_SourceDebug, ATTR_SourceDebugExtension, ATTR_SourceFile, ATTR_StackMapTable, ATTR_Synthetic, ATTR_Unknown, ATTR_Varargs, CONSTANT_Class, CONSTANT_Double, CONSTANT_Dynamic, CONSTANT_Fieldref, CONSTANT_Float, CONSTANT_Integer, CONSTANT_InterfaceMethodref, CONSTANT_InvokeDynamic, CONSTANT_Long, CONSTANT_MethodHandle, CONSTANT_Methodref, CONSTANT_MethodType, CONSTANT_Module, CONSTANT_NameAndType, CONSTANT_Package, CONSTANT_String, CONSTANT_Utf8, KNOWN_ATTRS, MAGIC, MAJOR_VERSION, MINOR_VERSION_MAX, REF_getField, REF_getStatic, REF_invokeInterface, REF_invokeSpecial, REF_invokeStatic, REF_invokeVirtual, REF_newInvokeSpecial, REF_putField, REF_putStatic, REQUIRED_ATTRS
-
-
Constructor Summary
Constructors Constructor Description GuardDB(java.io.File[] inFile)A classfile database for obfuscation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(ObfuscationListener listener)Registers Listener to receive events.voidclose()Close input JAR file.protected voidfinalize()Close input JAR file and log-file at GC-time.protected voidfireObfuscatingClass(java.lang.String className)Fire obfuscating class.protected voidfireObfuscatingJar(java.lang.String inJar, java.lang.String outJar)Fire obfuscating jar.protected voidfireParsingClass(java.lang.String className)Fire parsing class.protected voidfireParsingJar(java.lang.String jar)Fire parsing jar.java.lang.StringgetOutName(java.lang.String inName)Gets out name.booleanisPedantic()Getter for property pedantic.booleanisReplaceClassNameStrings()Getter for property replaceClassNameStrings.voidremapTo(java.io.File[] out, Filter fileFilter, java.io.PrintWriter log, boolean conserveManifest)Remap each class based on the remap database, and remove attributes.voidremoveListener(ObfuscationListener listener)Removes Listener from the list of listeners.voidretain(java.util.Collection rgsEntries, java.io.PrintWriter log)Go through database marking certain entities for retention, while maintaining polymorphic integrity.voidsetAnnotationClass(java.lang.String annotationClass)Sets annotation class.voidsetDigests(java.lang.String[] digestStrings)Sets digests.voidsetPedantic(boolean pedantic)Setter for property pedantic.voidsetReplaceClassNameStrings(boolean replaceClassNameStrings)Setter for property replaceClassNameStrings.voidsetResourceHandler(ResourceHandler handler)Sets resource handler.java.lang.StringtranslateItem(java.lang.String identifier, char seperator, boolean strict)Translates the given class or package identifier.java.lang.StringtranslateJavaClass(java.lang.String javaClass)Translate java class string.java.lang.StringtranslateJavaFile(java.lang.String javaClass)Returns the obfuscated file name of the java class.
-
-
-
Method Detail
-
finalize
protected void finalize() throws java.io.IOExceptionClose input JAR file and log-file at GC-time.- Overrides:
finalizein classjava.lang.Object- Throws:
java.io.IOException
-
setResourceHandler
public void setResourceHandler(ResourceHandler handler)
Sets resource handler.- Parameters:
handler- the handler
-
getOutName
public java.lang.String getOutName(java.lang.String inName)
Gets out name.- Parameters:
inName- the in name- Returns:
- the out name
-
retain
public void retain(java.util.Collection rgsEntries, java.io.PrintWriter log) throws java.io.IOExceptionGo through database marking certain entities for retention, while maintaining polymorphic integrity.- Parameters:
rgsEntries- the rgs entrieslog- the log- Throws:
java.io.IOException- the io exception
-
remapTo
public void remapTo(java.io.File[] out, Filter fileFilter, java.io.PrintWriter log, boolean conserveManifest) throws java.io.IOException, java.lang.ClassNotFoundExceptionRemap each class based on the remap database, and remove attributes.- Parameters:
out- the outfileFilter- the file filterlog- the logconserveManifest- the conserve manifest- Throws:
java.io.IOException- the io exceptionjava.lang.ClassNotFoundException- the class not found exception
-
close
public void close() throws java.io.IOExceptionClose input JAR file. @throws IOException the io exception- Throws:
java.io.IOException- the io exception
-
fireParsingJar
protected void fireParsingJar(java.lang.String jar)
Fire parsing jar.- Parameters:
jar- the jar
-
fireParsingClass
protected void fireParsingClass(java.lang.String className)
Fire parsing class.- Parameters:
className- the class name
-
fireObfuscatingJar
protected void fireObfuscatingJar(java.lang.String inJar, java.lang.String outJar)Fire obfuscating jar.- Parameters:
inJar- the in jaroutJar- the out jar
-
fireObfuscatingClass
protected void fireObfuscatingClass(java.lang.String className)
Fire obfuscating class.- Parameters:
className- the class name
-
addListener
public void addListener(ObfuscationListener listener)
Registers Listener to receive events.- Parameters:
listener- The listener to register.
-
removeListener
public void removeListener(ObfuscationListener listener)
Removes Listener from the list of listeners.- Parameters:
listener- The listener to remove.
-
isReplaceClassNameStrings
public boolean isReplaceClassNameStrings()
Getter for property replaceClassNameStrings.- Returns:
- Value of property replaceClassNameStrings.
-
setReplaceClassNameStrings
public void setReplaceClassNameStrings(boolean replaceClassNameStrings)
Setter for property replaceClassNameStrings.- Parameters:
replaceClassNameStrings- New value of property replaceClassNameStrings.
-
isPedantic
public boolean isPedantic()
Getter for property pedantic.- Returns:
- Value of property pedantic.
-
setPedantic
public void setPedantic(boolean pedantic)
Setter for property pedantic.- Parameters:
pedantic- New value of property pedantic.
-
translateJavaFile
public java.lang.String translateJavaFile(java.lang.String javaClass)
Returns the obfuscated file name of the java class. The ending ".class" is omitted.- Parameters:
javaClass- the fully qualified name of an unobfuscated class.- Returns:
- the string
-
translateJavaClass
public java.lang.String translateJavaClass(java.lang.String javaClass)
Translate java class string.- Parameters:
javaClass- the java class- Returns:
- the string
-
translateItem
public java.lang.String translateItem(java.lang.String identifier, char seperator, boolean strict)Translates the given class or package identifier.- Parameters:
identifier- a qualified class name or a jar entry name.strict- iftrue, translate the whole identifier only; otherwise translate as much of the given identifier as possible.- Returns:
- the mapped identifier.
-
setDigests
public void setDigests(java.lang.String[] digestStrings)
Sets digests.- Parameters:
digestStrings- the digest strings
-
setAnnotationClass
public void setAnnotationClass(java.lang.String annotationClass)
Sets annotation class.- Parameters:
annotationClass- the annotation class
-
-