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 |
|---|---|---|---|---|---|---|---|---|---|
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/ComputerID.java | ComputerID | getComputerIdentifier | class ComputerID {
public static final List<String> NON_UNIQUE_UUIDS = Arrays.asList("03000200-0400-0500-0006-000700080009",
"FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF", "00000000-0000-0000-0000-000000000000");
/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.la... |
SystemInfo systemInfo = new SystemInfo();
OperatingSystem operatingSystem = systemInfo.getOperatingSystem();
HardwareAbstractionLayer hardwareAbstractionLayer = systemInfo.getHardware();
CentralProcessor centralProcessor = hardwareAbstractionLayer.getProcessor();
ComputerSystem ... | 491 | 331 | 822 | <no_super_class> |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/DetectVM.java | DetectVM | identifyVM | class DetectVM {
private static final String OSHI_VM_MAC_ADDR_PROPERTIES = "oshi.vmmacaddr.properties";
private static final Properties vmMacAddressProps = FileUtil
.readPropertiesFromFilename(OSHI_VM_MAC_ADDR_PROPERTIES);
// Constant for CPU vendor string
private static final Map<String, ... |
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hw = si.getHardware();
// Check CPU Vendor
String vendor = hw.getProcessor().getProcessorIdentifier().getVendor().trim();
if (vmVendor.containsKey(vendor)) {
return vmVendor.get(vendor);
}
//... | 646 | 343 | 989 | <no_super_class> |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/DiskStoreForPath.java | DiskStoreForPath | main | class DiskStoreForPath {
/**
* Main method
*
* @param args Optional file path
* @throws URISyntaxException on invalid path
*/
@SuppressForbidden(reason = "Using System.out in a demo class")
public static void main(String[] args) throws URISyntaxException {<FILL_FUNCTION_BODY>}
... |
// Use the arg as a file path or get this class's path
String filePath = args.length > 0 ? args[0]
: new File(DiskStoreForPath.class.getProtectionDomain().getCodeSource().getLocation().toURI())
.getPath();
System.out.println("Searching stores for path: " ... | 398 | 465 | 863 | <no_super_class> |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/Json.java | Json | main | class Json {
/**
* <p>
* main.
* </p>
*
* @param args an array of {@link java.lang.String} objects.
*/
@SuppressForbidden(reason = "Using System.out in a demo class")
public static void main(String[] args) {<FILL_FUNCTION_BODY>}
} |
// Jackson ObjectMapper
ObjectMapper mapper = new ObjectMapper();
// Fetch some OSHI objects
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
try {
// Pretty print computer system
System.out.println("JSON for CP... | 97 | 201 | 298 | <no_super_class> |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/OshiGui.java | OshiGui | getJMenu | class OshiGui {
private JFrame mainFrame;
private JButton jMenu;
private SystemInfo si = new SystemInfo();
public static void main(String[] args) {
OshiGui gui = new OshiGui();
gui.init();
SwingUtilities.invokeLater(gui::setVisible);
}
private void setVisible() {
... |
JButton button = new JButton(title);
button.setMnemonic(mnemonic);
button.setToolTipText(toolTip);
button.addActionListener(e -> {
Container contentPane = this.mainFrame.getContentPane();
if (contentPane.getComponents().length <= 0 || contentPane.getComponent(0) ... | 632 | 136 | 768 | <no_super_class> |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/OshiHTTPServer.java | OshiHTTPServer | run | class OshiHTTPServer implements Runnable {
// port to listen connection
private static final int PORT = 8080;
private static final Logger logger = LoggerFactory.getLogger(OshiHTTPServer.class);
// Client Connection via Socket Class
private Socket connect;
public OshiHTTPServer(Socket c) {
... |
try ( // read characters from the client via input stream on the socket
BufferedReader in = new BufferedReader(
new InputStreamReader(connect.getInputStream(), StandardCharsets.UTF_8));
// get character output stream to client (for headers)
... | 310 | 832 | 1,142 | <no_super_class> |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/UserComInit.java | UserComInit | loopWmiQueriesWithUserCom | class UserComInit {
private static final int REPETITIONS = 300;
@SuppressForbidden(reason = "Using System.out in a demo class")
public static void main(String[] args) {
wakeUpCom();
System.out.println("Collecting statistics with default COM setup");
loopWmiQueries();
System... |
// Create instance using existing WmiQueryHandler class for convenience, only to
// be used for COM init/uninit. Not needed if user initializes COM.
WmiQueryHandler handlerForSingleCOMinit = Objects.requireNonNull(WmiQueryHandler.createInstance());
boolean singleComInit = false;
... | 326 | 237 | 563 | <no_super_class> |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/gui/FileStorePanel.java | FileStorePanel | init | class FileStorePanel extends OshiJPanel { // NOSONAR squid:S110
private static final long serialVersionUID = 1L;
private static final String USED = "Used";
private static final String AVAILABLE = "Available";
private static final DecimalFormatSymbols ROOT_SYMBOLS = DecimalFormatSymbols.getInstance(Lo... |
List<OSFileStore> fileStores = fs.getFileStores();
@SuppressWarnings("unchecked")
DefaultPieDataset<String>[] fsData = new DefaultPieDataset[fileStores.size()];
JFreeChart[] fsCharts = new JFreeChart[fsData.length];
JPanel fsPanel = new JPanel();
fsPanel.setLayout(new G... | 669 | 494 | 1,163 | <methods>public void <init>() <variables>protected javax.swing.JLabel msgLabel,protected javax.swing.JPanel msgPanel,private static final long serialVersionUID |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/gui/InterfacePanel.java | InterfacePanel | buildParamsText | class InterfacePanel extends OshiJPanel { // NOSONAR squid:S110
private static final long serialVersionUID = 1L;
private static final int INIT_HASH_SIZE = 100;
private static final String IP_ADDRESS_SEPARATOR = "; ";
private static final String PARAMS = "Network Parameters";
private static final ... |
NetworkParams params = os.getNetworkParams();
StringBuilder sb = new StringBuilder("Host Name: ").append(params.getHostName());
if (!params.getDomainName().isEmpty()) {
sb.append("\nDomain Name: ").append(params.getDomainName());
}
sb.append("\nIPv4 Default Gateway: ... | 1,173 | 193 | 1,366 | <methods>public void <init>() <variables>protected javax.swing.JLabel msgLabel,protected javax.swing.JPanel msgPanel,private static final long serialVersionUID |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/gui/MemoryPanel.java | MemoryPanel | init | class MemoryPanel extends OshiJPanel { // NOSONAR squid:S110
private static final long serialVersionUID = 1L;
private static final String PHYSICAL_MEMORY = "Physical Memory";
private static final String VIRTUAL_MEMORY = "Virtual Memory (Swap)";
private static final String USED = "Used";
private s... |
DefaultPieDataset<String> physMemData = new DefaultPieDataset<>();
DefaultPieDataset<String> virtMemData = new DefaultPieDataset<>();
updateDatasets(memory, physMemData, virtMemData);
JFreeChart physMem = ChartFactory.createPieChart(PHYSICAL_MEMORY, physMemData, true, true, false);
... | 689 | 606 | 1,295 | <methods>public void <init>() <variables>protected javax.swing.JLabel msgLabel,protected javax.swing.JPanel msgPanel,private static final long serialVersionUID |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/gui/OsHwTextPanel.java | OsHwTextPanel | init | class OsHwTextPanel extends OshiJPanel { // NOSONAR squid:S110
private static final long serialVersionUID = 1L;
private static final String OPERATING_SYSTEM = "Operating System";
private static final String HARDWARE_INFORMATION = "Hardware Information";
private static final String PROCESSOR = "Process... |
osPrefix = getOsPrefix(si);
GridBagConstraints osLabel = new GridBagConstraints();
GridBagConstraints osConstraints = new GridBagConstraints();
osConstraints.gridy = 1;
osConstraints.fill = GridBagConstraints.BOTH;
osConstraints.insets = new Insets(0, 0, 15, 15); // T,L... | 838 | 759 | 1,597 | <methods>public void <init>() <variables>protected javax.swing.JLabel msgLabel,protected javax.swing.JPanel msgPanel,private static final long serialVersionUID |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/gui/ProcessorPanel.java | ProcessorPanel | init | class ProcessorPanel extends OshiJPanel { // NOSONAR squid:S110
private static final long serialVersionUID = 1L;
private long[] oldTicks;
private long[][] oldProcTicks;
public ProcessorPanel(SystemInfo si) {
super();
CentralProcessor cpu = si.getHardware().getProcessor();
oldT... |
GridBagConstraints sysConstraints = new GridBagConstraints();
sysConstraints.weightx = 1d;
sysConstraints.weighty = 1d;
sysConstraints.fill = GridBagConstraints.BOTH;
GridBagConstraints procConstraints = (GridBagConstraints) sysConstraints.clone();
procConstraints.grid... | 352 | 614 | 966 | <methods>public void <init>() <variables>protected javax.swing.JLabel msgLabel,protected javax.swing.JPanel msgPanel,private static final long serialVersionUID |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/gui/UsbPanel.java | UsbPanel | init | class UsbPanel extends OshiJPanel { // NOSONAR squid:S110
private static final long serialVersionUID = 1L;
private static final String USB_DEVICES = "USB Devices";
public UsbPanel(SystemInfo si) {
super();
init(si.getHardware());
}
private void init(HardwareAbstractionLayer hal) ... |
JLabel usb = new JLabel(USB_DEVICES);
add(usb, BorderLayout.NORTH);
JTextArea usbArea = new JTextArea(60, 20);
JScrollPane scrollV = new JScrollPane(usbArea);
scrollV.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
DefaultCaret caret = (Def... | 232 | 211 | 443 | <methods>public void <init>() <variables>protected javax.swing.JLabel msgLabel,protected javax.swing.JPanel msgPanel,private static final long serialVersionUID |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/jmx/demo/Client.java | Client | main | class Client {
@SuppressForbidden(reason = "Using System.out in a demo class")
public static void main(String[] args) throws IOException, MalformedObjectNameException, ReflectionException,
InstanceNotFoundException, MBeanException, AttributeNotFoundException {<FILL_FUNCTION_BODY>}
} |
// The address of the connector server
JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:8888/server");
// Map for custom properties key values
Map<String, ?> environment = null;
// Create the JMXCconnectorServer
JMXConnector cntor = JMX... | 79 | 364 | 443 | <no_super_class> |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/jmx/mbeans/Baseboard.java | Baseboard | setUpMBean | class Baseboard implements DynamicMBean, PropertiesAvailable {
private oshi.hardware.Baseboard baseboard;
private MBeanInfo dMBeanInfo = null;
private List<String> propertiesAvailable = new ArrayList<>();
private final String PROPERTIES = "Properties";
private void setUpMBean() throws Introspectio... |
PropertyDescriptor[] methods = Introspector.getBeanInfo(baseboard.getClass()).getPropertyDescriptors();
MBeanAttributeInfo[] attributeInfos = new MBeanAttributeInfo[methods.length];
for (int i = 0; i < methods.length; i++) {
attributeInfos[i] = new MBeanAttributeInfo(methods[i].ge... | 483 | 203 | 686 | <no_super_class> |
oshi_oshi | oshi/oshi-demo/src/main/java/oshi/demo/jmx/strategiesplatform/WindowsStrategyRegistrattionPlatform.java | WindowsStrategyRegistrattionPlatform | registerMBeans | class WindowsStrategyRegistrattionPlatform implements StrategyRegistrationPlatformMBeans {
@Override
public void registerMBeans(SystemInfo systemInfo, MBeanServer mBeanServer)
throws NotCompliantMBeanException, InstanceAlreadyExistsException, MBeanRegistrationException,
MalformedObjectNa... |
// here we can register all the MBeans reletad to windows. for this sample we
// are only gonna register one MBean with two Attribute
ObjectName objectName = new ObjectName("oshi:component=BaseBoard");
oshi.demo.jmx.mbeans.Baseboard baseBoardMBean = new oshi.demo.jmx.mbeans.Baseboard(
... | 104 | 138 | 242 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/authorization/DefaultCasAuthorizationGenerator.java | DefaultCasAuthorizationGenerator | generate | class DefaultCasAuthorizationGenerator implements AuthorizationGenerator {
/** Constant <code>DEFAULT_REMEMBER_ME_ATTRIBUTE_NAME="longTermAuthenticationRequestTokenUsed"</code> */
public static final String DEFAULT_REMEMBER_ME_ATTRIBUTE_NAME = "longTermAuthenticationRequestTokenUsed";
// default name of t... |
val rememberMeValue = (String) profile.getAttribute(rememberMeAttributeName);
val isRemembered = rememberMeValue != null && Boolean.parseBoolean(rememberMeValue);
profile.setRemembered(isRemembered);
return Optional.of(profile);
| 294 | 72 | 366 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/client/CasClient.java | CasClient | internalInit | class CasClient extends IndirectClient {
@Getter
@Setter
private CasConfiguration configuration = new CasConfiguration();
/**
* <p>Constructor for CasClient.</p>
*/
public CasClient() { }
/**
* <p>Constructor for CasClient.</p>
*
* @param configuration a {@link CasCon... |
assertNotNull("configuration", configuration);
configuration.setUrlResolver(this.getUrlResolver());
setRedirectionActionBuilderIfUndefined(new CasRedirectionActionBuilder(configuration, this));
setCredentialsExtractorIfUndefined(new CasCredentialsExtractor(configuration));
setA... | 295 | 197 | 492 | <methods>public non-sealed void <init>() ,public java.lang.String computeFinalCallbackUrl(org.pac4j.core.context.WebContext) ,public java.lang.String getCodeVerifierSessionAttributeName() ,public final Optional<org.pac4j.core.exception.http.RedirectionAction> getLogoutAction(CallContext, org.pac4j.core.profile.UserProf... |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/client/CasProxyReceptor.java | CasProxyReceptor | internalInit | class CasProxyReceptor extends IndirectClient {
/** Constant <code>PARAM_PROXY_GRANTING_TICKET_IOU="pgtIou"</code> */
public static final String PARAM_PROXY_GRANTING_TICKET_IOU = "pgtIou";
/** Constant <code>PARAM_PROXY_GRANTING_TICKET="pgtId"</code> */
public static final String PARAM_PROXY_GRANTING_... |
assertNotNull("store", this.store);
setRedirectionActionBuilderIfUndefined(ctx
-> { throw new TechnicalException("Not supported by the CAS proxy receptor"); });
setCredentialsExtractorIfUndefined(ctx -> {
val webContext = ctx.webContext();
// like CommonUtil... | 206 | 431 | 637 | <methods>public non-sealed void <init>() ,public java.lang.String computeFinalCallbackUrl(org.pac4j.core.context.WebContext) ,public java.lang.String getCodeVerifierSessionAttributeName() ,public final Optional<org.pac4j.core.exception.http.RedirectionAction> getLogoutAction(CallContext, org.pac4j.core.profile.UserProf... |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/client/direct/DirectCasProxyClient.java | DirectCasProxyClient | internalInit | class DirectCasProxyClient extends DirectClient {
private CasConfiguration configuration;
private UrlResolver urlResolver = new DefaultUrlResolver();
private CallbackUrlResolver callbackUrlResolver = new NoParameterCallbackUrlResolver();
private String serviceUrl;
/**
* <p>Constructor for ... |
assertNotBlank("serviceUrl", this.serviceUrl);
assertNotNull("configuration", this.configuration);
// must be a CAS proxy protocol
val protocol = configuration.getProtocol();
assertTrue(protocol == CasProtocol.CAS20_PROXY || protocol == CasProtocol.CAS30_PROXY,
"The ... | 236 | 208 | 444 | <methods>public non-sealed void <init>() ,public final Optional<org.pac4j.core.exception.http.RedirectionAction> getLogoutAction(CallContext, org.pac4j.core.profile.UserProfile, java.lang.String) ,public final Optional<org.pac4j.core.exception.http.RedirectionAction> getRedirectionAction(CallContext) ,public final org.... |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/AbstractCasRestClient.java | AbstractCasRestClient | requestServiceTicket | class AbstractCasRestClient extends DirectClient {
@Getter
@Setter
protected CasConfiguration configuration;
/**
* <p>destroyTicketGrantingTicket.</p>
*
* @param profile a {@link CasRestProfile} object
* @param context a {@link WebContext} object
*/
public void destroyTick... |
HttpURLConnection connection = null;
try {
val endpointURL = new URL(configuration.computeFinalRestUrl(context));
val ticketURL = new URL(endpointURL, endpointURL.getPath() + "/" + profile.getTicketGrantingTicketId());
connection = HttpUtils.openPostConnection(ticke... | 643 | 294 | 937 | <methods>public non-sealed void <init>() ,public final Optional<org.pac4j.core.exception.http.RedirectionAction> getLogoutAction(CallContext, org.pac4j.core.profile.UserProfile, java.lang.String) ,public final Optional<org.pac4j.core.exception.http.RedirectionAction> getRedirectionAction(CallContext) ,public final org.... |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/CasRestBasicAuthClient.java | CasRestBasicAuthClient | internalInit | class CasRestBasicAuthClient extends AbstractCasRestClient {
private String headerName = HttpConstants.AUTHORIZATION_HEADER;
private String prefixHeader = HttpConstants.BASIC_HEADER_PREFIX;
/**
* <p>Constructor for CasRestBasicAuthClient.</p>
*/
public CasRestBasicAuthClient() {}
/**
... |
assertNotBlank("headerName", this.headerName);
assertNotNull("prefixHeader", this.prefixHeader);
assertNotNull("configuration", this.configuration);
setCredentialsExtractorIfUndefined(new BasicAuthExtractor(this.headerName, this.prefixHeader));
setAuthenticatorIfUndefined(new C... | 256 | 93 | 349 | <methods>public non-sealed void <init>() ,public void destroyTicketGrantingTicket(org.pac4j.cas.profile.CasRestProfile, org.pac4j.core.context.WebContext) ,public org.pac4j.core.credentials.TokenCredentials requestServiceTicket(java.lang.String, org.pac4j.cas.profile.CasRestProfile, org.pac4j.core.context.WebContext) ,... |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/CasRestFormClient.java | CasRestFormClient | internalInit | class CasRestFormClient extends AbstractCasRestClient {
private String usernameParameter = Pac4jConstants.USERNAME;
private String passwordParameter = Pac4jConstants.PASSWORD;
/**
* <p>Constructor for CasRestFormClient.</p>
*/
public CasRestFormClient() {}
/**
* <p>Constructor for... |
assertNotBlank("usernameParameter", this.usernameParameter);
assertNotBlank("passwordParameter", this.passwordParameter);
assertNotNull("configuration", this.configuration);
setCredentialsExtractorIfUndefined(new FormExtractor(this.usernameParameter, this.passwordParameter));
s... | 240 | 94 | 334 | <methods>public non-sealed void <init>() ,public void destroyTicketGrantingTicket(org.pac4j.cas.profile.CasRestProfile, org.pac4j.core.context.WebContext) ,public org.pac4j.core.credentials.TokenCredentials requestServiceTicket(java.lang.String, org.pac4j.cas.profile.CasRestProfile, org.pac4j.core.context.WebContext) ,... |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/credentials/authenticator/CasAuthenticator.java | CasAuthenticator | validateTicket | class CasAuthenticator extends ProfileDefinitionAware implements Authenticator {
protected CasConfiguration configuration;
protected String clientName;
protected UrlResolver urlResolver;
protected CallbackUrlResolver callbackUrlResolver;
protected String callbackUrl;
protected SessionLogou... |
val finalCallbackUrl = callbackUrlResolver.compute(urlResolver, callbackUrl, clientName, webContext);
return configuration.retrieveTicketValidator(webContext).validate(ticket, finalCallbackUrl);
| 1,015 | 51 | 1,066 | <methods>public non-sealed void <init>() ,public org.pac4j.core.profile.definition.ProfileDefinition getProfileDefinition() ,public void setProfileDefinition(org.pac4j.core.profile.definition.ProfileDefinition) <variables>private org.pac4j.core.profile.definition.ProfileDefinition profileDefinition |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/credentials/authenticator/CasRestAuthenticator.java | CasRestAuthenticator | validate | class CasRestAuthenticator implements Authenticator {
protected CasConfiguration configuration;
/**
* <p>Constructor for CasRestAuthenticator.</p>
*
* @param configuration a {@link CasConfiguration} object
*/
public CasRestAuthenticator(final CasConfiguration configuration) {
C... |
val credentials = (UsernamePasswordCredentials) cred;
if (credentials == null || credentials.getPassword() == null || credentials.getUsername() == null) {
throw new TechnicalException("Credentials are required");
}
val ticketGrantingTicketId = requestTicketGrantingTicket(cre... | 461 | 159 | 620 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/credentials/extractor/CasCredentialsExtractor.java | CasCredentialsExtractor | extract | class CasCredentialsExtractor implements CredentialsExtractor {
private final static int DECOMPRESSION_FACTOR = 10;
protected CasConfiguration configuration;
/**
* <p>Constructor for CasCredentialsExtractor.</p>
*
* @param configuration a {@link CasConfiguration} object
*/
public ... |
Credentials credentials = null;
val webContext = ctx.webContext();
// like the SingleSignOutFilter from the Apereo CAS client:
if (isTokenRequest(webContext)) {
val ticket = getArtifactParameter(webContext).get();
credentials = new TokenCredentials(ticket);
... | 1,002 | 344 | 1,346 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/logout/processor/CasLogoutProcessor.java | CasLogoutProcessor | processLogout | class CasLogoutProcessor implements LogoutProcessor {
protected CasConfiguration configuration;
protected SessionLogoutHandler sessionLogoutHandler;
/**
* <p>Constructor for CasLogoutProcessor.</p>
*
* @param configuration a {@link CasConfiguration} object
* @param sessionLogoutHandle... |
assertTrue(logoutCredentials instanceof SessionKeyCredentials, "credentials must be of type SessionKeyCredentials");
val credentials = (SessionKeyCredentials) logoutCredentials;
val sessionKey = credentials.getSessionKey();
if (credentials.getLogoutType() == LogoutType.BACK) {
... | 528 | 234 | 762 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/profile/CasProfileDefinition.java | CasProfileDefinition | newProfile | class CasProfileDefinition extends CommonProfileDefinition {
/**
* <p>Constructor for CasProfileDefinition.</p>
*/
public CasProfileDefinition() {
super(parameters -> new CasProfile());
}
/** {@inheritDoc} */
@Override
public UserProfile newProfile(final Object... parameters)... |
val proxyReceptor = (CasProxyReceptor) getParameter(parameters, 1);
if (proxyReceptor != null) {
val profile = new CasProxyProfile();
profile.setPrincipal((AttributePrincipal) getParameter(parameters, 2));
return profile;
} else {
return super.new... | 96 | 93 | 189 | <methods>public void <init>() ,public void <init>(org.pac4j.core.profile.factory.ProfileFactory) <variables>public static final java.lang.String DISPLAY_NAME,public static final java.lang.String EMAIL,public static final java.lang.String FAMILY_NAME,public static final java.lang.String FIRST_NAME,public static final ja... |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/profile/CasProxyProfile.java | CasProxyProfile | getProxyTicketFor | class CasProxyProfile extends CasProfile {
@Serial
private static final long serialVersionUID = 4956675835922254493L;
protected AttributePrincipal attributePrincipal = null;
/**
* Store the CAS principal.
*
* @param attributePrincipal the principal with attributes
*/
public vo... |
if (this.attributePrincipal != null) {
logger.debug("Requesting PT from principal: {} and for service: {}", attributePrincipal, service);
val pt = this.attributePrincipal.getProxyTicketFor(service);
logger.debug("Get PT: {}", pt);
return pt;
}
ret... | 196 | 92 | 288 | <methods>public non-sealed void <init>() <variables>private static final long serialVersionUID |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/profile/CasRestProfile.java | CasRestProfile | equals | class CasRestProfile extends CommonProfile {
@Serial
private static final long serialVersionUID = -1688563185891330018L;
private static final String TGT_KEY = "$tgt_key";
/**
* <p>Constructor for CasRestProfile.</p>
*/
public CasRestProfile() {
}
/**
* <p>Constructor for Ca... |
if (obj == null) {
return false;
}
return obj instanceof CasRestProfile casRestProfile
&& (obj == this || getTicketGrantingTicketId().equals(casRestProfile.getTicketGrantingTicketId()));
| 397 | 66 | 463 | <methods>public void <init>() ,public void <init>(boolean) ,public java.lang.String getDisplayName() ,public java.lang.String getEmail() ,public java.lang.String getFamilyName() ,public java.lang.String getFirstName() ,public org.pac4j.core.profile.Gender getGender() ,public java.util.Locale getLocale() ,public java.la... |
pac4j_pac4j | pac4j/pac4j-cas/src/main/java/org/pac4j/cas/redirect/CasRedirectionActionBuilder.java | CasRedirectionActionBuilder | constructRedirectUrl | class CasRedirectionActionBuilder implements RedirectionActionBuilder {
protected CasConfiguration configuration;
protected CasClient client;
/**
* <p>Constructor for CasRedirectionActionBuilder.</p>
*
* @param configuration a {@link CasConfiguration} object
* @param client a {@link C... |
return casServerLoginUrl + (casServerLoginUrl.contains("?") ? "&" : "?") + serviceParameterName + "="
+ CommonHelper.urlEncode(serviceUrl) + (renew ? "&renew=true" : "") + (gateway ? "&gateway=true" : "")
+ (method != null ? "&method=" + method : "");
| 665 | 99 | 764 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/AbstractBuilder.java | AbstractBuilder | getAuthenticator | class AbstractBuilder implements PropertiesConstants {
/** Constant <code>MAX_NUM_CLIENTS=100</code> */
protected static final int MAX_NUM_CLIENTS = 100;
/** Constant <code>MAX_NUM_AUTHENTICATORS=10</code> */
protected static final int MAX_NUM_AUTHENTICATORS = 10;
/** Constant <code>MAX_NUM_CUSTOM_... |
if (AUTHENTICATOR_TEST_TOKEN.equals(name)) {
return new SimpleTestTokenAuthenticator();
} else if (AUTHENTICATOR_TEST_USERNAME_PASSWORD.equals(name)) {
return new SimpleTestUsernamePasswordAuthenticator();
} else {
return authenticators.get(name);
}
... | 1,067 | 91 | 1,158 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/CasClientBuilder.java | CasClientBuilder | tryCreateCasClient | class CasClientBuilder extends AbstractBuilder {
/**
* <p>Constructor for CasClientBuilder.</p>
*
* @param properties a {@link Map} object
*/
public CasClientBuilder(final Map<String, String> properties) {
super(properties);
}
/**
* <p>tryCreateCasClient.</p>
*
... |
for (var i = 0; i <= MAX_NUM_CLIENTS; i++) {
val loginUrl = getProperty(CAS_LOGIN_URL, i);
val protocol = getProperty(CAS_PROTOCOL, i);
if (isNotBlank(loginUrl)) {
var configuration = new CasConfiguration();
val casClient = new CasClient(confi... | 147 | 170 | 317 | <methods><variables>protected static final int MAX_NUM_AUTHENTICATORS,protected static final int MAX_NUM_CLIENTS,protected static final int MAX_NUM_CUSTOM_PROPERTIES,protected static final int MAX_NUM_ENCODERS,protected final non-sealed Map<java.lang.String,org.pac4j.core.credentials.authenticator.Authenticator> authen... |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/DbAuthenticatorBuilder.java | DbAuthenticatorBuilder | buildDataSource | class DbAuthenticatorBuilder extends AbstractBuilder {
/**
* <p>Constructor for DbAuthenticatorBuilder.</p>
*
* @param properties a {@link Map} object
*/
public DbAuthenticatorBuilder(final Map<String, String> properties) {
super(properties);
}
/**
* <p>tryBuildDbAuthe... |
val ds = new HikariDataSource();
if (containsProperty(DB_DATASOURCE_CLASS_NAME, i)) {
ds.setDataSourceClassName(getProperty(DB_DATASOURCE_CLASS_NAME, i));
} else if (containsProperty(DB_JDBC_URL, i)) {
ds.setJdbcUrl(getProperty(DB_JDBC_URL, i));
}
if (con... | 620 | 1,315 | 1,935 | <methods><variables>protected static final int MAX_NUM_AUTHENTICATORS,protected static final int MAX_NUM_CLIENTS,protected static final int MAX_NUM_CUSTOM_PROPERTIES,protected static final int MAX_NUM_ENCODERS,protected final non-sealed Map<java.lang.String,org.pac4j.core.credentials.authenticator.Authenticator> authen... |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/DirectClientBuilder.java | DirectClientBuilder | tryCreateAnonymousClient | class DirectClientBuilder extends AbstractBuilder {
/**
* <p>Constructor for DirectClientBuilder.</p>
*
* @param properties a {@link Map} object
* @param authenticators a {@link Map} object
*/
public DirectClientBuilder(final Map<String, String> properties, final Map<String, Authentica... |
val anonymous = getProperty(ANONYMOUS);
if (isNotBlank(anonymous)) {
clients.add(new AnonymousClient());
}
| 377 | 44 | 421 | <methods><variables>protected static final int MAX_NUM_AUTHENTICATORS,protected static final int MAX_NUM_CLIENTS,protected static final int MAX_NUM_CUSTOM_PROPERTIES,protected static final int MAX_NUM_ENCODERS,protected final non-sealed Map<java.lang.String,org.pac4j.core.credentials.authenticator.Authenticator> authen... |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/IndirectHttpClientBuilder.java | IndirectHttpClientBuilder | tryCreateIndirectBasicAuthClient | class IndirectHttpClientBuilder extends AbstractBuilder {
/**
* <p>Constructor for IndirectHttpClientBuilder.</p>
*
* @param properties a {@link Map} object
* @param authenticators a {@link Map} object
*/
public IndirectHttpClientBuilder(final Map<String, String> properties, final Map<... |
for (var i = 0; i <= MAX_NUM_CLIENTS; i++) {
val authenticator = getProperty(INDIRECTBASICAUTH_AUTHENTICATOR, i);
if (isNotBlank(authenticator)) {
val indirectBasicAuthClient = new IndirectBasicAuthClient();
indirectBasicAuthClient.setAuthenticator(getAut... | 507 | 202 | 709 | <methods><variables>protected static final int MAX_NUM_AUTHENTICATORS,protected static final int MAX_NUM_CLIENTS,protected static final int MAX_NUM_CUSTOM_PROPERTIES,protected static final int MAX_NUM_ENCODERS,protected final non-sealed Map<java.lang.String,org.pac4j.core.credentials.authenticator.Authenticator> authen... |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/OAuthBuilder.java | OAuthBuilder | tryCreateLinkedInClient | class OAuthBuilder extends AbstractBuilder {
/**
* <p>Constructor for OAuthBuilder.</p>
*
* @param properties a {@link Map} object
*/
public OAuthBuilder(final Map<String, String> properties) {
super(properties);
}
/**
* <p>tryCreateLinkedInClient.</p>
*
* @p... |
val id = getProperty(LINKEDIN_ID);
val secret = getProperty(LINKEDIN_SECRET);
val scope = getProperty(LINKEDIN_SCOPE);
if (isNotBlank(id) && isNotBlank(secret)) {
val linkedInClient = new LinkedIn2Client(id, secret);
if (isNotBlank(scope)) {
link... | 1,877 | 129 | 2,006 | <methods><variables>protected static final int MAX_NUM_AUTHENTICATORS,protected static final int MAX_NUM_CLIENTS,protected static final int MAX_NUM_CUSTOM_PROPERTIES,protected static final int MAX_NUM_ENCODERS,protected final non-sealed Map<java.lang.String,org.pac4j.core.credentials.authenticator.Authenticator> authen... |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/OidcClientBuilder.java | OidcClientBuilder | tryCreateOidcClient | class OidcClientBuilder extends AbstractBuilder {
/**
* <p>Constructor for OidcClientBuilder.</p>
*
* @param properties a {@link Map} object
*/
public OidcClientBuilder(final Map<String, String> properties) {
super(properties);
}
/**
* <p>tryCreateOidcClient.</p>
... |
for (var i = 0; i <= MAX_NUM_CLIENTS; i++) {
val id = getProperty(OIDC_ID, i);
if (isNotBlank(id)) {
val configuration = new OidcConfiguration();
configuration.setClientId(id);
val secret = getProperty(OIDC_SECRET, i);
if ... | 155 | 917 | 1,072 | <methods><variables>protected static final int MAX_NUM_AUTHENTICATORS,protected static final int MAX_NUM_CLIENTS,protected static final int MAX_NUM_CUSTOM_PROPERTIES,protected static final int MAX_NUM_ENCODERS,protected final non-sealed Map<java.lang.String,org.pac4j.core.credentials.authenticator.Authenticator> authen... |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/RestAuthenticatorBuilder.java | RestAuthenticatorBuilder | tryBuildRestAuthenticator | class RestAuthenticatorBuilder extends AbstractBuilder {
/**
* <p>Constructor for RestAuthenticatorBuilder.</p>
*
* @param properties a {@link Map} object
*/
public RestAuthenticatorBuilder(final Map<String, String> properties) {
super(properties);
}
/**
* <p>tryBuildR... |
for (var i = 0; i <= MAX_NUM_AUTHENTICATORS; i++) {
val url = getProperty(REST_URL, i);
if (isNotBlank(url)) {
authenticators.put(concat("rest", i), new RestAuthenticator(url));
}
}
| 157 | 83 | 240 | <methods><variables>protected static final int MAX_NUM_AUTHENTICATORS,protected static final int MAX_NUM_CLIENTS,protected static final int MAX_NUM_CUSTOM_PROPERTIES,protected static final int MAX_NUM_ENCODERS,protected final non-sealed Map<java.lang.String,org.pac4j.core.credentials.authenticator.Authenticator> authen... |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/Saml2ClientBuilder.java | Saml2ClientBuilder | tryCreateSaml2Client | class Saml2ClientBuilder extends AbstractBuilder {
/**
* <p>Constructor for Saml2ClientBuilder.</p>
*
* @param properties a {@link Map} object
*/
public Saml2ClientBuilder(final Map<String, String> properties) {
super(properties);
}
/**
* <p>tryCreateSaml2Client.</p>
... |
for (var i = 0; i <= MAX_NUM_CLIENTS; i++) {
val keystorePassword = getProperty(SAML_KEYSTORE_PASSWORD, i);
val privateKeyPassword = getProperty(SAML_PRIVATE_KEY_PASSWORD, i);
val keystorePath = getProperty(SAML_KEYSTORE_PATH, i);
val identityProviderMetadataPath... | 155 | 1,590 | 1,745 | <methods><variables>protected static final int MAX_NUM_AUTHENTICATORS,protected static final int MAX_NUM_CLIENTS,protected static final int MAX_NUM_CUSTOM_PROPERTIES,protected static final int MAX_NUM_ENCODERS,protected final non-sealed Map<java.lang.String,org.pac4j.core.credentials.authenticator.Authenticator> authen... |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/ShiroEncoderBuilder.java | ShiroEncoderBuilder | tryCreatePasswordEncoder | class ShiroEncoderBuilder extends AbstractBuilder {
/**
* <p>Constructor for ShiroEncoderBuilder.</p>
*
* @param properties a {@link Map} object
*/
public ShiroEncoderBuilder(final Map<String, String> properties) {
super(properties);
}
/**
* <p>tryCreatePasswordEncoder... |
for (var i = 0; i <= MAX_NUM_ENCODERS; i++) {
val exists = getProperty(SHIRO_ENCODER, i);
val hasProperty = containsProperty(SHIRO_ENCODER_GENERATE_PUBLIC_SALT, i)
|| containsProperty(SHIRO_ENCODER_HASH_ALGORITHM_NAME, i)
|| containsProperty(SHIRO_ENCODE... | 158 | 519 | 677 | <methods><variables>protected static final int MAX_NUM_AUTHENTICATORS,protected static final int MAX_NUM_CLIENTS,protected static final int MAX_NUM_CUSTOM_PROPERTIES,protected static final int MAX_NUM_ENCODERS,protected final non-sealed Map<java.lang.String,org.pac4j.core.credentials.authenticator.Authenticator> authen... |
pac4j_pac4j | pac4j/pac4j-config/src/main/java/org/pac4j/config/builder/SpringEncoderBuilder.java | SpringEncoderBuilder | tryCreatePasswordEncoder | class SpringEncoderBuilder extends AbstractBuilder {
/**
* <p>Constructor for SpringEncoderBuilder.</p>
*
* @param properties a {@link Map} object
*/
public SpringEncoderBuilder(final Map<String, String> properties) {
super(properties);
}
/**
* <p>tryCreatePasswordEnco... |
for (var i = 0; i <= MAX_NUM_ENCODERS; i++) {
val type = getProperty(SPRING_ENCODER_TYPE, i);
if (isNotBlank(type)) {
final PasswordEncoder encoder;
if (SpringEncoderType.NOOP.toString().equalsIgnoreCase(type)) {
LOGGER.debug("Please n... | 168 | 1,059 | 1,227 | <methods><variables>protected static final int MAX_NUM_AUTHENTICATORS,protected static final int MAX_NUM_CLIENTS,protected static final int MAX_NUM_CUSTOM_PROPERTIES,protected static final int MAX_NUM_ENCODERS,protected final non-sealed Map<java.lang.String,org.pac4j.core.credentials.authenticator.Authenticator> authen... |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/adapter/DefaultFrameworkAdapter.java | DefaultFrameworkAdapter | compareManagers | class DefaultFrameworkAdapter extends FrameworkAdapter {
/** {@inheritDoc} */
@Override
public int compareManagers(final Object obj1, final Object obj2) {<FILL_FUNCTION_BODY>}
/** {@inheritDoc} */
@Override
public void applyDefaultSettingsIfUndefined(final Config config) {
CommonHelper... |
if (obj1 != null && obj2 != null) {
return obj2.getClass().getSimpleName().compareTo(obj1.getClass().getSimpleName());
} else {
return 0;
}
| 216 | 60 | 276 | <methods>public non-sealed void <init>() ,public abstract void applyDefaultSettingsIfUndefined(org.pac4j.core.config.Config) ,public abstract int compareManagers(java.lang.Object, java.lang.Object) <variables>public static final non-sealed org.pac4j.core.adapter.FrameworkAdapter INSTANCE |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/AbstractCheckAuthenticationAuthorizer.java | AbstractCheckAuthenticationAuthorizer | handleError | class AbstractCheckAuthenticationAuthorizer extends ProfileAuthorizer {
private String redirectionUrl;
/**
* <p>Constructor for AbstractCheckAuthenticationAuthorizer.</p>
*/
public AbstractCheckAuthenticationAuthorizer() {}
/**
* <p>Constructor for AbstractCheckAuthenticationAuthorizer... |
if (this.redirectionUrl != null) {
throw HttpActionHelper.buildRedirectUrlAction(context, this.redirectionUrl);
} else {
return false;
}
| 175 | 51 | 226 | <methods>public non-sealed void <init>() ,public boolean isAllAuthorized(org.pac4j.core.context.WebContext, org.pac4j.core.context.session.SessionStore, Iterable<org.pac4j.core.profile.UserProfile>) ,public boolean isAnyAuthorized(org.pac4j.core.context.WebContext, org.pac4j.core.context.session.SessionStore, Iterable<... |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/AbstractRequireAllAuthorizer.java | AbstractRequireAllAuthorizer | isProfileAuthorized | class AbstractRequireAllAuthorizer<E extends Object> extends AbstractRequireElementAuthorizer<E> {
/** {@inheritDoc} */
@Override
protected boolean isProfileAuthorized(final WebContext context, final SessionStore sessionStore, final UserProfile profile) {<FILL_FUNCTION_BODY>}
} |
if (elements == null || elements.isEmpty()) {
return true;
}
for (val element : elements) {
if (!check(context, sessionStore, profile, element)) {
return false;
}
}
return true;
| 75 | 66 | 141 | <methods>public non-sealed void <init>() ,public Set<E> getElements() ,public boolean isAuthorized(org.pac4j.core.context.WebContext, org.pac4j.core.context.session.SessionStore, List<org.pac4j.core.profile.UserProfile>) ,public void setElements(Set<E>) ,public void setElements(List<E>) ,public transient void setElemen... |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/AbstractRequireAnyAuthorizer.java | AbstractRequireAnyAuthorizer | isProfileAuthorized | class AbstractRequireAnyAuthorizer<E extends Object> extends AbstractRequireElementAuthorizer<E> {
/** {@inheritDoc} */
@Override
protected boolean isProfileAuthorized(final WebContext context, final SessionStore sessionStore, final UserProfile profile) {<FILL_FUNCTION_BODY>}
} |
if (elements == null || elements.isEmpty()) {
return check(context, sessionStore, profile, null);
}
for (val element : elements) {
if (check(context, sessionStore, profile, element)) {
return true;
}
}
return false;
| 75 | 75 | 150 | <methods>public non-sealed void <init>() ,public Set<E> getElements() ,public boolean isAuthorized(org.pac4j.core.context.WebContext, org.pac4j.core.context.session.SessionStore, List<org.pac4j.core.profile.UserProfile>) ,public void setElements(Set<E>) ,public void setElements(List<E>) ,public transient void setElemen... |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/AbstractRequireElementAuthorizer.java | AbstractRequireElementAuthorizer | setElements | class AbstractRequireElementAuthorizer<E extends Object> extends ProfileAuthorizer {
protected Set<E> elements;
/** {@inheritDoc} */
@Override
public boolean isAuthorized(final WebContext context, final SessionStore sessionStore, final List<UserProfile> profiles) {
return isAnyAuthorized(conte... |
if (elements != null) {
this.elements = new HashSet<>(elements);
}
| 478 | 29 | 507 | <methods>public non-sealed void <init>() ,public boolean isAllAuthorized(org.pac4j.core.context.WebContext, org.pac4j.core.context.session.SessionStore, Iterable<org.pac4j.core.profile.UserProfile>) ,public boolean isAnyAuthorized(org.pac4j.core.context.WebContext, org.pac4j.core.context.session.SessionStore, Iterable<... |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/AndAuthorizer.java | AndAuthorizer | isAuthorized | class AndAuthorizer implements Authorizer {
private final List<Authorizer> authorizers;
/**
* <p>Constructor for AndAuthorizer.</p>
*
* @param authorizers a {@link List} object
*/
public AndAuthorizer(List<Authorizer> authorizers) {
this.authorizers = authorizers;
}
/*... |
for (var authorizer : authorizers) {
if (!authorizer.isAuthorized(context, sessionStore, profiles)) return false;
}
return true;
| 225 | 44 | 269 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/CsrfAuthorizer.java | CsrfAuthorizer | isAuthorized | class CsrfAuthorizer implements Authorizer {
private String parameterName = Pac4jConstants.CSRF_TOKEN;
private String headerName = Pac4jConstants.CSRF_TOKEN;
private boolean checkAllRequests = false;
/**
* <p>Constructor for CsrfAuthorizer.</p>
*/
public CsrfAuthorizer() {
}
/... |
val checkRequest = checkAllRequests || isPost(context) || isPut(context) || isPatch(context) || isDelete(context);
if (checkRequest) {
val parameterToken = context.getRequestParameter(parameterName).orElse(null);
val headerToken = context.getRequestHeader(headerName).orElse(null... | 480 | 547 | 1,027 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/IsFullyAuthenticatedAuthorizer.java | IsFullyAuthenticatedAuthorizer | isProfileAuthorized | class IsFullyAuthenticatedAuthorizer extends AbstractCheckAuthenticationAuthorizer {
/**
* <p>Constructor for IsFullyAuthenticatedAuthorizer.</p>
*/
public IsFullyAuthenticatedAuthorizer() {}
/**
* <p>Constructor for IsFullyAuthenticatedAuthorizer.</p>
*
* @param redirectionUrl a ... |
return profile != null && !(profile instanceof AnonymousProfile) && !profile.isRemembered();
| 326 | 28 | 354 | <methods>public void <init>() ,public void <init>(java.lang.String) <variables>private java.lang.String redirectionUrl |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/IsRememberedAuthorizer.java | IsRememberedAuthorizer | isProfileAuthorized | class IsRememberedAuthorizer extends AbstractCheckAuthenticationAuthorizer {
/**
* <p>Constructor for IsRememberedAuthorizer.</p>
*/
public IsRememberedAuthorizer() {}
/**
* <p>Constructor for IsRememberedAuthorizer.</p>
*
* @param redirectionUrl a {@link String} object
*/
... |
return profile != null && !(profile instanceof AnonymousProfile) && profile.isRemembered();
| 306 | 27 | 333 | <methods>public void <init>() ,public void <init>(java.lang.String) <variables>private java.lang.String redirectionUrl |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/OrAuthorizer.java | OrAuthorizer | isAuthorized | class OrAuthorizer implements Authorizer {
private final List<Authorizer> authorizers;
/**
* <p>Constructor for OrAuthorizer.</p>
*
* @param authorizers a {@link List} object
*/
public OrAuthorizer(List<Authorizer> authorizers) {
this.authorizers = authorizers;
}
/** {... |
for (val authorizer : authorizers) {
if (authorizer.isAuthorized(context, sessionStore, profiles)) return true;
}
return false;
| 227 | 44 | 271 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/ProfileAuthorizer.java | ProfileAuthorizer | isAnyAuthorized | class ProfileAuthorizer implements Authorizer {
/**
* If all profiles are authorized.
*
* @param context the web context
* @param sessionStore the session store
* @param profiles the user profiles
* @return whether all profiles are authorized
*/
public boolean isAllAuthorized... |
for (val profile : profiles) {
if (isProfileAuthorized(context, sessionStore, profile)) {
return true;
}
}
return handleError(context, sessionStore);
| 411 | 52 | 463 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/RequireAnyAttributeAuthorizer.java | RequireAnyAttributeAuthorizer | check | class RequireAnyAttributeAuthorizer extends AbstractRequireAnyAuthorizer<String> {
private final String valueToMatch;
/**
* <p>Constructor for RequireAnyAttributeAuthorizer.</p>
*/
public RequireAnyAttributeAuthorizer() {
this(".+");
}
/**
* <p>Constructor for RequireAnyAttr... |
if (!profile.containsAttribute(element)) {
return false;
}
if (CommonHelper.isBlank(this.valueToMatch)) {
return true;
}
val attributeValues = profile.getAttribute(element);
if (attributeValues instanceof Collection) {
return Collect... | 294 | 133 | 427 | <methods>public non-sealed void <init>() <variables> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/RequireAnyRoleAuthorizer.java | RequireAnyRoleAuthorizer | check | class RequireAnyRoleAuthorizer extends AbstractRequireAnyAuthorizer<String> {
/**
* <p>Constructor for RequireAnyRoleAuthorizer.</p>
*/
public RequireAnyRoleAuthorizer() { }
/**
* <p>Constructor for RequireAnyRoleAuthorizer.</p>
*
* @param roles a {@link String} object
*/
... |
val profileRoles = profile.getRoles();
if( profileRoles.isEmpty() ) {
return false;
}
if( element == null ) {
return true;
}
return profileRoles.contains(element);
| 582 | 64 | 646 | <methods>public non-sealed void <init>() <variables> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/generator/DefaultRolesAuthorizationGenerator.java | DefaultRolesAuthorizationGenerator | generate | class DefaultRolesAuthorizationGenerator implements AuthorizationGenerator {
private Collection<String> defaultRoles;
/**
* <p>Constructor for DefaultRolesAuthorizationGenerator.</p>
*/
public DefaultRolesAuthorizationGenerator() {}
/**
* <p>Constructor for DefaultRolesAuthorizationGen... |
if (defaultRoles != null) {
profile.addRoles(defaultRoles);
}
return Optional.of(profile);
| 383 | 39 | 422 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/generator/FromAttributesAuthorizationGenerator.java | FromAttributesAuthorizationGenerator | generateAuth | class FromAttributesAuthorizationGenerator implements AuthorizationGenerator {
private Collection<String> roleAttributes;
private String splitChar = ",";
/**
* <p>Constructor for FromAttributesAuthorizationGenerator.</p>
*/
public FromAttributesAuthorizationGenerator() {
this.roleAt... |
if (attributes == null) {
return;
}
for (val attribute : attributes) {
val value = profile.getAttribute(attribute);
if (value != null) {
if (value instanceof String) {
val st = new StringTokenizer((String) value, this.spli... | 387 | 261 | 648 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/generator/LoadLinkedUserAuthorizationGenerator.java | LoadLinkedUserAuthorizationGenerator | generate | class LoadLinkedUserAuthorizationGenerator implements AuthorizationGenerator {
private ProfileService profileService;
private boolean failIfLinkedUserNotFound = true;
/**
* <p>Constructor for LoadLinkedUserAuthorizationGenerator.</p>
*/
public LoadLinkedUserAuthorizationGenerator() {}
... |
CommonHelper.assertNotNull("profileService", profileService);
val linkedProfile = profileService.findByLinkedId(profile.getId());
if (linkedProfile != null) {
return Optional.ofNullable(linkedProfile);
} else {
if (failIfLinkedUserNotFound) {
th... | 199 | 124 | 323 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/authorization/generator/SpringSecurityPropertiesAuthorizationGenerator.java | SpringSecurityPropertiesAuthorizationGenerator | generate | class SpringSecurityPropertiesAuthorizationGenerator implements AuthorizationGenerator {
/** Constant <code>DISABLED="disabled"</code> */
public final static String DISABLED = "disabled";
/** Constant <code>ENABLED="enabled"</code> */
public final static String ENABLED = "enabled";
private Map<Str... |
val id = profile.getId();
val roles = rolesByUsers.get(id);
if (roles != null && !roles.isEmpty()) {
profile.addRoles(roles);
}
return Optional.of(profile);
| 387 | 65 | 452 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/client/Clients.java | Clients | internalInit | class Clients extends InitializableObject {
private volatile List<Client> clients = new ArrayList<>();
private Map<String, Client> clientsMap;
private volatile Integer oldClientsHash;
private String callbackUrl;
private AjaxRequestResolver ajaxRequestResolver;
private UrlResolver urlResolv... |
clientsMap = new HashMap<>();
for (val client : this.clients) {
val name = client.getName();
CommonHelper.assertNotBlank("name", name);
val lowerTrimmedName = name.toLowerCase().trim();
if (clientsMap.containsKey(lowerTrimmedName)) {
throw... | 1,469 | 371 | 1,840 | <methods>public non-sealed void <init>() ,public int getNbAttempts() ,public void init() ,public void init(boolean) ,public final boolean isInitialized() ,public void reinit() <variables>private java.util.concurrent.atomic.AtomicBoolean initialized,private volatile java.lang.Long lastAttempt,private int maxAttempts,pri... |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/client/DirectClient.java | DirectClient | afterInternalInit | class DirectClient extends BaseClient {
/** {@inheritDoc} */
@Override
protected void beforeInternalInit(final boolean forceReinit) {
if (saveProfileInSession == null) {
saveProfileInSession = false;
}
}
/** {@inheritDoc} */
@Override
protected final void afterI... |
// ensures components have been properly initialized
assertNotNull("credentialsExtractor", getCredentialsExtractor());
assertNotNull("authenticator", getAuthenticator());
assertNotNull("profileCreator", getProfileCreator());
| 281 | 56 | 337 | <methods>public non-sealed void <init>() ,public void addAuthorizationGenerator(org.pac4j.core.authorization.generator.AuthorizationGenerator) ,public void addAuthorizationGenerators(Collection<org.pac4j.core.authorization.generator.AuthorizationGenerator>) ,public org.pac4j.core.logout.handler.SessionLogoutHandler fin... |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/client/direct/AnonymousClient.java | AnonymousClient | internalInit | class AnonymousClient extends DirectClient {
/** Constant <code>INSTANCE</code> */
public static final AnonymousClient INSTANCE = new AnonymousClient();
private static boolean warned;
/**
* <p>Constructor for AnonymousClient.</p>
*/
public AnonymousClient() {
if (!warned) {
... |
setCredentialsExtractorIfUndefined(ctx -> Optional.of(AnonymousCredentials.INSTANCE));
setAuthenticatorIfUndefined((ctx, cred) -> {
cred.setUserProfile(AnonymousProfile.INSTANCE);
return Optional.of(AnonymousCredentials.INSTANCE);
});
| 179 | 81 | 260 | <methods>public non-sealed void <init>() ,public final Optional<org.pac4j.core.exception.http.RedirectionAction> getLogoutAction(CallContext, org.pac4j.core.profile.UserProfile, java.lang.String) ,public final Optional<org.pac4j.core.exception.http.RedirectionAction> getRedirectionAction(CallContext) ,public final org.... |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/client/finder/DefaultCallbackClientFinder.java | DefaultCallbackClientFinder | find | class DefaultCallbackClientFinder implements ClientFinder {
/**
* <p>Constructor for DefaultCallbackClientFinder.</p>
*/
public DefaultCallbackClientFinder() {}
/** {@inheritDoc} */
@Override
public List<Client> find(final Clients clients, final WebContext context, final String clientNam... |
List<Client> result = new ArrayList<>();
List<Client> indirectClients = new ArrayList<>();
for (val client : clients.findAllClients()) {
if (client instanceof IndirectClient indirectClient) {
indirectClients.add(client);
indirectClient.init();
... | 100 | 339 | 439 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/client/finder/DefaultSecurityClientFinder.java | DefaultSecurityClientFinder | find | class DefaultSecurityClientFinder implements ClientFinder {
private String clientNameParameter = Pac4jConstants.DEFAULT_FORCE_CLIENT_PARAMETER;
/** {@inheritDoc} */
@Override
public List<Client> find(final Clients clients, final WebContext context, final String clientNames) {<FILL_FUNCTION_BODY>}
} |
final List<Client> result = new ArrayList<>();
var securityClientNames = clientNames;
// we don't have defined clients to secure the URL, use the general default security ones from the Clients if they exist
// we check the nullity and not the blankness to allow the blank string to mean... | 91 | 588 | 679 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/config/ConfigBuilder.java | ConfigBuilder | build | class ConfigBuilder {
/**
* <p>build.</p>
*
* @param factoryName a {@link String} object
* @param parameters a {@link Object} object
* @return a {@link Config} object
*/
@SuppressWarnings("unchecked")
public synchronized static Config build(final String factoryName, final Obje... |
try {
LOGGER.info("Build the configuration from factory: {}", factoryName);
val factory = (ConfigFactory) CommonHelper.getConstructor(factoryName).newInstance();
return factory.build(parameters);
} catch (final Exception e) {
throw new TechnicalException... | 109 | 82 | 191 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/context/WebContextHelper.java | WebContextHelper | isQueryStringParameter | class WebContextHelper implements HttpConstants {
private static final ZoneId GMT = ZoneId.of("GMT");
/**
* Date formats with time zone as specified in the HTTP RFC to use for formatting.
* @see <a href="https://tools.ietf.org/html/rfc7231#section-7.1.1.1">Section 7.1.1.1 of RFC 7231</a>
*/
... |
val queryString = context.getQueryString();
return queryString.filter(s -> context.getRequestParameter(name).isPresent() && s.contains(name + '=')).isPresent();
| 1,739 | 51 | 1,790 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/credentials/AnonymousCredentials.java | AnonymousCredentials | equals | class AnonymousCredentials extends Credentials {
@Serial
private static final long serialVersionUID = 7526472295622776147L;
/** Constant <code>INSTANCE</code> */
public final static AnonymousCredentials INSTANCE = new AnonymousCredentials();
/** {@inheritDoc} */
@Override
public boolean e... |
if (o instanceof AnonymousCredentials) {
return true;
}
return false;
| 148 | 28 | 176 | <methods>public non-sealed void <init>() ,public boolean isForAuthentication() <variables>protected org.pac4j.core.logout.LogoutType logoutType,private static final long serialVersionUID,protected java.lang.String source,private org.pac4j.core.profile.UserProfile userProfile |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/credentials/authenticator/LocalCachingAuthenticator.java | LocalCachingAuthenticator | validate | class LocalCachingAuthenticator extends InitializableObject implements Authenticator {
private Authenticator delegate;
private int cacheSize;
private int timeout;
private TimeUnit timeUnit;
private Store<Credentials, UserProfile> store;
/**
* <p>Constructor for LocalCachingAuthenticator.... |
init();
var optProfile = this.store.get(credentials);
if (optProfile.isEmpty()) {
LOGGER.debug("No cached credentials found. Delegating authentication to {}...", delegate);
delegate.validate(ctx, credentials);
val profile = credentials.getUserProfile();
... | 641 | 161 | 802 | <methods>public non-sealed void <init>() ,public int getNbAttempts() ,public void init() ,public void init(boolean) ,public final boolean isInitialized() ,public void reinit() <variables>private java.util.concurrent.atomic.AtomicBoolean initialized,private volatile java.lang.Long lastAttempt,private int maxAttempts,pri... |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/credentials/extractor/BasicAuthExtractor.java | BasicAuthExtractor | extract | class BasicAuthExtractor implements CredentialsExtractor {
private final HeaderExtractor extractor;
public BasicAuthExtractor() {
this(HttpConstants.AUTHORIZATION_HEADER, HttpConstants.BASIC_HEADER_PREFIX);
}
public BasicAuthExtractor(final String headerName, final String prefixHeader) {
... |
val optCredentials = this.extractor.extract(ctx);
return optCredentials.map(cred -> {
val credentials = (TokenCredentials) cred;
final byte[] decoded;
try {
decoded = Base64.getDecoder().decode(credentials.getToken());
} catch (IllegalArg... | 144 | 231 | 375 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/credentials/extractor/FormExtractor.java | FormExtractor | extract | class FormExtractor implements CredentialsExtractor {
private final String usernameParameter;
private final String passwordParameter;
@Setter
private ExtractionMode extractionMode = ExtractionMode.ALL;
@Override
public Optional<Credentials> extract(final CallContext ctx) {<FILL_FUNCTION_BODY... |
val webContext = ctx.webContext();
var username = Optional.<String>empty();
var password = Optional.<String>empty();
switch (extractionMode) {
case ALL:
username = webContext.getRequestParameter(this.usernameParameter);
password = webContext.... | 117 | 405 | 522 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/credentials/extractor/HeaderExtractor.java | HeaderExtractor | extract | class HeaderExtractor implements CredentialsExtractor {
private String headerName;
private String prefixHeader;
private boolean trimValue;
/**
* <p>Getter for the field <code>headerName</code>.</p>
*
* @return a {@link String} object
*/
public String getHeaderName() {
... |
CommonHelper.assertNotBlank("headerName", this.headerName);
CommonHelper.assertNotNull("prefixHeader", this.prefixHeader);
var header = ctx.webContext().getRequestHeader(this.headerName);
if (header.isEmpty()) {
header = ctx.webContext().getRequestHeader(this.headerName.toL... | 624 | 217 | 841 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/credentials/extractor/ParameterExtractor.java | ParameterExtractor | extract | class ParameterExtractor implements CredentialsExtractor {
private final String parameterName;
private boolean supportGetRequest;
private boolean supportPostRequest;
/**
* <p>Constructor for ParameterExtractor.</p>
*
* @param parameterName a {@link String} object
*/
public Pa... |
val webContext = ctx.webContext();
if (WebContextHelper.isGet(webContext) && !supportGetRequest) {
throw new CredentialsException("GET requests not supported");
} else if (WebContextHelper.isPost(webContext) && !supportPostRequest) {
throw new CredentialsException("POST ... | 276 | 144 | 420 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/engine/AbstractExceptionAwareLogic.java | AbstractExceptionAwareLogic | handleException | class AbstractExceptionAwareLogic {
private String errorUrl;
/**
* Handle exceptions.
*
* @param e the thrown exception
* @param httpActionAdapter the HTTP action adapter
* @param context the web context
* @return the final HTTP result
*/
protected Object handleException... |
if (httpActionAdapter == null || context == null) {
throw runtimeException(e);
} else if (e instanceof HttpAction httpAction) {
LOGGER.debug("extra HTTP action required in security: {}", httpAction.getCode());
return httpActionAdapter.adapt(httpAction, context);
... | 439 | 149 | 588 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/engine/DefaultCallbackLogic.java | DefaultCallbackLogic | perform | class DefaultCallbackLogic extends AbstractExceptionAwareLogic implements CallbackLogic {
/** Constant <code>INSTANCE</code> */
public static final DefaultCallbackLogic INSTANCE = new DefaultCallbackLogic();
private ClientFinder clientFinder = new DefaultCallbackClientFinder();
private SavedRequestHa... |
LOGGER.debug("=== CALLBACK ===");
// checks
val ctx = buildContext(config, parameters);
val webContext = ctx.webContext();
val httpActionAdapter = config.getHttpActionAdapter();
assertNotNull("httpActionAdapter", httpActionAdapter);
HttpAction action;
... | 875 | 680 | 1,555 | <methods>public non-sealed void <init>() <variables>private java.lang.String errorUrl |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/engine/DefaultLogoutLogic.java | DefaultLogoutLogic | perform | class DefaultLogoutLogic extends AbstractExceptionAwareLogic implements LogoutLogic {
/** Constant <code>INSTANCE</code> */
public static final LogoutLogic INSTANCE = new DefaultLogoutLogic();
/** {@inheritDoc} */
@Override
public Object perform(final Config config, final String defaultUrl, final ... |
LOGGER.debug("=== LOGOUT ===");
// checks
val ctx = buildContext(config, parameters);
val webContext = ctx.webContext();
val httpActionAdapter = config.getHttpActionAdapter();
assertNotNull("httpActionAdapter", httpActionAdapter);
HttpAction action;
tr... | 261 | 1,012 | 1,273 | <methods>public non-sealed void <init>() <variables>private java.lang.String errorUrl |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/engine/DefaultSecurityLogic.java | DefaultSecurityLogic | perform | class DefaultSecurityLogic extends AbstractExceptionAwareLogic implements SecurityLogic {
/** Constant <code>INSTANCE</code> */
public static final DefaultSecurityLogic INSTANCE = new DefaultSecurityLogic();
private ClientFinder clientFinder = new DefaultSecurityClientFinder();
private AuthorizationC... |
LOGGER.debug("=== SECURITY ===");
// checks
val ctx = buildContext(config, parameters);
val webContext = ctx.webContext();
val sessionStore = ctx.sessionStore();
val httpActionAdapter = config.getHttpActionAdapter();
assertNotNull("httpActionAdapter", httpActio... | 893 | 1,139 | 2,032 | <methods>public non-sealed void <init>() <variables>private java.lang.String errorUrl |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/engine/savedrequest/DefaultSavedRequestHandler.java | DefaultSavedRequestHandler | restore | class DefaultSavedRequestHandler implements SavedRequestHandler {
/** {@inheritDoc} */
@Override
public void save(final CallContext ctx) {
val webContext = ctx.webContext();
val sessionStore = ctx.sessionStore();
val requestedUrl = getRequestedUrl(webContext, sessionStore);
... |
val webContext = ctx.webContext();
val sessionStore = ctx.sessionStore();
val optRequestedUrl = sessionStore.get(webContext, Pac4jConstants.REQUESTED_URL);
HttpAction requestedAction = null;
if (optRequestedUrl.isPresent()) {
sessionStore.set(webContext, Pac4jConsta... | 348 | 285 | 633 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/http/ajax/DefaultAjaxRequestResolver.java | DefaultAjaxRequestResolver | buildAjaxResponse | class DefaultAjaxRequestResolver implements AjaxRequestResolver, HttpConstants, Pac4jConstants {
private boolean addRedirectionUrlAsHeader = false;
/** {@inheritDoc} */
@Override
public boolean isAjax(final CallContext ctx) {
val webContext = ctx.webContext();
val xmlHttpRequest = AJAX... |
String url = null;
if (addRedirectionUrlAsHeader) {
val action = redirectionActionBuilder.getRedirectionAction(ctx).orElse(null);
if (action instanceof WithLocationAction) {
url = ((WithLocationAction) action).getLocation();
}
}
val w... | 278 | 359 | 637 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/http/callback/PathParameterCallbackUrlResolver.java | PathParameterCallbackUrlResolver | matches | class PathParameterCallbackUrlResolver implements CallbackUrlResolver {
/** {@inheritDoc} */
@Override
public String compute(final UrlResolver urlResolver, final String url, final String clientName, final WebContext context) {
var newUrl = urlResolver.compute(url, context);
if (newUrl != nu... |
val path = context.getPath();
if (path != null) {
val pos = path.lastIndexOf("/");
final String name;
if (pos >= 0) {
name = path.substring(pos + 1);
} else {
name = path;
}
return CommonHelper.areEq... | 166 | 104 | 270 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/http/callback/QueryParameterCallbackUrlResolver.java | QueryParameterCallbackUrlResolver | compute | class QueryParameterCallbackUrlResolver implements CallbackUrlResolver {
@Getter
@Setter
private String clientNameParameter = Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER;
private Map<String, String> customParams = new HashMap<>();
/**
* <p>Constructor for QueryParameterCallbackUrlResolver.</... |
var newUrl = urlResolver.compute(url, context);
if (newUrl != null && !newUrl.contains(this.clientNameParameter + '=')) {
newUrl = CommonHelper.addParameter(newUrl, this.clientNameParameter, clientName);
}
for (val entry : this.customParams.entrySet()) {
newUrl =... | 307 | 118 | 425 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/http/url/DefaultUrlResolver.java | DefaultUrlResolver | compute | class DefaultUrlResolver implements UrlResolver {
private boolean completeRelativeUrl;
/**
* <p>Constructor for DefaultUrlResolver.</p>
*/
public DefaultUrlResolver() {}
/**
* <p>Constructor for DefaultUrlResolver.</p>
*
* @param completeRelativeUrl a boolean
*/
publ... |
if (this.completeRelativeUrl) {
val relativeUrl = url != null
&& !url.startsWith(HttpConstants.SCHEME_HTTP) && !url.startsWith(HttpConstants.SCHEME_HTTPS);
if (context != null && relativeUrl) {
val sb = new StringBuilder();
sb.append(co... | 162 | 271 | 433 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/logout/CasLogoutActionBuilder.java | CasLogoutActionBuilder | getLogoutAction | class CasLogoutActionBuilder implements LogoutActionBuilder {
private final String serverLogoutUrl;
private final String postLogoutUrlParameter;
/**
* <p>Constructor for CasLogoutActionBuilder.</p>
*
* @param serverLogoutUrl a {@link String} object
* @param postLogoutUrlParameter a {@... |
if (isBlank(serverLogoutUrl)) {
return Optional.empty();
}
var redirectUrl = serverLogoutUrl;
if (isNotBlank(targetUrl)) {
redirectUrl = addParameter(redirectUrl, postLogoutUrlParameter, targetUrl);
}
LOGGER.debug("redirectUrl: {}", redirectUrl);... | 248 | 117 | 365 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/logout/GoogleLogoutActionBuilder.java | GoogleLogoutActionBuilder | getLogoutAction | class GoogleLogoutActionBuilder implements LogoutActionBuilder {
/** {@inheritDoc} */
@Override
public Optional<RedirectionAction> getLogoutAction(final CallContext ctx, final UserProfile currentProfile, final String targetUrl) {<FILL_FUNCTION_BODY>}
} |
val redirectUrl = "https://accounts.google.com/Logout";
LOGGER.debug("redirectUrl: {}", redirectUrl);
return Optional.of(HttpActionHelper.buildRedirectUrlAction(ctx.webContext(), redirectUrl));
| 71 | 64 | 135 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/logout/handler/DefaultSessionLogoutHandler.java | DefaultSessionLogoutHandler | destroySession | class DefaultSessionLogoutHandler implements SessionLogoutHandler {
private Store<String, Object> store = new GuavaStore<>(10000, 30, TimeUnit.MINUTES);
private boolean destroySession;
/**
* <p>Constructor for DefaultSessionLogoutHandler.</p>
*/
public DefaultSessionLogoutHandler() {}
... |
val webContext = ctx.webContext();
val sessionStore = ctx.sessionStore();
val optTrackableSession = store.get(key);
if (optTrackableSession.isPresent()) {
store.remove(key);
}
if (sessionStore == null) {
LOGGER.warn("No session store. Cannot des... | 932 | 557 | 1,489 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/matching/matcher/CacheControlMatcher.java | CacheControlMatcher | matches | class CacheControlMatcher implements Matcher {
/** {@inheritDoc} */
@Override
public boolean matches(final CallContext ctx) {<FILL_FUNCTION_BODY>}
} |
val webContext = ctx.webContext();
val url = webContext.getFullRequestURL().toLowerCase();
if (!url.endsWith(".css")
&& !url.endsWith(".js")
&& !url.endsWith(".png")
&& !url.endsWith(".jpg")
&& !url.endsWith(".ico")
... | 49 | 195 | 244 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/matching/matcher/CorsMatcher.java | CorsMatcher | matches | class CorsMatcher implements Matcher {
private String allowOrigin;
private String exposeHeaders;
private int maxAge = -1;
private Boolean allowCredentials;
private Set<HttpConstants.HTTP_METHOD> allowMethods;
private String allowHeaders;
/** {@inheritDoc} */
@Override
public b... |
val webContext = ctx.webContext();
CommonHelper.assertNotBlank("allowOrigin", allowOrigin);
webContext.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, allowOrigin);
if (CommonHelper.isNotBlank(exposeHeaders)) {
webContext.setResponseHeader(HttpConstant... | 110 | 361 | 471 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/matching/matcher/HeaderMatcher.java | HeaderMatcher | matches | class HeaderMatcher implements Matcher {
private String headerName;
private String expectedValue;
protected Pattern pattern;
/**
* <p>Constructor for HeaderMatcher.</p>
*/
public HeaderMatcher() {}
/**
* <p>Constructor for HeaderMatcher.</p>
*
* @param headerName a ... |
CommonHelper.assertNotBlank("headerName", headerName);
val headerValue = ctx.webContext().getRequestHeader(this.headerName);
val headerNull = expectedValue == null && headerValue.isEmpty();
val headerMatches = headerValue.isPresent() && pattern != null && pattern.matcher(headerValue.ge... | 300 | 98 | 398 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/matching/matcher/HttpMethodMatcher.java | HttpMethodMatcher | matches | class HttpMethodMatcher implements Matcher {
private Set<HttpConstants.HTTP_METHOD> methods;
/**
* <p>Constructor for HttpMethodMatcher.</p>
*/
public HttpMethodMatcher() {}
/**
* <p>Constructor for HttpMethodMatcher.</p>
*
* @param methods a {@link HttpConstants.HTTP_METHOD}... |
CommonHelper.assertNotNull("methods", methods);
val requestMethod = ctx.webContext().getRequestMethod();
for (val method : methods) {
if (method.name().equalsIgnoreCase(requestMethod)) {
return true;
}
}
return false;
| 195 | 73 | 268 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/matching/matcher/PathMatcher.java | PathMatcher | warnRegexp | class PathMatcher implements Matcher {
private final Set<String> includedPaths = new HashSet<>();
@Getter
private final Set<String> excludedPaths = new HashSet<>();
@Getter
private final Set<Pattern> excludedPatterns = new HashSet<>();
private static boolean warnedRegexp;
private static boo... |
if (!warnedRegexp) {
LOGGER.warn("Be careful when using the 'excludeBranch' or 'excludeRegex' methods. "
+ "They use regular expressions and their definitions may be error prone. You could exclude more URLs than expected.");
warnedRegexp = true;
}
| 1,626 | 80 | 1,706 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/matching/matcher/StrictTransportSecurityMatcher.java | StrictTransportSecurityMatcher | matches | class StrictTransportSecurityMatcher implements Matcher {
/**
* 6 months in seconds.
*/
private final static int DEFAULT_MAX_AGE = 15768000;
private int maxAge = DEFAULT_MAX_AGE;
/**
* <p>Constructor for StrictTransportSecurityMatcher.</p>
*/
public StrictTransportSecurityMatc... |
val webContext = ctx.webContext();
if (WebContextHelper.isHttpsOrSecure(webContext)) {
webContext.setResponseHeader("Strict-Transport-Security", "max-age=" + maxAge + " ; includeSubDomains");
}
return true;
| 211 | 76 | 287 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/matching/matcher/csrf/CsrfTokenGeneratorMatcher.java | CsrfTokenGeneratorMatcher | matches | class CsrfTokenGeneratorMatcher implements Matcher {
private CsrfTokenGenerator csrfTokenGenerator;
private String domain;
private String path = "/";
private Boolean httpOnly = true;
private Boolean secure = true;
private Integer maxAge;
private String sameSitePolicy;
private boo... |
val webContext = ctx.webContext();
CommonHelper.assertNotNull("csrfTokenGenerator", csrfTokenGenerator);
if (addTokenAsAttribute || addTokenAsHeader || addTokenAsCookie) {
val token = csrfTokenGenerator.get(webContext, ctx.sessionStore());
if (addTokenAsAttribute) {
... | 247 | 403 | 650 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/matching/matcher/csrf/DefaultCsrfTokenGenerator.java | DefaultCsrfTokenGenerator | get | class DefaultCsrfTokenGenerator implements CsrfTokenGenerator {
// 4 hours
private int ttlInSeconds = 4*60*60;
private boolean rotateTokens = true;
/** {@inheritDoc} */
@Override
public String get(final WebContext context, final SessionStore sessionStore) {<FILL_FUNCTION_BODY>}
} |
String token = null;
val optCurrentToken = sessionStore.get(context, Pac4jConstants.CSRF_TOKEN);
if (optCurrentToken.isPresent()) {
token = (String) optCurrentToken.get();
LOGGER.debug("previous CSRF token: {}", token);
sessionStore.set(context, Pac4jConstan... | 96 | 292 | 388 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/profile/Color.java | Color | toPaddedHexString | class Color implements Serializable {
@Serial
private static final long serialVersionUID = -28080878626869621L;
private int red;
private int green;
private int blue;
/**
* <p>Constructor for Color.</p>
*
* @param red a int
* @param green a int
* @param blue a int
... |
// add "0" padding to single-digit hex values
return i < 16 ? "0" + Integer.toHexString(i).toUpperCase() : Integer.toHexString(i).toUpperCase();
| 680 | 59 | 739 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/profile/CommonProfile.java | CommonProfile | getAttributeAsDate | class CommonProfile extends BasicUserProfile {
@Serial
private static final long serialVersionUID = -1856159870249261877L;
/**
* <p>Constructor for CommonProfile.</p>
*/
public CommonProfile() {
this(true);
}
/**
* Create a profile with possibility to merge attributes w... |
val value = getAttribute(name);
// it should be a Date, but in case it's a Long (Vertx issue with profiles serialized to JSON and restored)
if (value instanceof Long l) {
return new Date(l);
}
else if (value instanceof Double d) {
return new Date(d.longVa... | 1,287 | 107 | 1,394 | <methods>public void <init>() ,public void <init>(boolean) ,public void addAttribute(java.lang.String, java.lang.Object) ,public void addAttributes(Map<java.lang.String,java.lang.Object>) ,public void addAuthenticationAttribute(java.lang.String, java.lang.Object) ,public void addAuthenticationAttributes(Map<java.lang.S... |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/profile/ProfileHelper.java | ProfileHelper | buildUserProfileByClassCompleteName | class ProfileHelper {
private static List<String> profileClassPrefixes = List.of("org.pac4j.");
private ProfileHelper() {}
/**
* Indicate if the user identifier matches this kind of profile.
*
* @param id user identifier
* @param clazz profile class
* @return if the user identifi... |
try {
val constructor = CommonHelper.getConstructor(completeName);
return (UserProfile) constructor.newInstance();
} catch (final ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException
| InstantiationException e) {
... | 897 | 78 | 975 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/profile/ProfileManager.java | ProfileManager | saveAll | class ProfileManager {
private final Authorizer IS_AUTHENTICATED_AUTHORIZER = new IsAuthenticatedAuthorizer();
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final WebContext context;
protected SessionStore sessionStore;
@Getter
@Setter
protected Config c... |
if (saveInSession) {
LOGGER.debug("Saving profiles (session): {}", profiles);
this.sessionStore.set(this.context, Pac4jConstants.USER_PROFILES, profiles);
}
LOGGER.debug("Saving profiles (request): {}", profiles);
this.context.setRequestAttribute(Pac4jConstants.U... | 1,773 | 99 | 1,872 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/profile/converter/AbstractAttributeConverter.java | AbstractAttributeConverter | convert | class AbstractAttributeConverter implements AttributeConverter {
private final Class<? extends Object> clazz;
/**
* <p>Constructor for AbstractAttributeConverter.</p>
*
* @param clazz a {@link Class} object
*/
protected AbstractAttributeConverter(final Class<? extends Object> clazz) {
... |
Object t = null;
if (attribute != null) {
if (clazz.isAssignableFrom(attribute.getClass())) {
t = attribute;
} else if (attribute instanceof List l) {
if (l.size() > 0) {
val element = l.get(0);
if (clazz.is... | 323 | 174 | 497 | <no_super_class> |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/profile/converter/BooleanConverter.java | BooleanConverter | internalConvert | class BooleanConverter extends AbstractAttributeConverter {
/**
* <p>Constructor for BooleanConverter.</p>
*/
public BooleanConverter() {
super(Boolean.class);
}
/** {@inheritDoc} */
@Override
protected Boolean internalConvert(final Object attribute) {<FILL_FUNCTION_BODY>}
... |
if (attribute instanceof String) {
return "1".equals(attribute) || "true".equals(attribute);
} else if (attribute instanceof Number) {
return Integer.valueOf(1).equals(attribute);
}
return null;
| 119 | 63 | 182 | <methods>public java.lang.Boolean accept(java.lang.String) ,public java.lang.Object convert(java.lang.Object) <variables>private final non-sealed Class<? extends java.lang.Object> clazz |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/profile/converter/ColorConverter.java | ColorConverter | internalConvert | class ColorConverter extends AbstractAttributeConverter {
/**
* <p>Constructor for ColorConverter.</p>
*/
public ColorConverter() {
super(Color.class);
}
/** {@inheritDoc} */
@Override
protected Color internalConvert(final Object attribute) {<FILL_FUNCTION_BODY>}
} |
if (attribute instanceof String s && s.length() == 6) {
try {
var hex = s.substring(0, 2);
val r = Integer.parseInt(hex, 16);
hex = s.substring(2, 4);
val g = Integer.parseInt(hex, 16);
hex = s.substring(4, 6);
... | 88 | 169 | 257 | <methods>public java.lang.Boolean accept(java.lang.String) ,public java.lang.Object convert(java.lang.Object) <variables>private final non-sealed Class<? extends java.lang.Object> clazz |
pac4j_pac4j | pac4j/pac4j-core/src/main/java/org/pac4j/core/profile/converter/DateConverter.java | DateConverter | internalConvert | class DateConverter extends AbstractAttributeConverter {
protected String format;
protected Locale locale;
/**
* <p>Constructor for DateConverter.</p>
*/
public DateConverter() {
this(DateTimeFormatter.ISO_LOCAL_DATE_TIME.toString());
}
/**
* <p>Constructor for DateCon... |
if (attribute instanceof String s) {
SimpleDateFormat simpleDateFormat;
if (this.locale == null) {
simpleDateFormat = new SimpleDateFormat(this.format);
} else {
simpleDateFormat = new SimpleDateFormat(this.format, this.locale);
}
... | 264 | 145 | 409 | <methods>public java.lang.Boolean accept(java.lang.String) ,public java.lang.Object convert(java.lang.Object) <variables>private final non-sealed Class<? extends java.lang.Object> clazz |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.