proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
apache_pdfbox | pdfbox/pdfbox/src/main/java/org/apache/pdfbox/util/filetypedetector/FileTypeDetector.java | FileTypeDetector | detectFileType | class FileTypeDetector
{
private static final ByteTrie<FileType> root;
static
{
root = new ByteTrie<>();
root.setDefaultValue(FileType.UNKNOWN);
// https://en.wikipedia.org/wiki/List_of_file_signatures
root.addPath(FileType.JPEG, new byte[]{(byte)0xff, (byte)0xd8});
... |
if (!inputStream.markSupported())
{
throw new IOException("Stream must support mark/reset");
}
int maxByteCount = root.getMaxDepth();
inputStream.mark(maxByteCount);
byte[] bytes = new byte[maxByteCount];
int bytesRead = inputStream.read(bytes);
... | 1,431 | 148 | 1,579 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/DecompressObjectstreams.java | DecompressObjectstreams | main | class DecompressObjectstreams implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = {"-h", "--help"}, usageHelp = true, description = "display this help message")
boolean usageHelpRe... |
// suppress the Dock icon on OS X
System.setProperty("apple.awt.UIElement", "true");
int exitCode = new CommandLine(new DecompressObjectstreams()).execute(args);
System.exit(exitCode);
| 430 | 63 | 493 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/Decrypt.java | Decrypt | call | class Decrypt implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = "-alias", description = "the alias to the certificate in the keystore.")
private String alias;
@Option(names ... |
try (InputStream keyStoreStream = keyStore == null ? null : new FileInputStream(keyStore);
PDDocument document = Loader.loadPDF(infile, password, keyStoreStream, alias))
{
// overwrite inputfile if no outputfile was specified
if (outfile == null) {
... | 447 | 294 | 741 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/Encrypt.java | Encrypt | call | class Encrypt implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = "-O", description = "set the owner password (ignored if certFile is set)", arity = "0..1", interactive = true)
pri... |
AccessPermission ap = new AccessPermission();
ap.setCanAssembleDocument(canAssembleDocument);
ap.setCanExtractContent(canExtractContent);
ap.setCanExtractForAccessibility(canExtractForAccessibility);
ap.setCanFillInForm(canFillInForm);
ap.setCanModify(canModify);
... | 848 | 602 | 1,450 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/ExportFDF.java | ExportFDF | call | class ExportFDF implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = {"-i", "--input"}, description = "the PDF file to export", required = true)
private File infile;
@Option(na... |
try (PDDocument pdf = Loader.loadPDF(infile))
{
PDAcroForm form = pdf.getDocumentCatalog().getAcroForm();
if( form == null )
{
SYSERR.println( "Error: This PDF does not contain a form." );
return 1;
}
else
... | 306 | 244 | 550 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/ExportXFDF.java | ExportXFDF | call | class ExportXFDF implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = {"-i", "--input"}, description = "the PDF file to export", required = true)
private File infile;
@Option(n... |
try (PDDocument pdf = Loader.loadPDF(infile))
{
PDAcroForm form = pdf.getDocumentCatalog().getAcroForm();
if( form == null )
{
SYSERR.println( "Error: This PDF does not contain a form." );
}
else
{
i... | 310 | 244 | 554 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/ExtractXMP.java | ExtractXMP | call | class ExtractXMP implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSOUT;
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@CommandLine.Option(names = "-page", description = "extra... |
if (outfile == null)
{
String outPath = FilenameUtils.removeExtension(infile.getAbsolutePath()) + ".xml";
outfile = new File(outPath);
}
try (PDDocument document = Loader.loadPDF(infile, password))
{
PDDocumentCatalog catalog = docume... | 487 | 336 | 823 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/ImageToPDF.java | ImageToPDF | createRectangle | class ImageToPDF implements Callable<Integer>
{
private PDRectangle mediaBox = PDRectangle.LETTER;
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = "-autoOrientation", description = "set orientation dependin... |
if ("letter".equalsIgnoreCase(paperSize))
{
return PDRectangle.LETTER;
}
else if ("legal".equalsIgnoreCase(paperSize))
{
return PDRectangle.LEGAL;
}
else if ("A0".equalsIgnoreCase(paperSize))
{
return PDRectangle.A0;
... | 1,208 | 320 | 1,528 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/ImportFDF.java | ImportFDF | call | class ImportFDF implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = {"-i", "--input"}, description = "the PDF file to import to", required = true)
private File infile;
@Op... |
ImportFDF importer = new ImportFDF();
try (PDDocument pdf = Loader.loadPDF(infile);
FDFDocument fdf = Loader.loadFDF(fdffile))
{
importer.importFDF( pdf, fdf );
if (outfile == null)
{
outfile = infile;
}
... | 591 | 171 | 762 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/ImportXFDF.java | ImportXFDF | call | class ImportXFDF implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = {"-i", "--input"}, description = "the PDF file to import to", required = true)
private File infile;
@Optio... |
ImportXFDF importer = new ImportXFDF();
try (PDDocument pdf = Loader.loadPDF(infile);
FDFDocument fdf = Loader.loadXFDF(xfdffile))
{
importer.importFDF( pdf, fdf );
if (outfile == null)
{
outfile = infile;
}
... | 544 | 175 | 719 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/OverlayPDF.java | OverlayPDF | call | class OverlayPDF implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = "-odd", description = "overlay file used for odd pages")
private File oddPageOverlay;
@Option(names = "-ev... |
int retcode = 0;
Overlay overlayer = new Overlay();
overlayer.setOverlayPosition(position);
if (firstPageOverlay != null)
{
overlayer.setFirstPageOverlayFile(firstPageOverlay.getAbsolutePath());
}
if (lastPageOverlay != null)
{
... | 599 | 531 | 1,130 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/PDFBox.java | PDFBox | main | class PDFBox implements Runnable
{
@Spec CommandLine.Model.CommandSpec spec;
/**
* Main method.
*
* @param args command line arguments
*/
public static void main(String[] args)
{<FILL_FUNCTION_BODY>}
@Override
public void run()
{
throw new ParameterException(... |
// suppress the Dock icon on OS X
System.setProperty("apple.awt.UIElement", "true");
CommandLine commandLine = new CommandLine(new PDFBox()).setSubcommandsCaseInsensitive(true);
if (!GraphicsEnvironment.isHeadless())
{
commandLine.addSubcommand("debug", PDFDebugger.... | 114 | 452 | 566 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/PDFMerger.java | PDFMerger | main | class PDFMerger implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = {"-i", "--input"}, description = "the PDF files to merge.", paramLabel = "<infile>", required = true)
private Fi... |
// suppress the Dock icon on OS X
System.setProperty("apple.awt.UIElement", "true");
int exitCode = new CommandLine(new PDFMerger()).execute(args);
System.exit(exitCode);
| 410 | 61 | 471 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/PDFSplit.java | PDFSplit | call | class PDFSplit implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = "-password", description = "the password to decrypt the document.", arity = "0..1", interactive = true)
priva... |
Splitter splitter = new Splitter();
if (outputPrefix == null)
{
outputPrefix = FilenameUtils.removeExtension(infile.getAbsolutePath());
}
List<PDDocument> documents = null;
try (PDDocument document = Loader.loadPDF(infile, password))
{
... | 438 | 493 | 931 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/PDFText2HTML.java | FontState | closeUntil | class FontState
{
private final List<String> stateList = new ArrayList<>();
private final Set<String> stateSet = new HashSet<>();
/**
* Pushes new {@link TextPosition TextPositions} into the font state. The state is only
* preserved correctly for each letter if the number ... |
for (int i = stateList.size(); i-- > 0;)
{
String tag = stateList.get(i);
tagsBuilder.append(closeTag(tag));
if (endTag != null && tag.equals(endTag))
{
return i;
}
}
retu... | 1,082 | 84 | 1,166 | <methods>public void <init>() ,public boolean getAddMoreFormatting() ,public java.lang.String getArticleEnd() ,public java.lang.String getArticleStart() ,public float getAverageCharTolerance() ,public float getDropThreshold() ,public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getEndB... |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/PDFText2Markdown.java | FontState | isItalic | class FontState
{
private final List<String> stateList = new ArrayList<>();
private final Set<String> stateSet = new HashSet<>();
/**
* Pushes new {@link TextPosition TextPositions} into the font state. The state is only
* preserved correctly for each letter if the number ... |
if (descriptor.isItalic())
{
return true;
}
String fontName = descriptor.getFontName().toLowerCase();
return fontName.contains("italic") || fontName.contains("oblique");
| 1,126 | 63 | 1,189 | <methods>public void <init>() ,public boolean getAddMoreFormatting() ,public java.lang.String getArticleEnd() ,public java.lang.String getArticleStart() ,public float getAverageCharTolerance() ,public float getDropThreshold() ,public org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem getEndB... |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java | PDFToImage | call | class PDFToImage implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = "-password", description = "the password to decrypt the document", arity = "0..1", interactive = true)
private ... |
if (outputPrefix == null)
{
outputPrefix = FilenameUtils.removeExtension(infile.getAbsolutePath());
}
if (!List.of(ImageIO.getWriterFormatNames()).contains(imageFormat))
{
SYSERR.println("Error: Invalid image format " + imageFormat + " - supported format... | 885 | 730 | 1,615 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/Version.java | Version | main | class Version implements Callable<Integer>, IVersionProvider
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSOUT;
@Spec CommandSpec spec;
/**
* Get the version of PDFBox or unknown if it is not known.
*
* @retu... |
// suppress the Dock icon on OS X
System.setProperty("apple.awt.UIElement", "true");
int exitCode = new CommandLine(new Version()).execute(args);
System.exit(exitCode);
| 333 | 59 | 392 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/WriteDecodedDoc.java | WriteDecodedDoc | processObject | class WriteDecodedDoc implements Callable<Integer>
{
// Expected for CLI app to write to System.out/System.err
@SuppressWarnings("squid:S106")
private final PrintStream SYSERR;
@Option(names = "-password", description = "the password to decrypt the document", arity = "0..1", interactive = true)
pri... |
COSBase base = cosObject.getObject();
if (base instanceof COSStream)
{
COSStream stream = (COSStream) base;
if (skipImages && COSName.XOBJECT.equals(stream.getItem(COSName.TYPE))
&& COSName.IMAGE.equals(stream.getItem(COSName.SUBTYPE)))
{
... | 931 | 218 | 1,149 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/imageio/JPEGUtil.java | JPEGUtil | updateMetadata | class JPEGUtil
{
private JPEGUtil()
{
}
/**
* Set dpi in a JPEG file
*
* @param metadata the meta data
* @param dpi the dpi
*
* @throws IIOInvalidTreeException if something goes wrong
*/
static void updateMetadata(IIOMetadata metadata, int dpi) throws IIOInval... |
MetaUtil.debugLogMetadata(metadata, MetaUtil.JPEG_NATIVE_FORMAT);
// https://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java
// http://docs.oracle.com/javase/6/docs/api/javax/imageio/metadata/doc-files/jpeg_metada... | 121 | 628 | 749 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/imageio/MetaUtil.java | MetaUtil | debugLogMetadata | class MetaUtil
{
private static final Logger LOG = LogManager.getLogger(MetaUtil.class);
static final String SUN_TIFF_FORMAT = "com_sun_media_imageio_plugins_tiff_image_1.0";
static final String JPEG_NATIVE_FORMAT = "javax_imageio_jpeg_image_1.0";
static final String STANDARD_METADATA_FORMAT = "javax_i... |
if (!LOG.isDebugEnabled())
{
return;
}
// see http://docs.oracle.com/javase/7/docs/api/javax/imageio/
// metadata/doc-files/standard_metadata.html
IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(format);
try
{
Stri... | 185 | 366 | 551 | <no_super_class> |
apache_pdfbox | pdfbox/tools/src/main/java/org/apache/pdfbox/tools/imageio/TIFFUtil.java | TIFFUtil | createRationalField | class TIFFUtil
{
private static final Logger LOG = LogManager.getLogger(TIFFUtil.class);
private TIFFUtil()
{
}
/**
* Sets the ImageIO parameter compression type based on the given image.
* @param image buffered image used to decide compression type
* @param param ImageIO write ... |
IIOMetadataNode field, arrayNode, valueNode;
field = new IIOMetadataNode("TIFFField");
field.setAttribute("number", Integer.toString(number));
field.setAttribute("name", name);
arrayNode = new IIOMetadataNode("TIFFRationals");
field.appendChild(arrayNode);
valueN... | 1,593 | 139 | 1,732 | <no_super_class> |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/schema/AdobePDFSchema.java | AdobePDFSchema | getPDFVersionProperty | class AdobePDFSchema extends XMPSchema
{
@PropertyType(type = Types.Text, card = Cardinality.Simple)
public static final String KEYWORDS = "Keywords";
@PropertyType(type = Types.Text, card = Cardinality.Simple)
public static final String PDF_VERSION = "PDFVersion";
@PropertyType(type = Types.Text... |
AbstractField tmp = getProperty(PDF_VERSION);
if (tmp instanceof TextType)
{
return (TextType) tmp;
}
return null;
| 1,173 | 45 | 1,218 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String, java.lang.String) ,public void <init>(org.apache.xmpbox.XMPMetadata) ,public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String) ,public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String) ... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/schema/PDFAIdentificationSchema.java | PDFAIdentificationSchema | setConformanceProperty | class PDFAIdentificationSchema extends XMPSchema
{
@PropertyType(type = Types.Integer, card = Cardinality.Simple)
public static final String PART = "part";
@PropertyType(type = Types.Text, card = Cardinality.Simple)
public static final String AMD = "amd";
@PropertyType(type = Types.Text, card = C... |
String value = conf.getStringValue();
if (value.equals("A") || value.equals("B") || value.equals("U"))
{
addProperty(conf);
}
else
{
throw new BadFieldValueException(
"The property given not seems to be a PDF/A conformance leve... | 1,803 | 95 | 1,898 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String, java.lang.String) ,public void <init>(org.apache.xmpbox.XMPMetadata) ,public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String) ,public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String) ... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPBasicJobTicketSchema.java | XMPBasicJobTicketSchema | addJob | class XMPBasicJobTicketSchema extends XMPSchema
{
@PropertyType(type = Types.Job, card = Cardinality.Bag)
public static final String JOB_REF = "JobRef";
private ArrayProperty bagJobs;
public XMPBasicJobTicketSchema(XMPMetadata metadata)
{
this(metadata, null);
}
public XMPBasicJo... |
JobType job = new JobType(getMetadata(), fieldPrefix);
job.setId(id);
job.setName(name);
job.setUrl(url);
addJob(job);
| 541 | 53 | 594 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String, java.lang.String) ,public void <init>(org.apache.xmpbox.XMPMetadata) ,public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String) ,public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String) ... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPSchemaFactory.java | XMPSchemaFactory | createXMPSchema | class XMPSchemaFactory
{
private final String namespace;
private final Class<? extends XMPSchema> schemaClass;
private final PropertiesDescription propDef;
/**
* Factory Constructor for basic known schemas
*
* @param namespace
* namespace URI to treat
* @param sc... |
XMPSchema schema;
Class<?>[] argsClass;
Object[] schemaArgs;
if (schemaClass == XMPSchema.class)
{
argsClass = new Class[] { XMPMetadata.class, String.class, String.class };
schemaArgs = new Object[] { metadata, namespace, prefix };
}
els... | 467 | 253 | 720 | <no_super_class> |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractComplexProperty.java | AbstractComplexProperty | addProperty | class AbstractComplexProperty extends AbstractField
{
private final ComplexPropertyContainer container;
private final Map<String, String> namespaceToPrefix;
public AbstractComplexProperty(XMPMetadata metadata, String propertyName)
{
super(metadata, propertyName);
container = new Compl... |
// https://www.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/cs6/XMPSpecificationPart1.pdf
// "Each property name in an XMP packet shall be unique within that packet"
// "Multiple values are represented using an XMP array value"
// "The nested element's element content shall consist of... | 632 | 172 | 804 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String) ,public final boolean containsAttribute(java.lang.String) ,public final List<org.apache.xmpbox.type.Attribute> getAllAttributes() ,public final org.apache.xmpbox.type.Attribute getAttribute(java.lang.String) ,public final org.apache.xmpbox.XMP... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractSimpleProperty.java | AbstractSimpleProperty | toString | class AbstractSimpleProperty extends AbstractField
{
private final String namespace;
private final String prefix;
private final Object rawValue;
/**
* Property specific type constructor (namespaceURI is given)
*
* @param metadata
* The metadata to attach to this p... |
return "[" + this.getClass().getSimpleName() + ":" + getStringValue() + "]";
| 552 | 30 | 582 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String) ,public final boolean containsAttribute(java.lang.String) ,public final List<org.apache.xmpbox.type.Attribute> getAllAttributes() ,public final org.apache.xmpbox.type.Attribute getAttribute(java.lang.String) ,public final org.apache.xmpbox.XMP... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/AbstractStructuredType.java | AbstractStructuredType | addSimpleProperty | class AbstractStructuredType extends AbstractComplexProperty
{
protected static final String STRUCTURE_ARRAY_NAME = "li";
private String namespace;
private String preferedPrefix;
private String prefix;
public AbstractStructuredType(XMPMetadata metadata)
{
this(metadata, null, null, ... |
TypeMapping tm = getMetadata().getTypeMapping();
AbstractSimpleProperty asp = tm.instanciateSimpleField(getClass(), null, getPrefix(), propertyName, value);
addProperty(asp);
| 892 | 53 | 945 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String) ,public void addNamespace(java.lang.String, java.lang.String) ,public final void addProperty(org.apache.xmpbox.type.AbstractField) ,public Map<java.lang.String,java.lang.String> getAllNamespacesWithPrefix() ,public final List<org.apache.xmpbox... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/ArrayProperty.java | ArrayProperty | getElementsAsString | class ArrayProperty extends AbstractComplexProperty
{
private final Cardinality arrayType;
private final String namespace;
private final String prefix;
/**
* Constructor of a complex property
*
* @param metadata
* The metadata to attach to this property
* @param ... |
List<AbstractField> allProperties = getContainer().getAllProperties();
List<String> retval = new ArrayList<>(allProperties.size());
allProperties.forEach(tmp -> retval.add(((AbstractSimpleProperty) tmp).getStringValue()));
return Collections.unmodifiableList(retval);
| 372 | 77 | 449 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String) ,public void addNamespace(java.lang.String, java.lang.String) ,public final void addProperty(org.apache.xmpbox.type.AbstractField) ,public Map<java.lang.String,java.lang.String> getAllNamespacesWithPrefix() ,public final List<org.apache.xmpbox... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/Attribute.java | Attribute | toString | class Attribute
{
private String nsURI;
private String name;
private String value;
/**
* Constructor of a new Attribute
*
* @param nsURI
* namespaceURI of this attribute (could be null)
* @param localName
* localName of this attribute
* @para... |
return "[attr:{" + nsURI + "}" + name + "=" + value + "]";
| 516 | 28 | 544 | <no_super_class> |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/BooleanType.java | BooleanType | setValue | class BooleanType extends AbstractSimpleProperty
{
public static final String TRUE = "True";
public static final String FALSE = "False";
private boolean booleanValue;
/**
* Property Boolean type constructor (namespaceURI is given)
*
* @param metadata
* The metadata to... |
if (value instanceof Boolean)
{
booleanValue = (Boolean) value;
}
else if (value instanceof String)
{
// NumberFormatException is thrown (sub of InvalidArgumentException)
String s = value.toString().trim().toUpperCase();
if ("TRUE"... | 354 | 185 | 539 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String, java.lang.String, java.lang.Object) ,public final java.lang.String getNamespace() ,public java.lang.String getPrefix() ,public java.lang.Object getRawValue() ,public abstract java.lang.String getStringValue() ,public abstract... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/ComplexPropertyContainer.java | ComplexPropertyContainer | removePropertiesByName | class ComplexPropertyContainer
{
private final List<AbstractField> properties;
/**
* Complex Property type constructor (namespaceURI is given)
*
*/
public ComplexPropertyContainer()
{
properties = new ArrayList<>();
}
/**
* Give the first property found in this co... |
if (properties.isEmpty())
{
return;
}
List<AbstractField> propList = getPropertiesByLocalName(localName);
if (propList == null)
{
return;
}
propList.forEach(properties::remove);
| 1,012 | 70 | 1,082 | <no_super_class> |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/DateType.java | DateType | isGoodType | class DateType extends AbstractSimpleProperty
{
private Calendar dateValue;
/**
* Property Date type constructor (namespaceURI is given)
*
* @param metadata
* The metadata to attach to this property
* @param namespaceURI
* the namespace URI to associate to ... |
if (value instanceof Calendar)
{
return true;
}
else if (value instanceof String)
{
try
{
DateConverter.toCalendar((String) value);
return true;
}
catch (IOException e)
{
... | 722 | 86 | 808 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String, java.lang.String, java.lang.Object) ,public final java.lang.String getNamespace() ,public java.lang.String getPrefix() ,public java.lang.Object getRawValue() ,public abstract java.lang.String getStringValue() ,public abstract... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/IntegerType.java | IntegerType | setValue | class IntegerType extends AbstractSimpleProperty
{
private int integerValue;
/**
* Property Integer type constructor (namespaceURI is given)
*
* @param metadata
* The metadata to attach to this property
* @param namespaceURI
* the namespace URI to associate... |
if (value instanceof Integer)
{
integerValue = (Integer) value;
}
else if (value instanceof String)
{
integerValue = Integer.parseInt((String) value);
// NumberFormatException is thrown (sub of InvalidArgumentException)
}
else
... | 316 | 107 | 423 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String, java.lang.String, java.lang.Object) ,public final java.lang.String getNamespace() ,public java.lang.String getPrefix() ,public java.lang.Object getRawValue() ,public abstract java.lang.String getStringValue() ,public abstract... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/LayerType.java | LayerType | getLayerName | class LayerType extends AbstractStructuredType
{
@PropertyType(type = Types.Text, card = Cardinality.Simple)
public static final String LAYER_NAME = "LayerName";
@PropertyType(type = Types.Text, card = Cardinality.Simple)
public static final String LAYER_TEXT = "LayerText";
public LayerType(XMPMe... |
AbstractField absProp = getFirstEquivalentProperty(LAYER_NAME, TextType.class);
if (absProp != null)
{
return ((TextType) absProp).getStringValue();
}
return null;
| 440 | 60 | 500 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata) ,public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String) ,public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String, java.lang.String) ,public org.apache.xmpbox.type.ArrayProperty createArrayProperty(java.lang.String, org.... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/RealType.java | RealType | setValue | class RealType extends AbstractSimpleProperty
{
private float realValue;
/**
* Property Real type constructor (namespaceURI is given)
*
* @param metadata
* The metadata to attach to this property
* @param namespaceURI
* the namespace URI to associate to thi... |
if (value instanceof Float)
{
realValue = (Float) value;
}
else if (value instanceof String)
{
// NumberFormatException is thrown (sub of InvalidArgumentException)
realValue = Float.parseFloat((String) value);
}
else
{
... | 319 | 109 | 428 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String, java.lang.String, java.lang.Object) ,public final java.lang.String getNamespace() ,public java.lang.String getPrefix() ,public java.lang.Object getRawValue() ,public abstract java.lang.String getStringValue() ,public abstract... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/TextType.java | TextType | setValue | class TextType extends AbstractSimpleProperty
{
private String textValue;
/**
* Property Text type constructor (namespaceURI is given)
*
* @param metadata
* The metadata to attach to this property
* @param namespaceURI
* the namespace URI to associate to th... |
if (!(value instanceof String))
{
throw new IllegalArgumentException("Value given is not allowed for the Text type : '" + value + "'");
}
else
{
textValue = (String) value;
}
| 287 | 61 | 348 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String, java.lang.String, java.lang.Object) ,public final java.lang.String getNamespace() ,public java.lang.String getPrefix() ,public java.lang.Object getRawValue() ,public abstract java.lang.String getStringValue() ,public abstract... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/type/ThumbnailType.java | ThumbnailType | getHeight | class ThumbnailType extends AbstractStructuredType
{
@PropertyType(type = Types.Choice, card = Cardinality.Simple)
public static final String FORMAT = "format";
@PropertyType(type = Types.Integer, card = Cardinality.Simple)
public static final String HEIGHT = "height";
@PropertyType(type = Types.... |
AbstractField absProp = getFirstEquivalentProperty(HEIGHT, IntegerType.class);
if (absProp != null)
{
return ((IntegerType) absProp).getValue();
}
return null;
| 799 | 57 | 856 | <methods>public void <init>(org.apache.xmpbox.XMPMetadata) ,public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String) ,public void <init>(org.apache.xmpbox.XMPMetadata, java.lang.String, java.lang.String, java.lang.String) ,public org.apache.xmpbox.type.ArrayProperty createArrayProperty(java.lang.String, org.... |
apache_pdfbox | pdfbox/xmpbox/src/main/java/org/apache/xmpbox/xml/DomHelper.java | DomHelper | getUniqueElementChild | class DomHelper
{
private DomHelper()
{
}
public static Element getUniqueElementChild(Element description) throws XmpParsingException
{<FILL_FUNCTION_BODY>}
/**
* Return the first child element of the element parameter. If there is no child, null is returned
*
* @param descrip... |
NodeList nl = description.getChildNodes();
int pos = -1;
for (int i = 0; i < nl.getLength(); i++)
{
if (nl.item(i) instanceof Element)
{
if (pos >= 0)
{
// invalid : found two child elements
... | 517 | 148 | 665 | <no_super_class> |
pf4j_pf4j | pf4j/demo/app/src/main/java/org/pf4j/demo/Boot.java | Boot | main | class Boot {
private static final Logger log = LoggerFactory.getLogger(Boot.class);
public static void main(String[] args) {<FILL_FUNCTION_BODY>}
private static void printLogo() {
log.info(StringUtils.repeat("#", 40));
log.info(StringUtils.center("PF4J-DEMO", 40));
log.info(String... |
// print logo
printLogo();
// create the plugin manager
PluginManager pluginManager = new DemoPluginManager();
// load the plugins
pluginManager.loadPlugins();
// enable a disabled plugin
// pluginManager.enablePlugin("welcome-plugin");
// star... | 122 | 857 | 979 | <no_super_class> |
pf4j_pf4j | pf4j/demo/app/src/main/java/org/pf4j/demo/DemoPluginFactory.java | DemoPluginFactory | createInstance | class DemoPluginFactory extends DefaultPluginFactory {
private static final Logger log = LoggerFactory.getLogger(DemoPluginFactory.class);
@Override
protected Plugin createInstance(Class<?> pluginClass, PluginWrapper pluginWrapper) {<FILL_FUNCTION_BODY>}
} |
PluginContext context = new PluginContext(pluginWrapper.getRuntimeMode());
try {
Constructor<?> constructor = pluginClass.getConstructor(PluginContext.class);
return (Plugin) constructor.newInstance(context);
} catch (Exception e) {
log.error(e.getMessage(), ... | 77 | 89 | 166 | <methods>public non-sealed void <init>() ,public org.pf4j.Plugin create(org.pf4j.PluginWrapper) <variables>private static final org.slf4j.Logger log |
pf4j_pf4j | pf4j/demo/plugins/plugin1/src/main/java/org/pf4j/demo/welcome/WelcomePlugin.java | WelcomePlugin | start | class WelcomePlugin extends DemoPlugin {
public WelcomePlugin(PluginContext context) {
super(context);
}
@Override
public void start() {<FILL_FUNCTION_BODY>}
@Override
public void stop() {
log.info("WelcomePlugin.stop()");
}
@Extension
public static class WelcomeG... |
log.info("WelcomePlugin.start()");
// for testing the development mode
if (RuntimeMode.DEVELOPMENT.equals(context.getRuntimeMode())) {
log.info(StringUtils.upperCase("WelcomePlugin"));
}
| 131 | 63 | 194 | <methods><variables>protected final non-sealed org.pf4j.demo.api.PluginContext context |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/BasePluginLoader.java | BasePluginLoader | loadJars | class BasePluginLoader implements PluginLoader {
protected PluginManager pluginManager;
protected PluginClasspath pluginClasspath;
public BasePluginLoader(PluginManager pluginManager, PluginClasspath pluginClasspath) {
this.pluginManager = pluginManager;
this.pluginClasspath = pluginClassp... |
for (String jarsDirectory : pluginClasspath.getJarsDirectories()) {
Path file = pluginPath.resolve(jarsDirectory);
List<File> jars = FileUtils.getJars(file);
for (File jar : jars) {
pluginClassLoader.addFile(jar);
}
}
| 457 | 83 | 540 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/BasePluginRepository.java | BasePluginRepository | getPluginPaths | class BasePluginRepository implements PluginRepository {
protected final List<Path> pluginsRoots;
protected FileFilter filter;
protected Comparator<File> comparator;
public BasePluginRepository(Path... pluginsRoots) {
this(Arrays.asList(pluginsRoots));
}
public BasePluginRepository(L... |
return pluginsRoots.stream()
.flatMap(path -> streamFiles(path, filter))
.sorted(comparator)
.map(File::toPath)
.collect(Collectors.toList());
| 549 | 59 | 608 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/CompoundPluginDescriptorFinder.java | CompoundPluginDescriptorFinder | add | class CompoundPluginDescriptorFinder implements PluginDescriptorFinder {
private static final Logger log = LoggerFactory.getLogger(CompoundPluginDescriptorFinder.class);
private List<PluginDescriptorFinder> finders = new ArrayList<>();
public CompoundPluginDescriptorFinder add(PluginDescriptorFinder find... |
if (finder == null) {
throw new IllegalArgumentException("null not allowed");
}
finders.add(finder);
return this;
| 461 | 44 | 505 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/CompoundPluginLoader.java | CompoundPluginLoader | add | class CompoundPluginLoader implements PluginLoader {
private static final Logger log = LoggerFactory.getLogger(CompoundPluginLoader.class);
private List<PluginLoader> loaders = new ArrayList<>();
public CompoundPluginLoader add(PluginLoader loader) {<FILL_FUNCTION_BODY>}
/**
* Add a {@link Plug... |
if (loader == null) {
throw new IllegalArgumentException("null not allowed");
}
loaders.add(loader);
return this;
| 481 | 42 | 523 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java | CompoundPluginRepository | deletePluginPath | class CompoundPluginRepository implements PluginRepository {
private List<PluginRepository> repositories = new ArrayList<>();
public CompoundPluginRepository add(PluginRepository repository) {
if (repository == null) {
throw new IllegalArgumentException("null not allowed");
}
... |
for (PluginRepository repository : repositories) {
if (repository.deletePluginPath(pluginPath)) {
return true;
}
}
return false;
| 288 | 46 | 334 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/DefaultExtensionFactory.java | DefaultExtensionFactory | create | class DefaultExtensionFactory implements ExtensionFactory {
private static final Logger log = LoggerFactory.getLogger(DefaultExtensionFactory.class);
/**
* Creates an extension instance.
*/
@Override
public <T> T create(Class<T> extensionClass) {<FILL_FUNCTION_BODY>}
} |
log.debug("Create instance for extension '{}'", extensionClass.getName());
try {
return extensionClass.newInstance();
} catch (Exception e) {
throw new PluginRuntimeException(e);
}
| 84 | 58 | 142 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/DefaultExtensionFinder.java | DefaultExtensionFinder | findClassNames | class DefaultExtensionFinder implements ExtensionFinder, PluginStateListener {
protected PluginManager pluginManager;
protected List<ExtensionFinder> finders = new ArrayList<>();
public DefaultExtensionFinder(PluginManager pluginManager) {
this.pluginManager = pluginManager;
add(new Legac... |
Set<String> classNames = new HashSet<>();
for (ExtensionFinder finder : finders) {
classNames.addAll(finder.findClassNames(pluginId));
}
return classNames;
| 522 | 59 | 581 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/DefaultPluginDescriptor.java | DefaultPluginDescriptor | setDependencies | class DefaultPluginDescriptor implements PluginDescriptor {
private String pluginId;
private String pluginDescription;
private String pluginClass = Plugin.class.getName();
private String version;
private String requires = "*"; // SemVer format
private String provider;
private List<PluginDep... |
this.dependencies = new ArrayList<>();
if (dependencies != null) {
dependencies = dependencies.trim();
if (!dependencies.isEmpty()) {
String[] tokens = dependencies.split(",");
for (String dependency : tokens) {
dependency = d... | 1,170 | 117 | 1,287 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/DefaultPluginFactory.java | DefaultPluginFactory | createInstance | class DefaultPluginFactory implements PluginFactory {
private static final Logger log = LoggerFactory.getLogger(DefaultPluginFactory.class);
/**
* Creates a plugin instance. If an error occurs than that error is logged and the method returns {@code null}.
*/
@Override
public Plugin create(fi... |
try {
Constructor<?> constructor = pluginClass.getConstructor(PluginWrapper.class);
return (Plugin) constructor.newInstance(pluginWrapper);
} catch (NoSuchMethodException e) {
return createUsingNoParametersConstructor(pluginClass);
} catch (Exception e) {
... | 436 | 95 | 531 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/DefaultPluginManager.java | DefaultPluginManager | loadPluginFromPath | class DefaultPluginManager extends AbstractPluginManager {
private static final Logger log = LoggerFactory.getLogger(DefaultPluginManager.class);
public static final String PLUGINS_DIR_CONFIG_PROPERTY_NAME = "pf4j.pluginsConfigDir";
public DefaultPluginManager() {
super();
}
public Defau... |
// First unzip any ZIP files
try {
pluginPath = FileUtils.expandIfZip(pluginPath);
} catch (Exception e) {
log.warn("Failed to unzip " + pluginPath, e);
return null;
}
return super.loadPluginFromPath(pluginPath);
| 812 | 81 | 893 | <methods>public synchronized void addPluginStateListener(org.pf4j.PluginStateListener) ,public boolean deletePlugin(java.lang.String) ,public boolean disablePlugin(java.lang.String) ,public boolean enablePlugin(java.lang.String) ,public Set<java.lang.String> getExtensionClassNames(java.lang.String) ,public List<Class<?... |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/DefaultPluginRepository.java | DefaultPluginRepository | expandIfZip | class DefaultPluginRepository extends BasePluginRepository {
private static final Logger log = LoggerFactory.getLogger(DefaultPluginRepository.class);
public DefaultPluginRepository(Path... pluginsRoots) {
this(Arrays.asList(pluginsRoots));
}
public DefaultPluginRepository(List<Path> pluginsR... |
try {
FileUtils.expandIfZip(filePath);
} catch (IOException e) {
log.error("Cannot expand plugin zip '{}'", filePath);
log.error(e.getMessage(), e);
}
| 372 | 61 | 433 | <methods>public transient void <init>(java.nio.file.Path[]) ,public void <init>(List<java.nio.file.Path>) ,public void <init>(List<java.nio.file.Path>, java.io.FileFilter) ,public boolean deletePluginPath(java.nio.file.Path) ,public List<java.nio.file.Path> getPluginPaths() ,public void setComparator(Comparator<java.io... |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/DefaultPluginStatusProvider.java | DefaultPluginStatusProvider | enablePlugin | class DefaultPluginStatusProvider implements PluginStatusProvider {
private static final Logger log = LoggerFactory.getLogger(DefaultPluginStatusProvider.class);
private final Path pluginsRoot;
private List<String> enabledPlugins;
private List<String> disabledPlugins;
public DefaultPluginStatusP... |
if (!isPluginDisabled(pluginId)) {
// do nothing
return;
}
if (Files.exists(getEnabledFilePath())) {
enabledPlugins.add(pluginId);
try {
FileUtils.writeLines(enabledPlugins, getEnabledFilePath());
} catch (IOException... | 666 | 170 | 836 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/DevelopmentPluginRepository.java | DevelopmentPluginRepository | createHiddenPluginFilter | class DevelopmentPluginRepository extends BasePluginRepository {
public static final String MAVEN_BUILD_DIR = "target";
public static final String GRADLE_BUILD_DIR = "build";
public DevelopmentPluginRepository(Path... pluginsRoots) {
this(Arrays.asList(pluginsRoots));
}
public Development... |
OrFileFilter hiddenPluginFilter = new OrFileFilter(new HiddenFilter());
// skip default build output folders since these will cause errors in the logs
hiddenPluginFilter
.addFileFilter(new NameFileFilter(MAVEN_BUILD_DIR))
.addFileFilter(new NameFileFilter(GRADLE_BUILD_D... | 182 | 94 | 276 | <methods>public transient void <init>(java.nio.file.Path[]) ,public void <init>(List<java.nio.file.Path>) ,public void <init>(List<java.nio.file.Path>, java.io.FileFilter) ,public boolean deletePluginPath(java.nio.file.Path) ,public List<java.nio.file.Path> getPluginPaths() ,public void setComparator(Comparator<java.io... |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/ExtensionWrapper.java | ExtensionWrapper | getExtension | class ExtensionWrapper<T> implements Comparable<ExtensionWrapper<T>> {
private final ExtensionDescriptor descriptor;
private final ExtensionFactory extensionFactory;
private T extension; // cache
public ExtensionWrapper(ExtensionDescriptor descriptor, ExtensionFactory extensionFactory) {
this.... |
if (extension == null) {
extension = (T) extensionFactory.create(descriptor.extensionClass);
}
return extension;
| 199 | 39 | 238 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/JarPluginLoader.java | JarPluginLoader | loadPlugin | class JarPluginLoader implements PluginLoader {
protected PluginManager pluginManager;
public JarPluginLoader(PluginManager pluginManager) {
this.pluginManager = pluginManager;
}
@Override
public boolean isApplicable(Path pluginPath) {
return Files.exists(pluginPath) && FileUtils.... |
PluginClassLoader pluginClassLoader = new PluginClassLoader(pluginManager, pluginDescriptor, getClass().getClassLoader());
pluginClassLoader.addFile(pluginPath.toFile());
return pluginClassLoader;
| 130 | 55 | 185 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/JarPluginManager.java | JarPluginManager | createPluginRepository | class JarPluginManager extends DefaultPluginManager {
public JarPluginManager() {
super();
}
public JarPluginManager(Path... pluginsRoots) {
super(pluginsRoots);
}
@Override
protected PluginDescriptorFinder createPluginDescriptorFinder() {
return new ManifestPluginDesc... |
return new CompoundPluginRepository()
.add(new DevelopmentPluginRepository(getPluginsRoots()), this::isDevelopment)
.add(new JarPluginRepository(getPluginsRoots()), this::isNotDevelopment);
| 182 | 59 | 241 | <methods>public void <init>() ,public transient void <init>(java.nio.file.Path[]) ,public void <init>(List<java.nio.file.Path>) <variables>public static final java.lang.String PLUGINS_DIR_CONFIG_PROPERTY_NAME,private static final org.slf4j.Logger log |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java | LegacyExtensionFinder | readPluginsStorages | class LegacyExtensionFinder extends AbstractExtensionFinder {
private static final Logger log = LoggerFactory.getLogger(LegacyExtensionFinder.class);
public static final String EXTENSIONS_RESOURCE = LegacyExtensionStorage.EXTENSIONS_RESOURCE;
public LegacyExtensionFinder(PluginManager pluginManager) {
... |
log.debug("Reading extensions storages from plugins");
Map<String, Set<String>> result = new LinkedHashMap<>();
List<PluginWrapper> plugins = pluginManager.getPlugins();
for (PluginWrapper plugin : plugins) {
String pluginId = plugin.getDescriptor().getPluginId();
... | 495 | 287 | 782 | <methods>public List<ExtensionWrapper<T>> find(Class<T>) ,public List<ExtensionWrapper<T>> find(Class<T>, java.lang.String) ,public List<ExtensionWrapper#RAW> find(java.lang.String) ,public Set<java.lang.String> findClassNames(java.lang.String) ,public static org.pf4j.Extension findExtensionAnnotation(Class<?>) ,public... |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/LoggingPluginStateListener.java | LoggingPluginStateListener | pluginStateChanged | class LoggingPluginStateListener implements PluginStateListener {
private static final Logger log = LoggerFactory.getLogger(LoggingPluginStateListener.class);
@Override
public void pluginStateChanged(PluginStateEvent event) {<FILL_FUNCTION_BODY>}
} |
log.debug("The state of plugin '{}' has changed from '{}' to '{}'", event.getPlugin().getPluginId(),
event.getOldState(), event.getPluginState());
| 72 | 50 | 122 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java | ManifestPluginDescriptorFinder | readManifest | class ManifestPluginDescriptorFinder implements PluginDescriptorFinder {
private static final Logger log = LoggerFactory.getLogger(ManifestPluginDescriptorFinder.class);
public static final String PLUGIN_ID = "Plugin-Id";
public static final String PLUGIN_DESCRIPTION = "Plugin-Description";
public sta... |
if (FileUtils.isJarFile(pluginPath)) {
return readManifestFromJar(pluginPath);
}
if (FileUtils.isZipFile(pluginPath)) {
return readManifestFromZip(pluginPath);
}
return readManifestFromDirectory(pluginPath);
| 1,138 | 81 | 1,219 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/PluginClasspath.java | PluginClasspath | equals | class PluginClasspath {
private final Set<String> classesDirectories = new HashSet<>();
private final Set<String> jarsDirectories = new HashSet<>();
/**
* Get the classes directories.
*
* @return a set of directories that contain classes files
*/
public Set<String> getClassesDirect... |
if (this == o) return true;
if (!(o instanceof PluginClasspath)) return false;
PluginClasspath that = (PluginClasspath) o;
return classesDirectories.equals(that.classesDirectories) &&
jarsDirectories.equals(that.jarsDirectories);
| 574 | 76 | 650 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/PluginDependency.java | PluginDependency | equals | class PluginDependency {
private String pluginId;
private String pluginVersionSupport = "*";
private final boolean optional;
public PluginDependency(String dependency) {
int index = dependency.indexOf('@');
if (index == -1) {
this.pluginId = dependency;
} else {
... |
if (this == o) return true;
if (!(o instanceof PluginDependency)) return false;
PluginDependency that = (PluginDependency) o;
return optional == that.optional &&
pluginId.equals(that.pluginId) &&
pluginVersionSupport.equals(that.pluginVersionSupport);
| 500 | 77 | 577 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/PluginStateEvent.java | PluginStateEvent | toString | class PluginStateEvent extends EventObject {
private final PluginWrapper plugin;
private final PluginState oldState;
public PluginStateEvent(PluginManager source, PluginWrapper plugin, PluginState oldState) {
super(source);
this.plugin = plugin;
this.oldState = oldState;
}
... |
return "PluginStateEvent [plugin=" + plugin.getPluginId() +
", newState=" + getPluginState() +
", oldState=" + oldState +
']';
| 332 | 51 | 383 | <methods>public void <init>(java.lang.Object) ,public java.lang.Object getSource() ,public java.lang.String toString() <variables>private static final long serialVersionUID,protected transient java.lang.Object source |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/PluginWrapper.java | PluginWrapper | toString | class PluginWrapper {
private final PluginManager pluginManager;
private final PluginDescriptor descriptor;
private final Path pluginPath;
private final ClassLoader pluginClassLoader;
private PluginFactory pluginFactory;
private PluginState pluginState;
private final RuntimeMode runtimeMode... |
return "PluginWrapper [descriptor=" + descriptor + ", pluginPath=" + pluginPath + "]";
| 1,084 | 29 | 1,113 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/PropertiesPluginDescriptorFinder.java | PropertiesPluginDescriptorFinder | readProperties | class PropertiesPluginDescriptorFinder implements PluginDescriptorFinder {
private static final Logger log = LoggerFactory.getLogger(PropertiesPluginDescriptorFinder.class);
public static final String DEFAULT_PROPERTIES_FILE_NAME = "plugin.properties";
public static final String PLUGIN_ID = "plugin.id";
... |
Path propertiesPath = getPropertiesPath(pluginPath, propertiesFileName);
if (propertiesPath == null) {
throw new PluginRuntimeException("Cannot find the properties path");
}
Properties properties = new Properties();
try {
log.debug("Lookup plugin descrip... | 899 | 186 | 1,085 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/ServiceProviderExtensionFinder.java | ServiceProviderExtensionFinder | readPluginsStorages | class ServiceProviderExtensionFinder extends AbstractExtensionFinder {
private static final Logger log = LoggerFactory.getLogger(ServiceProviderExtensionFinder.class);
public static final String EXTENSIONS_RESOURCE = ServiceProviderExtensionStorage.EXTENSIONS_RESOURCE;
public ServiceProviderExtensionFind... |
log.debug("Reading extensions storages from plugins");
Map<String, Set<String>> result = new LinkedHashMap<>();
List<PluginWrapper> plugins = pluginManager.getPlugins();
for (PluginWrapper plugin : plugins) {
String pluginId = plugin.getDescriptor().getPluginId();
... | 758 | 267 | 1,025 | <methods>public List<ExtensionWrapper<T>> find(Class<T>) ,public List<ExtensionWrapper<T>> find(Class<T>, java.lang.String) ,public List<ExtensionWrapper#RAW> find(java.lang.String) ,public Set<java.lang.String> findClassNames(java.lang.String) ,public static org.pf4j.Extension findExtensionAnnotation(Class<?>) ,public... |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/SingletonExtensionFactory.java | SingletonExtensionFactory | create | class SingletonExtensionFactory extends DefaultExtensionFactory {
private final List<String> extensionClassNames;
private final Map<ClassLoader, Map<String, Object>> cache;
public SingletonExtensionFactory(PluginManager pluginManager, String... extensionClassNames) {
this.extensionClassNames = Ar... |
String extensionClassName = extensionClass.getName();
ClassLoader extensionClassLoader = extensionClass.getClassLoader();
if (!cache.containsKey(extensionClassLoader)) {
cache.put(extensionClassLoader, new HashMap<>());
}
Map<String, Object> classLoaderBucket = cac... | 200 | 182 | 382 | <methods>public non-sealed void <init>() ,public T create(Class<T>) <variables>private static final org.slf4j.Logger log |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/ZipPluginManager.java | ZipPluginManager | createPluginRepository | class ZipPluginManager extends DefaultPluginManager {
@Override
protected PluginDescriptorFinder createPluginDescriptorFinder() {
return new PropertiesPluginDescriptorFinder();
}
@Override
protected PluginLoader createPluginLoader() {
return new CompoundPluginLoader()
.... |
return new CompoundPluginRepository()
.add(new DevelopmentPluginRepository(getPluginsRoots()), this::isDevelopment)
.add(new DefaultPluginRepository(getPluginsRoots()), this::isNotDevelopment);
| 140 | 59 | 199 | <methods>public void <init>() ,public transient void <init>(java.nio.file.Path[]) ,public void <init>(List<java.nio.file.Path>) <variables>public static final java.lang.String PLUGINS_DIR_CONFIG_PROPERTY_NAME,private static final org.slf4j.Logger log |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/asm/ExtensionInfo.java | ExtensionInfo | load | class ExtensionInfo {
private static final Logger log = LoggerFactory.getLogger(ExtensionInfo.class);
private final String className;
int ordinal = 0;
List<String> plugins = new ArrayList<>();
List<String> points = new ArrayList<>();
private ExtensionInfo(String className) {
this.cla... |
try (InputStream input = classLoader.getResourceAsStream(className.replace('.', '/') + ".class")) {
ExtensionInfo info = new ExtensionInfo(className);
new ClassReader(input).accept(new ExtensionVisitor(info), ClassReader.SKIP_DEBUG);
return info;
} catch (IOExceptio... | 439 | 102 | 541 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/asm/ExtensionVisitor.java | ExtensionVisitor | visit | class ExtensionVisitor extends ClassVisitor {
private static final Logger log = LoggerFactory.getLogger(ExtensionVisitor.class);
private static final int ASM_VERSION = Opcodes.ASM7;
private final ExtensionInfo extensionInfo;
ExtensionVisitor(ExtensionInfo extensionInfo) {
super(ASM_VERSI... |
log.debug("Load annotation attribute {} = {} ({})", name, value, value.getClass().getName());
if ("ordinal".equals(name)) {
extensionInfo.ordinal = Integer.parseInt(value.toString());
} else if ("plugins... | 332 | 257 | 589 | <methods>public void <init>(int) ,public void <init>(int, org.objectweb.asm.ClassVisitor) ,public void visit(int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[]) ,public org.objectweb.asm.AnnotationVisitor visitAnnotation(java.lang.String, boolean) ,public void visitAttribute(org.objectwe... |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/processor/ExtensionStorage.java | ExtensionStorage | read | class ExtensionStorage {
private static final Pattern COMMENT = Pattern.compile("#.*");
private static final Pattern WHITESPACE = Pattern.compile("\\s+");
protected final ExtensionAnnotationProcessor processor;
public ExtensionStorage(ExtensionAnnotationProcessor processor) {
this.processor =... |
try (BufferedReader bufferedReader = new BufferedReader(reader)) {
String line;
while ((line = bufferedReader.readLine()) != null) {
line = COMMENT.matcher(line).replaceFirst("");
line = WHITESPACE.matcher(line).replaceAll("");
if (line.le... | 362 | 109 | 471 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/processor/LegacyExtensionStorage.java | LegacyExtensionStorage | write | class LegacyExtensionStorage extends ExtensionStorage {
public static final String EXTENSIONS_RESOURCE = "META-INF/extensions.idx";
public LegacyExtensionStorage(ExtensionAnnotationProcessor processor) {
super(processor);
}
@Override
public Map<String, Set<String>> read() {
Map<St... |
try {
FileObject file = getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", EXTENSIONS_RESOURCE);
try (BufferedWriter writer = new BufferedWriter(file.openWriter())) {
writer.write("# Generated by PF4J"); // write header
writer.newLine();
... | 303 | 213 | 516 | <methods>public void <init>(org.pf4j.processor.ExtensionAnnotationProcessor) ,public abstract Map<java.lang.String,Set<java.lang.String>> read() ,public static void read(java.io.Reader, Set<java.lang.String>) throws java.io.IOException,public abstract void write(Map<java.lang.String,Set<java.lang.String>>) <variables>p... |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/processor/ServiceProviderExtensionStorage.java | ServiceProviderExtensionStorage | read | class ServiceProviderExtensionStorage extends ExtensionStorage {
public static final String EXTENSIONS_RESOURCE = "META-INF/services";
public ServiceProviderExtensionStorage(ExtensionAnnotationProcessor processor) {
super(processor);
}
@Override
public Map<String, Set<String>> read() {<FI... |
Map<String, Set<String>> extensions = new HashMap<>();
for (String extensionPoint : processor.getExtensions().keySet()) {
try {
FileObject file = getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", EXTENSIONS_RESOURCE
+ "/" + extensionPoint);
... | 443 | 205 | 648 | <methods>public void <init>(org.pf4j.processor.ExtensionAnnotationProcessor) ,public abstract Map<java.lang.String,Set<java.lang.String>> read() ,public static void read(java.io.Reader, Set<java.lang.String>) throws java.io.IOException,public abstract void write(Map<java.lang.String,Set<java.lang.String>>) <variables>p... |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/util/AndFileFilter.java | AndFileFilter | accept | class AndFileFilter implements FileFilter {
/** The list of file filters. */
private List<FileFilter> fileFilters;
public AndFileFilter() {
this(new ArrayList<>());
}
public AndFileFilter(FileFilter... fileFilters) {
this(Arrays.asList(fileFilters));
}
public AndFileFilte... |
if (this.fileFilters.isEmpty()) {
return false;
}
for (FileFilter fileFilter : this.fileFilters) {
if (!fileFilter.accept(file)) {
return false;
}
}
return true;
| 291 | 70 | 361 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/util/ClassUtils.java | ClassUtils | getAnnotationMirror | class ClassUtils {
private ClassUtils() {}
public static List<String> getAllInterfacesNames(Class<?> aClass) {
return toString(getAllInterfaces(aClass));
}
public static List<Class<?>> getAllInterfaces(Class<?> aClass) {
List<Class<?>> list = new ArrayList<>();
while (aClass ... |
String annotationClassName = annotationClass.getName();
for (AnnotationMirror m : typeElement.getAnnotationMirrors()) {
if (m.getAnnotationType().toString().equals(annotationClassName)) {
return m;
}
}
return null;
| 1,027 | 71 | 1,098 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/util/DirectedGraph.java | DirectedGraph | topologicalSort | class DirectedGraph<V> {
/**
* The implementation here is basically an adjacency list, but instead
* of an array of lists, a Map is used to map each vertex to its list of
* adjacent vertices.
*/
private Map<V, List<V>> neighbors = new HashMap<>();
/**
* Add a vertex to the graph. ... |
Map<V, Integer> degree = inDegree();
// determine all vertices with zero in-degree
Stack<V> zeroVertices = new Stack<>(); // stack as good as any here
for (V v : degree.keySet()) {
if (degree.get(v) == 0) {
zeroVertices.push(v);
}
}
... | 1,067 | 309 | 1,376 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/util/OrFileFilter.java | OrFileFilter | accept | class OrFileFilter implements FileFilter {
/** The list of file filters. */
private List<FileFilter> fileFilters;
public OrFileFilter() {
this(new ArrayList<>());
}
public OrFileFilter(FileFilter... fileFilters) {
this(Arrays.asList(fileFilters));
}
public OrFileFilter(Li... |
if (this.fileFilters.isEmpty()) {
return true;
}
for (FileFilter fileFilter : this.fileFilters) {
if (fileFilter.accept(file)) {
return true;
}
}
return false;
| 291 | 70 | 361 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/util/StringUtils.java | StringUtils | addStart | class StringUtils {
private StringUtils() {}
public static boolean isNullOrEmpty(String str) {
return (str == null) || str.isEmpty();
}
public static boolean isNotNullOrEmpty(String str) {
return !isNullOrEmpty(str);
}
/**
* Format the string. Replace "{}" with %s and fo... |
if (isNullOrEmpty(add)) {
return str;
}
if (isNullOrEmpty(str)) {
return add;
}
if (!str.startsWith(add)) {
return add + str;
}
return str;
| 453 | 74 | 527 | <no_super_class> |
pf4j_pf4j | pf4j/pf4j/src/main/java/org/pf4j/util/Unzip.java | Unzip | extract | class Unzip {
private static final Logger log = LoggerFactory.getLogger(Unzip.class);
/**
* Holds the destination directory.
* File will be unzipped into the destination directory.
*/
private File destination;
/**
* Holds path to zip file.
*/
private File source;
pub... |
log.debug("Extract content of '{}' to '{}'", source, destination);
// delete destination directory if exists
if (destination.exists() && destination.isDirectory()) {
FileUtils.delete(destination.toPath());
}
String destinationCanonicalPath = destination.getCanonica... | 299 | 365 | 664 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/AuthorizationServerConfiguration.java | AuthorizationServerConfiguration | authorizationServerSecurityFilterChain | class AuthorizationServerConfiguration {
private final OAuth2AuthorizationService authorizationService;
private final PasswordDecoderFilter passwordDecoderFilter;
private final ValidateCodeFilter validateCodeFilter;
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
@ConditionalOnProperty(value = "security.micro", matc... |
OAuth2AuthorizationServerConfigurer authorizationServerConfigurer = new OAuth2AuthorizationServerConfigurer();
// 增加验证码过滤器
http.addFilterBefore(validateCodeFilter, UsernamePasswordAuthenticationFilter.class);
// 增加密码解密过滤器
http.addFilterBefore(passwordDecoderFilter, UsernamePasswordAuthenticationFilter.class... | 719 | 633 | 1,352 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/config/WebSecurityConfiguration.java | WebSecurityConfiguration | resources | class WebSecurityConfiguration {
/**
* spring security 默认的安全策略
* @param http security注入点
* @return SecurityFilterChain
* @throws Exception
*/
@Bean
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(authorizeRequests -> authorizeRequests.reque... |
http.securityMatchers((matchers) -> matchers.requestMatchers("/actuator/**", "/css/**", "/error"))
.authorizeHttpRequests((authorize) -> authorize.anyRequest().permitAll())
.requestCache(RequestCacheConfigurer::disable)
.securityContext(AbstractHttpConfigurer::disable)
.sessionManagement(AbstractHttpConf... | 324 | 109 | 433 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/ImageCodeEndpoint.java | ImageCodeEndpoint | image | class ImageCodeEndpoint {
private static final Integer DEFAULT_IMAGE_WIDTH = 100;
private static final Integer DEFAULT_IMAGE_HEIGHT = 40;
private final RedisTemplate redisTemplate;
/**
* 创建图形验证码
*/
@SneakyThrows
@GetMapping("/image")
public void image(String randomStr, HttpServletResponse response) {<FIL... |
ArithmeticCaptcha captcha = new ArithmeticCaptcha(DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT);
String result = captcha.text();
redisTemplate.opsForValue()
.set(CacheConstants.DEFAULT_CODE_KEY + randomStr, result, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
// 转换流信息写出
captcha.out(response.getOutputStre... | 112 | 115 | 227 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/endpoint/PigTokenEndpoint.java | PigTokenEndpoint | confirm | class PigTokenEndpoint {
private final HttpMessageConverter<OAuth2AccessTokenResponse> accessTokenHttpResponseConverter = new OAuth2AccessTokenResponseHttpMessageConverter();
private final AuthenticationFailureHandler authenticationFailureHandler = new PigAuthenticationFailureEventHandler();
private final OAuth2A... |
SysOauthClientDetails clientDetails = RetOps
.of(clientDetailsService.getClientDetailsById(clientId, SecurityConstants.FROM_IN))
.getData()
.orElseThrow(() -> new OAuthClientException("clientId 不合法"));
Set<String> authorizedScopes = StringUtils.commaDelimitedListToSet(clientDetails.getScope());
modelAn... | 1,705 | 189 | 1,894 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/CustomeOAuth2AccessTokenGenerator.java | CustomeOAuth2AccessTokenGenerator | generate | class CustomeOAuth2AccessTokenGenerator implements OAuth2TokenGenerator<OAuth2AccessToken> {
private OAuth2TokenCustomizer<OAuth2TokenClaimsContext> accessTokenCustomizer;
private final StringKeyGenerator accessTokenGenerator = new Base64StringKeyGenerator(
Base64.getUrlEncoder().withoutPadding(), 96);
@Nullab... |
if (!OAuth2TokenType.ACCESS_TOKEN.equals(context.getTokenType()) || !OAuth2TokenFormat.REFERENCE
.equals(context.getRegisteredClient().getTokenSettings().getAccessTokenFormat())) {
return null;
}
String issuer = null;
if (context.getAuthorizationServerContext() != null) {
issuer = context.getAuthoriz... | 442 | 747 | 1,189 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/base/OAuth2ResourceOwnerBaseAuthenticationConverter.java | OAuth2ResourceOwnerBaseAuthenticationConverter | convert | class OAuth2ResourceOwnerBaseAuthenticationConverter<T extends OAuth2ResourceOwnerBaseAuthenticationToken>
implements AuthenticationConverter {
/**
* 是否支持此convert
* @param grantType 授权类型
* @return
*/
public abstract boolean support(String grantType);
/**
* 校验参数
* @param request 请求
*/
public void c... |
// grant_type (REQUIRED)
String grantType = request.getParameter(OAuth2ParameterNames.GRANT_TYPE);
if (!support(grantType)) {
return null;
}
MultiValueMap<String, String> parameters = OAuth2EndpointUtils.getParameters(request);
// scope (OPTIONAL)
String scope = parameters.getFirst(OAuth2ParameterNa... | 213 | 521 | 734 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/CustomeOAuth2TokenCustomizer.java | CustomeOAuth2TokenCustomizer | customize | class CustomeOAuth2TokenCustomizer implements OAuth2TokenCustomizer<OAuth2TokenClaimsContext> {
/**
* Customize the OAuth 2.0 Token attributes.
* @param context the context containing the OAuth 2.0 Token attributes
*/
@Override
public void customize(OAuth2TokenClaimsContext context) {<FILL_FUNCTION_BODY>}
} |
OAuth2TokenClaimsSet.Builder claims = context.getClaims();
claims.claim(SecurityConstants.DETAILS_LICENSE, SecurityConstants.PROJECT_LICENSE);
String clientId = context.getAuthorizationGrant().getName();
claims.claim(SecurityConstants.CLIENT_ID, clientId);
// 客户端模式不返回具体用户信息
if (SecurityConstants.CLIENT_CRE... | 102 | 227 | 329 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/FormIdentityLoginConfigurer.java | FormIdentityLoginConfigurer | init | class FormIdentityLoginConfigurer
extends AbstractHttpConfigurer<FormIdentityLoginConfigurer, HttpSecurity> {
@Override
public void init(HttpSecurity http) throws Exception {<FILL_FUNCTION_BODY>}
} |
http.formLogin(formLogin -> {
formLogin.loginPage("/token/login");
formLogin.loginProcessingUrl("/token/form");
formLogin.failureHandler(new FormAuthenticationFailureHandler());
})
.logout(logout -> logout.logoutSuccessHandler(new SsoLogoutSuccessHandler())
.deleteCookies("JSESSIONID")
.invali... | 61 | 134 | 195 | <methods>public void <init>() ,public org.springframework.security.config.annotation.web.builders.HttpSecurity disable() ,public com.pig4cloud.pig.auth.support.core.FormIdentityLoginConfigurer withObjectPostProcessor(ObjectPostProcessor<?>) <variables> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/core/PigDaoAuthenticationProvider.java | PigDaoAuthenticationProvider | additionalAuthenticationChecks | class PigDaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {
/**
* The plaintext password used to perform PasswordEncoder#matches(CharSequence,
* String)} on when the user is not found to avoid SEC-2056.
*/
private static final String USER_NOT_FOUND_PASSWORD = "userNotFoundPassword";
... |
// 只有密码模式需要校验密码
String grantType = WebUtils.getRequest().get().getParameter(OAuth2ParameterNames.GRANT_TYPE);
if (!StrUtil.equals(AuthorizationGrantType.PASSWORD.getValue(), grantType)) {
return;
}
if (authentication.getCredentials() == null) {
this.logger.debug("Failed to authenticate since no crede... | 1,357 | 237 | 1,594 | <methods>public void <init>() ,public final void afterPropertiesSet() throws java.lang.Exception,public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication) throws org.springframework.security.core.AuthenticationException,public org.springframework.security.cor... |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/filter/PasswordDecoderFilter.java | PasswordDecoderFilter | doFilterInternal | class PasswordDecoderFilter extends OncePerRequestFilter {
private final AuthSecurityConfigProperties authSecurityConfigProperties;
private static final String PASSWORD = "password";
private static final String KEY_ALGORITHM = "AES";
static {
// 关闭hutool 强制关闭Bouncy Castle库的依赖
SecureUtil.disableBouncyCastle(... |
// 不是登录请求,直接向下执行
if (!StrUtil.containsAnyIgnoreCase(request.getRequestURI(), SecurityConstants.OAUTH_TOKEN_URL)) {
chain.doFilter(request, response);
return;
}
// 将请求流转换为可多次读取的请求流
RepeatBodyRequestWrapper requestWrapper = new RepeatBodyRequestWrapper(request);
Map<String, String[]> parameterMap = re... | 151 | 334 | 485 | <methods>public void <init>() ,public final void doFilter(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse, jakarta.servlet.FilterChain) throws jakarta.servlet.ServletException, java.io.IOException<variables>public static final java.lang.String ALREADY_FILTERED_SUFFIX |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/filter/ValidateCodeFilter.java | ValidateCodeFilter | doFilterInternal | class ValidateCodeFilter extends OncePerRequestFilter {
private final AuthSecurityConfigProperties authSecurityConfigProperties;
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {<FILL_FUNCTION_BODY>... |
String requestUrl = request.getServletPath();
// 不是登录URL 请求直接跳过
if (!SecurityConstants.OAUTH_TOKEN_URL.equals(requestUrl)) {
filterChain.doFilter(request, response);
return;
}
// 如果登录URL 但是刷新token的请求,直接向下执行
String grantType = request.getParameter(OAuth2ParameterNames.GRANT_TYPE);
if (StrUtil.equ... | 504 | 318 | 822 | <methods>public void <init>() ,public final void doFilter(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse, jakarta.servlet.FilterChain) throws jakarta.servlet.ServletException, java.io.IOException<variables>public static final java.lang.String ALREADY_FILTERED_SUFFIX |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/FormAuthenticationFailureHandler.java | FormAuthenticationFailureHandler | onAuthenticationFailure | class FormAuthenticationFailureHandler implements AuthenticationFailureHandler {
/**
* Called when an authentication attempt fails.
* @param request the request during which the authentication attempt occurred.
* @param response the response.
* @param exception the exception which was thrown to reject the aut... |
log.debug("表单登录失败:{}", exception.getLocalizedMessage());
String url = HttpUtil.encodeParams(String.format("/token/login?error=%s", exception.getMessage()),
CharsetUtil.CHARSET_UTF_8);
WebUtils.getResponse().sendRedirect(url);
| 118 | 82 | 200 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigAuthenticationFailureEventHandler.java | PigAuthenticationFailureEventHandler | sendErrorResponse | class PigAuthenticationFailureEventHandler implements AuthenticationFailureHandler {
private final MappingJackson2HttpMessageConverter errorHttpResponseConverter = new MappingJackson2HttpMessageConverter();
/**
* Called when an authentication attempt fails.
* @param request the request during which the authenti... |
ServletServerHttpResponse httpResponse = new ServletServerHttpResponse(response);
httpResponse.setStatusCode(HttpStatus.UNAUTHORIZED);
String errorMessage;
if (exception instanceof OAuth2AuthenticationException) {
OAuth2AuthenticationException authorizationException = (OAuth2AuthenticationException) except... | 457 | 189 | 646 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigAuthenticationSuccessEventHandler.java | PigAuthenticationSuccessEventHandler | sendAccessTokenResponse | class PigAuthenticationSuccessEventHandler implements AuthenticationSuccessHandler {
private final HttpMessageConverter<OAuth2AccessTokenResponse> accessTokenHttpResponseConverter = new PigCustomOAuth2AccessTokenResponseHttpMessageConverter();
/**
* Called when a user has been successfully authenticated.
* @par... |
OAuth2AccessTokenAuthenticationToken accessTokenAuthentication = (OAuth2AccessTokenAuthenticationToken) authentication;
OAuth2AccessToken accessToken = accessTokenAuthentication.getAccessToken();
OAuth2RefreshToken refreshToken = accessTokenAuthentication.getRefreshToken();
Map<String, Object> additionalPara... | 514 | 362 | 876 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/PigLogoutSuccessEventHandler.java | PigLogoutSuccessEventHandler | onApplicationEvent | class PigLogoutSuccessEventHandler implements ApplicationListener<LogoutSuccessEvent> {
@Override
public void onApplicationEvent(LogoutSuccessEvent event) {<FILL_FUNCTION_BODY>}
/**
* 处理退出成功方法
* <p>
* 获取到登录的authentication 对象
* @param authentication 登录对象
*/
public void handle(Authentication authenticatio... |
Authentication authentication = (Authentication) event.getSource();
if (authentication instanceof PreAuthenticatedAuthenticationToken) {
handle(authentication);
}
| 350 | 43 | 393 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/handler/SsoLogoutSuccessHandler.java | SsoLogoutSuccessHandler | onLogoutSuccess | class SsoLogoutSuccessHandler implements LogoutSuccessHandler {
private static final String REDIRECT_URL = "redirect_url";
@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
throws IOException {<FILL_FUNCTION_BODY>}
} |
if (response == null) {
return;
}
// 获取请求参数中是否包含 回调地址
String redirectUrl = request.getParameter(REDIRECT_URL);
if (StrUtil.isNotBlank(redirectUrl)) {
response.sendRedirect(redirectUrl);
}
else if (StrUtil.isNotBlank(request.getHeader(HttpHeaders.REFERER))) {
// 默认跳转referer 地址
String referer ... | 80 | 155 | 235 | <no_super_class> |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/password/OAuth2ResourceOwnerPasswordAuthenticationConverter.java | OAuth2ResourceOwnerPasswordAuthenticationConverter | checkParams | class OAuth2ResourceOwnerPasswordAuthenticationConverter
extends OAuth2ResourceOwnerBaseAuthenticationConverter<OAuth2ResourceOwnerPasswordAuthenticationToken> {
/**
* 支持密码模式
* @param grantType 授权类型
*/
@Override
public boolean support(String grantType) {
return AuthorizationGrantType.PASSWORD.getValue().e... |
MultiValueMap<String, String> parameters = OAuth2EndpointUtils.getParameters(request);
// username (REQUIRED)
String username = parameters.getFirst(OAuth2ParameterNames.USERNAME);
if (!StringUtils.hasText(username) || parameters.get(OAuth2ParameterNames.USERNAME).size() != 1) {
OAuth2EndpointUtils.throwErro... | 233 | 266 | 499 | <methods>public non-sealed void <init>() ,public abstract com.pig4cloud.pig.auth.support.password.OAuth2ResourceOwnerPasswordAuthenticationToken buildToken(org.springframework.security.core.Authentication, Set<java.lang.String>, Map<java.lang.String,java.lang.Object>) ,public void checkParams(jakarta.servlet.http.HttpS... |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/password/OAuth2ResourceOwnerPasswordAuthenticationProvider.java | OAuth2ResourceOwnerPasswordAuthenticationProvider | buildToken | class OAuth2ResourceOwnerPasswordAuthenticationProvider
extends OAuth2ResourceOwnerBaseAuthenticationProvider<OAuth2ResourceOwnerPasswordAuthenticationToken> {
private static final Logger LOGGER = LogManager.getLogger(OAuth2ResourceOwnerPasswordAuthenticationProvider.class);
/**
* Constructs an {@code OAuth2Aut... |
String username = (String) reqParameters.get(OAuth2ParameterNames.USERNAME);
String password = (String) reqParameters.get(OAuth2ParameterNames.PASSWORD);
return new UsernamePasswordAuthenticationToken(username, password);
| 395 | 61 | 456 | <methods>public void <init>(org.springframework.security.authentication.AuthenticationManager, OAuth2AuthorizationService, OAuth2TokenGenerator<? extends OAuth2Token>) ,public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication) throws org.springframework.secur... |
pig-mesh_pig | pig/pig-auth/src/main/java/com/pig4cloud/pig/auth/support/sms/OAuth2ResourceOwnerSmsAuthenticationConverter.java | OAuth2ResourceOwnerSmsAuthenticationConverter | checkParams | class OAuth2ResourceOwnerSmsAuthenticationConverter
extends OAuth2ResourceOwnerBaseAuthenticationConverter<OAuth2ResourceOwnerSmsAuthenticationToken> {
/**
* 是否支持此convert
* @param grantType 授权类型
* @return
*/
@Override
public boolean support(String grantType) {
return SecurityConstants.MOBILE.equals(gran... |
MultiValueMap<String, String> parameters = OAuth2EndpointUtils.getParameters(request);
// PHONE (REQUIRED)
String phone = parameters.getFirst(SecurityConstants.SMS_PARAMETER_NAME);
if (!StringUtils.hasText(phone) || parameters.get(SecurityConstants.SMS_PARAMETER_NAME).size() != 1) {
OAuth2EndpointUtils.thro... | 242 | 156 | 398 | <methods>public non-sealed void <init>() ,public abstract com.pig4cloud.pig.auth.support.sms.OAuth2ResourceOwnerSmsAuthenticationToken buildToken(org.springframework.security.core.Authentication, Set<java.lang.String>, Map<java.lang.String,java.lang.Object>) ,public void checkParams(jakarta.servlet.http.HttpServletRequ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.