id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
32,600
grails/grails-core
grails-core/src/main/groovy/org/grails/spring/context/support/ReloadableResourceBundleMessageSource.java
ReloadableResourceBundleMessageSource.getProperties
@SuppressWarnings("rawtypes") protected PropertiesHolder getProperties(final String filename, final Resource resource) { return CacheEntry.getValue(cachedProperties, filename, fileCacheMillis, new Callable<PropertiesHolder>() { @Override public PropertiesHolder call() throws Exception { return new PropertiesHolder(filename, resource); } }, new Callable<CacheEntry>() { @Override public CacheEntry call() throws Exception { return new PropertiesHolderCacheEntry(); } }, true, null); }
java
@SuppressWarnings("rawtypes") protected PropertiesHolder getProperties(final String filename, final Resource resource) { return CacheEntry.getValue(cachedProperties, filename, fileCacheMillis, new Callable<PropertiesHolder>() { @Override public PropertiesHolder call() throws Exception { return new PropertiesHolder(filename, resource); } }, new Callable<CacheEntry>() { @Override public CacheEntry call() throws Exception { return new PropertiesHolderCacheEntry(); } }, true, null); }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "protected", "PropertiesHolder", "getProperties", "(", "final", "String", "filename", ",", "final", "Resource", "resource", ")", "{", "return", "CacheEntry", ".", "getValue", "(", "cachedProperties", ",", "filename"...
Get a PropertiesHolder for the given filename, either from the cache or freshly loaded. @param filename the bundle filename (basename + Locale) @return the current PropertiesHolder for the bundle
[ "Get", "a", "PropertiesHolder", "for", "the", "given", "filename", "either", "from", "the", "cache", "or", "freshly", "loaded", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/spring/context/support/ReloadableResourceBundleMessageSource.java#L488-L501
32,601
grails/grails-core
grails-core/src/main/groovy/org/grails/spring/context/support/ReloadableResourceBundleMessageSource.java
ReloadableResourceBundleMessageSource.loadProperties
protected Properties loadProperties(Resource resource, String filename) throws IOException { InputStream is = resource.getInputStream(); Properties props = new Properties(); try { if (resource.getFilename().endsWith(XML_SUFFIX)) { if (logger.isDebugEnabled()) { logger.debug("Loading properties [" + resource.getFilename() + "]"); } this.propertiesPersister.loadFromXml(props, is); } else { String encoding = null; if (this.fileEncodings != null) { encoding = this.fileEncodings.getProperty(filename); } if (encoding == null) { encoding = this.defaultEncoding; } if (encoding != null) { if (logger.isDebugEnabled()) { logger.debug("Loading properties [" + resource.getFilename() + "] with encoding '" + encoding + "'"); } this.propertiesPersister.load(props, new InputStreamReader(is, encoding)); } else { if (logger.isDebugEnabled()) { logger.debug("Loading properties [" + resource.getFilename() + "]"); } this.propertiesPersister.load(props, is); } } return props; } finally { is.close(); } }
java
protected Properties loadProperties(Resource resource, String filename) throws IOException { InputStream is = resource.getInputStream(); Properties props = new Properties(); try { if (resource.getFilename().endsWith(XML_SUFFIX)) { if (logger.isDebugEnabled()) { logger.debug("Loading properties [" + resource.getFilename() + "]"); } this.propertiesPersister.loadFromXml(props, is); } else { String encoding = null; if (this.fileEncodings != null) { encoding = this.fileEncodings.getProperty(filename); } if (encoding == null) { encoding = this.defaultEncoding; } if (encoding != null) { if (logger.isDebugEnabled()) { logger.debug("Loading properties [" + resource.getFilename() + "] with encoding '" + encoding + "'"); } this.propertiesPersister.load(props, new InputStreamReader(is, encoding)); } else { if (logger.isDebugEnabled()) { logger.debug("Loading properties [" + resource.getFilename() + "]"); } this.propertiesPersister.load(props, is); } } return props; } finally { is.close(); } }
[ "protected", "Properties", "loadProperties", "(", "Resource", "resource", ",", "String", "filename", ")", "throws", "IOException", "{", "InputStream", "is", "=", "resource", ".", "getInputStream", "(", ")", ";", "Properties", "props", "=", "new", "Properties", "...
Load the properties from the given resource. @param resource the resource to load from @param filename the original bundle filename (basename + Locale) @return the populated Properties instance @throws IOException if properties loading failed
[ "Load", "the", "properties", "from", "the", "given", "resource", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/spring/context/support/ReloadableResourceBundleMessageSource.java#L527-L563
32,602
grails/grails-core
grails-core/src/main/groovy/org/grails/spring/context/support/ReloadableResourceBundleMessageSource.java
ReloadableResourceBundleMessageSource.clearCache
public void clearCache() { logger.debug("Clearing entire resource bundle cache"); this.cachedProperties.clear(); this.cachedMergedProperties.clear(); this.cachedFilenames.clear(); this.cachedResources.clear(); }
java
public void clearCache() { logger.debug("Clearing entire resource bundle cache"); this.cachedProperties.clear(); this.cachedMergedProperties.clear(); this.cachedFilenames.clear(); this.cachedResources.clear(); }
[ "public", "void", "clearCache", "(", ")", "{", "logger", ".", "debug", "(", "\"Clearing entire resource bundle cache\"", ")", ";", "this", ".", "cachedProperties", ".", "clear", "(", ")", ";", "this", ".", "cachedMergedProperties", ".", "clear", "(", ")", ";",...
Clear the resource bundle cache. Subsequent resolve calls will lead to reloading of the properties files.
[ "Clear", "the", "resource", "bundle", "cache", ".", "Subsequent", "resolve", "calls", "will", "lead", "to", "reloading", "of", "the", "properties", "files", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/spring/context/support/ReloadableResourceBundleMessageSource.java#L570-L576
32,603
grails/grails-core
grails-core/src/main/groovy/org/grails/spring/context/support/ReloadableResourceBundleMessageSource.java
ReloadableResourceBundleMessageSource.clearCacheIncludingAncestors
public void clearCacheIncludingAncestors() { clearCache(); if (getParentMessageSource() instanceof ReloadableResourceBundleMessageSource) { ((ReloadableResourceBundleMessageSource) getParentMessageSource()).clearCacheIncludingAncestors(); } else if (getParentMessageSource() instanceof org.springframework.context.support.ReloadableResourceBundleMessageSource) { ((org.springframework.context.support.ReloadableResourceBundleMessageSource) getParentMessageSource()).clearCacheIncludingAncestors(); } }
java
public void clearCacheIncludingAncestors() { clearCache(); if (getParentMessageSource() instanceof ReloadableResourceBundleMessageSource) { ((ReloadableResourceBundleMessageSource) getParentMessageSource()).clearCacheIncludingAncestors(); } else if (getParentMessageSource() instanceof org.springframework.context.support.ReloadableResourceBundleMessageSource) { ((org.springframework.context.support.ReloadableResourceBundleMessageSource) getParentMessageSource()).clearCacheIncludingAncestors(); } }
[ "public", "void", "clearCacheIncludingAncestors", "(", ")", "{", "clearCache", "(", ")", ";", "if", "(", "getParentMessageSource", "(", ")", "instanceof", "ReloadableResourceBundleMessageSource", ")", "{", "(", "(", "ReloadableResourceBundleMessageSource", ")", "getPare...
Clear the resource bundle caches of this MessageSource and all its ancestors. @see #clearCache
[ "Clear", "the", "resource", "bundle", "caches", "of", "this", "MessageSource", "and", "all", "its", "ancestors", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/org/grails/spring/context/support/ReloadableResourceBundleMessageSource.java#L582-L589
32,604
grails/grails-core
grails-spring/src/main/groovy/grails/spring/BeanBuilder.java
BeanBuilder.importBeans
public void importBeans(String resourcePattern) { try { Resource[] resources = resourcePatternResolver.getResources(resourcePattern); for (Resource resource : resources) { importBeans(resource); } } catch (IOException e) { LOG.error("Error loading beans for resource pattern: " + resourcePattern, e); } }
java
public void importBeans(String resourcePattern) { try { Resource[] resources = resourcePatternResolver.getResources(resourcePattern); for (Resource resource : resources) { importBeans(resource); } } catch (IOException e) { LOG.error("Error loading beans for resource pattern: " + resourcePattern, e); } }
[ "public", "void", "importBeans", "(", "String", "resourcePattern", ")", "{", "try", "{", "Resource", "[", "]", "resources", "=", "resourcePatternResolver", ".", "getResources", "(", "resourcePattern", ")", ";", "for", "(", "Resource", "resource", ":", "resources...
Imports Spring bean definitions from either XML or Groovy sources into the current bean builder instance @param resourcePattern The resource pattern
[ "Imports", "Spring", "bean", "definitions", "from", "either", "XML", "or", "Groovy", "sources", "into", "the", "current", "bean", "builder", "instance" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/grails/spring/BeanBuilder.java#L189-L198
32,605
grails/grails-core
grails-spring/src/main/groovy/grails/spring/BeanBuilder.java
BeanBuilder.xmlns
public void xmlns(Map<String, String> definition) { Assert.notNull(namespaceHandlerResolver, "You cannot define a Spring namespace without a [namespaceHandlerResolver] set"); if (definition.isEmpty()) { return; } for (Map.Entry<String, String> entry : definition.entrySet()) { String namespace = entry.getKey(); String uri = entry.getValue() == null ? null : entry.getValue(); Assert.notNull(uri, "Namespace definition cannot supply a null URI"); final NamespaceHandler namespaceHandler = namespaceHandlerResolver.resolve(uri); if (namespaceHandler == null) { throw new BeanDefinitionParsingException( new Problem("No namespace handler found for URI: " + uri, new Location(readerContext.getResource()))); } namespaceHandlers.put(namespace, namespaceHandler); namespaces.put(namespace, uri); } }
java
public void xmlns(Map<String, String> definition) { Assert.notNull(namespaceHandlerResolver, "You cannot define a Spring namespace without a [namespaceHandlerResolver] set"); if (definition.isEmpty()) { return; } for (Map.Entry<String, String> entry : definition.entrySet()) { String namespace = entry.getKey(); String uri = entry.getValue() == null ? null : entry.getValue(); Assert.notNull(uri, "Namespace definition cannot supply a null URI"); final NamespaceHandler namespaceHandler = namespaceHandlerResolver.resolve(uri); if (namespaceHandler == null) { throw new BeanDefinitionParsingException( new Problem("No namespace handler found for URI: " + uri, new Location(readerContext.getResource()))); } namespaceHandlers.put(namespace, namespaceHandler); namespaces.put(namespace, uri); } }
[ "public", "void", "xmlns", "(", "Map", "<", "String", ",", "String", ">", "definition", ")", "{", "Assert", ".", "notNull", "(", "namespaceHandlerResolver", ",", "\"You cannot define a Spring namespace without a [namespaceHandlerResolver] set\"", ")", ";", "if", "(", ...
Defines a Spring namespace definition to use. @param definition The definition
[ "Defines", "a", "Spring", "namespace", "definition", "to", "use", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/grails/spring/BeanBuilder.java#L220-L241
32,606
grails/grails-core
grails-spring/src/main/groovy/grails/spring/BeanBuilder.java
BeanBuilder.registerBeans
public void registerBeans(BeanDefinitionRegistry registry) { finalizeDeferredProperties(); if (registry instanceof GenericApplicationContext) { GenericApplicationContext ctx = (GenericApplicationContext) registry; ctx.setClassLoader(classLoader); ctx.getBeanFactory().setBeanClassLoader(classLoader); } springConfig.registerBeansWithRegistry(registry); }
java
public void registerBeans(BeanDefinitionRegistry registry) { finalizeDeferredProperties(); if (registry instanceof GenericApplicationContext) { GenericApplicationContext ctx = (GenericApplicationContext) registry; ctx.setClassLoader(classLoader); ctx.getBeanFactory().setBeanClassLoader(classLoader); } springConfig.registerBeansWithRegistry(registry); }
[ "public", "void", "registerBeans", "(", "BeanDefinitionRegistry", "registry", ")", "{", "finalizeDeferredProperties", "(", ")", ";", "if", "(", "registry", "instanceof", "GenericApplicationContext", ")", "{", "GenericApplicationContext", "ctx", "=", "(", "GenericApplica...
Register a set of beans with the given bean registry. Most application contexts are bean registries.
[ "Register", "a", "set", "of", "beans", "with", "the", "given", "bean", "registry", ".", "Most", "application", "contexts", "are", "bean", "registries", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/grails/spring/BeanBuilder.java#L493-L503
32,607
grails/grails-core
grails-spring/src/main/groovy/grails/spring/BeanBuilder.java
BeanBuilder.invokeMethod
@Override public Object invokeMethod(String name, Object arg) { Object[] args = (Object[])arg; if (CREATE_APPCTX.equals(name)) { return createApplicationContext(); } if (REGISTER_BEANS.equals(name) && args.length == 1 && args[0] instanceof GenericApplicationContext) { registerBeans((GenericApplicationContext)args[0]); return null; } if (BEANS.equals(name) && args.length == 1 && args[0] instanceof Closure) { return beans((Closure<?>)args[0]); } if (REF.equals(name)) { String refName; Assert.notNull(args[0], "Argument to ref() is not a valid bean or was not found"); if (args[0] instanceof RuntimeBeanReference) { refName = ((RuntimeBeanReference)args[0]).getBeanName(); } else { refName = args[0].toString(); } boolean parentRef = false; if (args.length > 1) { if (args[1] instanceof Boolean) { parentRef = (Boolean) args[1]; } } return new RuntimeBeanReference(refName, parentRef); } if (namespaceHandlers.containsKey(name) && args.length > 0 && (args[0] instanceof Closure)) { createDynamicElementReader(name, true).invokeMethod("doCall", args); return this; } if (args.length > 0 && args[0] instanceof Closure) { // abstract bean definition return invokeBeanDefiningMethod(name, args); } if (args.length > 0 && args[0] instanceof Class || args.length > 0 && args[0] instanceof RuntimeBeanReference || args.length > 0 && args[0] instanceof Map) { return invokeBeanDefiningMethod(name, args); } if (args.length > 1 && args[args.length - 1] instanceof Closure) { return invokeBeanDefiningMethod(name, args); } ApplicationContext ctx = springConfig.getUnrefreshedApplicationContext(); MetaClass mc = DefaultGroovyMethods.getMetaClass(ctx); if (!mc.respondsTo(ctx, name, args).isEmpty()) { return mc.invokeMethod(ctx,name, args); } return this; }
java
@Override public Object invokeMethod(String name, Object arg) { Object[] args = (Object[])arg; if (CREATE_APPCTX.equals(name)) { return createApplicationContext(); } if (REGISTER_BEANS.equals(name) && args.length == 1 && args[0] instanceof GenericApplicationContext) { registerBeans((GenericApplicationContext)args[0]); return null; } if (BEANS.equals(name) && args.length == 1 && args[0] instanceof Closure) { return beans((Closure<?>)args[0]); } if (REF.equals(name)) { String refName; Assert.notNull(args[0], "Argument to ref() is not a valid bean or was not found"); if (args[0] instanceof RuntimeBeanReference) { refName = ((RuntimeBeanReference)args[0]).getBeanName(); } else { refName = args[0].toString(); } boolean parentRef = false; if (args.length > 1) { if (args[1] instanceof Boolean) { parentRef = (Boolean) args[1]; } } return new RuntimeBeanReference(refName, parentRef); } if (namespaceHandlers.containsKey(name) && args.length > 0 && (args[0] instanceof Closure)) { createDynamicElementReader(name, true).invokeMethod("doCall", args); return this; } if (args.length > 0 && args[0] instanceof Closure) { // abstract bean definition return invokeBeanDefiningMethod(name, args); } if (args.length > 0 && args[0] instanceof Class || args.length > 0 && args[0] instanceof RuntimeBeanReference || args.length > 0 && args[0] instanceof Map) { return invokeBeanDefiningMethod(name, args); } if (args.length > 1 && args[args.length - 1] instanceof Closure) { return invokeBeanDefiningMethod(name, args); } ApplicationContext ctx = springConfig.getUnrefreshedApplicationContext(); MetaClass mc = DefaultGroovyMethods.getMetaClass(ctx); if (!mc.respondsTo(ctx, name, args).isEmpty()) { return mc.invokeMethod(ctx,name, args); } return this; }
[ "@", "Override", "public", "Object", "invokeMethod", "(", "String", "name", ",", "Object", "arg", ")", "{", "Object", "[", "]", "args", "=", "(", "Object", "[", "]", ")", "arg", ";", "if", "(", "CREATE_APPCTX", ".", "equals", "(", "name", ")", ")", ...
Overrides method invocation to create beans for each method name that takes a class argument.
[ "Overrides", "method", "invocation", "to", "create", "beans", "for", "each", "method", "name", "that", "takes", "a", "class", "argument", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/grails/spring/BeanBuilder.java#L517-L579
32,608
grails/grails-core
grails-spring/src/main/groovy/grails/spring/BeanBuilder.java
BeanBuilder.setProperty
@Override public void setProperty(String name, Object value) { if (currentBeanConfig != null) { setPropertyOnBeanConfig(name, value); } }
java
@Override public void setProperty(String name, Object value) { if (currentBeanConfig != null) { setPropertyOnBeanConfig(name, value); } }
[ "@", "Override", "public", "void", "setProperty", "(", "String", "name", ",", "Object", "value", ")", "{", "if", "(", "currentBeanConfig", "!=", "null", ")", "{", "setPropertyOnBeanConfig", "(", "name", ",", "value", ")", ";", "}", "}" ]
Overrides property setting in the scope of the BeanBuilder to set properties on the current BeanConfiguration.
[ "Overrides", "property", "setting", "in", "the", "scope", "of", "the", "BeanBuilder", "to", "set", "properties", "on", "the", "current", "BeanConfiguration", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/grails/spring/BeanBuilder.java#L769-L774
32,609
grails/grails-core
grails-spring/src/main/groovy/grails/spring/BeanBuilder.java
BeanBuilder.bean
@SuppressWarnings("rawtypes") public AbstractBeanDefinition bean(Class type, Object...args) { BeanConfiguration current = currentBeanConfig; try { Closure callable = null; Collection constructorArgs = null; if (args != null && args.length > 0) { int index = args.length; Object lastArg = args[index-1]; if (lastArg instanceof Closure) { callable = (Closure) lastArg; index--; } if (index > -1) { constructorArgs = resolveConstructorArguments(args, 0, index); } } currentBeanConfig = constructorArgs == null ? springConfig.createSingletonBean(type) : springConfig.createSingletonBean(type, constructorArgs); if (callable != null) { callable.call(new Object[]{currentBeanConfig}); } return currentBeanConfig.getBeanDefinition(); } finally { currentBeanConfig = current; } }
java
@SuppressWarnings("rawtypes") public AbstractBeanDefinition bean(Class type, Object...args) { BeanConfiguration current = currentBeanConfig; try { Closure callable = null; Collection constructorArgs = null; if (args != null && args.length > 0) { int index = args.length; Object lastArg = args[index-1]; if (lastArg instanceof Closure) { callable = (Closure) lastArg; index--; } if (index > -1) { constructorArgs = resolveConstructorArguments(args, 0, index); } } currentBeanConfig = constructorArgs == null ? springConfig.createSingletonBean(type) : springConfig.createSingletonBean(type, constructorArgs); if (callable != null) { callable.call(new Object[]{currentBeanConfig}); } return currentBeanConfig.getBeanDefinition(); } finally { currentBeanConfig = current; } }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "AbstractBeanDefinition", "bean", "(", "Class", "type", ",", "Object", "...", "args", ")", "{", "BeanConfiguration", "current", "=", "currentBeanConfig", ";", "try", "{", "Closure", "callable", "=", "n...
Defines an inner bean definition. @param type The bean type @param args The constructors arguments and closure configurer @return The bean definition
[ "Defines", "an", "inner", "bean", "definition", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/grails/spring/BeanBuilder.java#L793-L821
32,610
grails/grails-core
grails-spring/src/main/groovy/grails/spring/BeanBuilder.java
BeanBuilder.manageMapIfNecessary
@SuppressWarnings({ "rawtypes", "unchecked" }) protected Object manageMapIfNecessary(Object value) { Map map = (Map)value; boolean containsRuntimeRefs = false; for (Object e : map.values()) { if (e instanceof RuntimeBeanReference) { containsRuntimeRefs = true; break; } } if (containsRuntimeRefs) { Map managedMap = new ManagedMap(); managedMap.putAll(map); return managedMap; } return value; }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) protected Object manageMapIfNecessary(Object value) { Map map = (Map)value; boolean containsRuntimeRefs = false; for (Object e : map.values()) { if (e instanceof RuntimeBeanReference) { containsRuntimeRefs = true; break; } } if (containsRuntimeRefs) { Map managedMap = new ManagedMap(); managedMap.putAll(map); return managedMap; } return value; }
[ "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "protected", "Object", "manageMapIfNecessary", "(", "Object", "value", ")", "{", "Map", "map", "=", "(", "Map", ")", "value", ";", "boolean", "containsRuntimeRefs", "=", "false"...
Checks whether there are any runtime refs inside a Map and converts it to a ManagedMap if necessary. @param value The current map @return A ManagedMap or a normal map
[ "Checks", "whether", "there", "are", "any", "runtime", "refs", "inside", "a", "Map", "and", "converts", "it", "to", "a", "ManagedMap", "if", "necessary", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/grails/spring/BeanBuilder.java#L862-L878
32,611
grails/grails-core
grails-spring/src/main/groovy/grails/spring/BeanBuilder.java
BeanBuilder.manageListIfNecessary
@SuppressWarnings({ "rawtypes", "unchecked" }) protected Object manageListIfNecessary(Object value) { List list = (List)value; boolean containsRuntimeRefs = false; for (Object e : list) { if (e instanceof RuntimeBeanReference) { containsRuntimeRefs = true; break; } } if (containsRuntimeRefs) { List tmp = new ManagedList(); tmp.addAll((List)value); value = tmp; } return value; }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) protected Object manageListIfNecessary(Object value) { List list = (List)value; boolean containsRuntimeRefs = false; for (Object e : list) { if (e instanceof RuntimeBeanReference) { containsRuntimeRefs = true; break; } } if (containsRuntimeRefs) { List tmp = new ManagedList(); tmp.addAll((List)value); value = tmp; } return value; }
[ "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "protected", "Object", "manageListIfNecessary", "(", "Object", "value", ")", "{", "List", "list", "=", "(", "List", ")", "value", ";", "boolean", "containsRuntimeRefs", "=", "fa...
Checks whether there are any runtime refs inside the list and converts it to a ManagedList if necessary. @param value The object that represents the list @return Either a new list or a managed one
[ "Checks", "whether", "there", "are", "any", "runtime", "refs", "inside", "the", "list", "and", "converts", "it", "to", "a", "ManagedList", "if", "necessary", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-spring/src/main/groovy/grails/spring/BeanBuilder.java#L887-L903
32,612
grails/grails-core
grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java
DefaultGrailsPluginManager.loadDelayedPlugins
private void loadDelayedPlugins() { while (!delayedLoadPlugins.isEmpty()) { GrailsPlugin plugin = delayedLoadPlugins.remove(0); if (areDependenciesResolved(plugin)) { if (!hasValidPluginsToLoadBefore(plugin)) { registerPlugin(plugin); } else { delayedLoadPlugins.add(plugin); } } else { // ok, it still hasn't resolved the dependency after the initial // load of all plugins. All hope is not lost, however, so lets first // look inside the remaining delayed loads before giving up boolean foundInDelayed = false; for (GrailsPlugin remainingPlugin : delayedLoadPlugins) { if (isDependentOn(plugin, remainingPlugin)) { foundInDelayed = true; break; } } if (foundInDelayed) { delayedLoadPlugins.add(plugin); } else { failedPlugins.put(plugin.getName(), plugin); LOG.error("ERROR: Plugin [" + plugin.getName() + "] cannot be loaded because its dependencies [" + DefaultGroovyMethods.inspect(plugin.getDependencyNames()) + "] cannot be resolved"); } } } }
java
private void loadDelayedPlugins() { while (!delayedLoadPlugins.isEmpty()) { GrailsPlugin plugin = delayedLoadPlugins.remove(0); if (areDependenciesResolved(plugin)) { if (!hasValidPluginsToLoadBefore(plugin)) { registerPlugin(plugin); } else { delayedLoadPlugins.add(plugin); } } else { // ok, it still hasn't resolved the dependency after the initial // load of all plugins. All hope is not lost, however, so lets first // look inside the remaining delayed loads before giving up boolean foundInDelayed = false; for (GrailsPlugin remainingPlugin : delayedLoadPlugins) { if (isDependentOn(plugin, remainingPlugin)) { foundInDelayed = true; break; } } if (foundInDelayed) { delayedLoadPlugins.add(plugin); } else { failedPlugins.put(plugin.getName(), plugin); LOG.error("ERROR: Plugin [" + plugin.getName() + "] cannot be loaded because its dependencies [" + DefaultGroovyMethods.inspect(plugin.getDependencyNames()) + "] cannot be resolved"); } } } }
[ "private", "void", "loadDelayedPlugins", "(", ")", "{", "while", "(", "!", "delayedLoadPlugins", ".", "isEmpty", "(", ")", ")", "{", "GrailsPlugin", "plugin", "=", "delayedLoadPlugins", ".", "remove", "(", "0", ")", ";", "if", "(", "areDependenciesResolved", ...
This method will attempt to load that plug-ins not loaded in the first pass
[ "This", "method", "will", "attempt", "to", "load", "that", "plug", "-", "ins", "not", "loaded", "in", "the", "first", "pass" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java#L497-L529
32,613
grails/grails-core
grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java
DefaultGrailsPluginManager.isDependentOn
private boolean isDependentOn(GrailsPlugin plugin, GrailsPlugin dependency) { for (String name : plugin.getDependencyNames()) { String requiredVersion = plugin.getDependentVersion(name); if (name.equals(dependency.getName()) && GrailsVersionUtils.isValidVersion(dependency.getVersion(), requiredVersion)) return true; } return false; }
java
private boolean isDependentOn(GrailsPlugin plugin, GrailsPlugin dependency) { for (String name : plugin.getDependencyNames()) { String requiredVersion = plugin.getDependentVersion(name); if (name.equals(dependency.getName()) && GrailsVersionUtils.isValidVersion(dependency.getVersion(), requiredVersion)) return true; } return false; }
[ "private", "boolean", "isDependentOn", "(", "GrailsPlugin", "plugin", ",", "GrailsPlugin", "dependency", ")", "{", "for", "(", "String", "name", ":", "plugin", ".", "getDependencyNames", "(", ")", ")", "{", "String", "requiredVersion", "=", "plugin", ".", "get...
Checks whether the first plugin is dependant on the second plugin. @param plugin The plugin to check @param dependency The plugin which the first argument may be dependant on @return true if it is
[ "Checks", "whether", "the", "first", "plugin", "is", "dependant", "on", "the", "second", "plugin", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java#L561-L570
32,614
grails/grails-core
grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java
DefaultGrailsPluginManager.areNoneToLoadBefore
private boolean areNoneToLoadBefore(GrailsPlugin plugin) { for (String name : plugin.getLoadAfterNames()) { if (getGrailsPlugin(name) == null) { return false; } } return true; }
java
private boolean areNoneToLoadBefore(GrailsPlugin plugin) { for (String name : plugin.getLoadAfterNames()) { if (getGrailsPlugin(name) == null) { return false; } } return true; }
[ "private", "boolean", "areNoneToLoadBefore", "(", "GrailsPlugin", "plugin", ")", "{", "for", "(", "String", "name", ":", "plugin", ".", "getLoadAfterNames", "(", ")", ")", "{", "if", "(", "getGrailsPlugin", "(", "name", ")", "==", "null", ")", "{", "return...
Returns true if there are no plugins left that should, if possible, be loaded before this plugin. @param plugin The plugin @return true if there are
[ "Returns", "true", "if", "there", "are", "no", "plugins", "left", "that", "should", "if", "possible", "be", "loaded", "before", "this", "plugin", "." ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java#L587-L594
32,615
grails/grails-core
grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java
DefaultGrailsPluginManager.attemptPluginLoad
private void attemptPluginLoad(GrailsPlugin plugin) { if (areDependenciesResolved(plugin) && areNoneToLoadBefore(plugin)) { registerPlugin(plugin); } else { delayedLoadPlugins.add(plugin); } }
java
private void attemptPluginLoad(GrailsPlugin plugin) { if (areDependenciesResolved(plugin) && areNoneToLoadBefore(plugin)) { registerPlugin(plugin); } else { delayedLoadPlugins.add(plugin); } }
[ "private", "void", "attemptPluginLoad", "(", "GrailsPlugin", "plugin", ")", "{", "if", "(", "areDependenciesResolved", "(", "plugin", ")", "&&", "areNoneToLoadBefore", "(", "plugin", ")", ")", "{", "registerPlugin", "(", "plugin", ")", ";", "}", "else", "{", ...
Attempts to load a plugin based on its dependencies. If a plugin's dependencies cannot be resolved it will add it to the list of dependencies to be resolved later. @param plugin The plugin
[ "Attempts", "to", "load", "a", "plugin", "based", "on", "its", "dependencies", ".", "If", "a", "plugin", "s", "dependencies", "cannot", "be", "resolved", "it", "will", "add", "it", "to", "the", "list", "of", "dependencies", "to", "be", "resolved", "later",...
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java#L635-L642
32,616
grails/grails-core
grails-web-common/src/main/groovy/grails/web/servlet/mvc/GrailsParameterMap.java
GrailsParameterMap.getDate
@Override public Date getDate(String name) { Object returnValue = wrappedMap.get(name); if ("date.struct".equals(returnValue)) { returnValue = lazyEvaluateDateParam(name); nestedDateMap.put(name, returnValue); return (Date)returnValue; } Date date = super.getDate(name); if (date == null) { // try lookup format from messages.properties String format = lookupFormat(name); if (format != null) { return getDate(name, format); } } return date; }
java
@Override public Date getDate(String name) { Object returnValue = wrappedMap.get(name); if ("date.struct".equals(returnValue)) { returnValue = lazyEvaluateDateParam(name); nestedDateMap.put(name, returnValue); return (Date)returnValue; } Date date = super.getDate(name); if (date == null) { // try lookup format from messages.properties String format = lookupFormat(name); if (format != null) { return getDate(name, format); } } return date; }
[ "@", "Override", "public", "Date", "getDate", "(", "String", "name", ")", "{", "Object", "returnValue", "=", "wrappedMap", ".", "get", "(", "name", ")", ";", "if", "(", "\"date.struct\"", ".", "equals", "(", "returnValue", ")", ")", "{", "returnValue", "...
Obtains a date for the parameter name using the default format @param name The name of the parameter @return A date or null
[ "Obtains", "a", "date", "for", "the", "parameter", "name", "using", "the", "default", "format" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/grails/web/servlet/mvc/GrailsParameterMap.java#L206-L223
32,617
grails/grails-core
grails-web-common/src/main/groovy/grails/web/servlet/mvc/GrailsParameterMap.java
GrailsParameterMap.toQueryString
public String toQueryString() { String encoding = request.getCharacterEncoding(); try { return WebUtils.toQueryString(this, encoding); } catch (UnsupportedEncodingException e) { throw new ControllerExecutionException("Unable to convert parameter map [" + this + "] to a query string: " + e.getMessage(), e); } }
java
public String toQueryString() { String encoding = request.getCharacterEncoding(); try { return WebUtils.toQueryString(this, encoding); } catch (UnsupportedEncodingException e) { throw new ControllerExecutionException("Unable to convert parameter map [" + this + "] to a query string: " + e.getMessage(), e); } }
[ "public", "String", "toQueryString", "(", ")", "{", "String", "encoding", "=", "request", ".", "getCharacterEncoding", "(", ")", ";", "try", "{", "return", "WebUtils", ".", "toQueryString", "(", "this", ",", "encoding", ")", ";", "}", "catch", "(", "Unsupp...
Converts this parameter map into a query String. Note that this will flatten nested keys separating them with the . character and URL encode the result @return A query String starting with the ? character
[ "Converts", "this", "parameter", "map", "into", "a", "query", "String", ".", "Note", "that", "this", "will", "flatten", "nested", "keys", "separating", "them", "with", "the", ".", "character", "and", "URL", "encode", "the", "result" ]
c0b08aa995b0297143b75d05642abba8cb7b4122
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/grails/web/servlet/mvc/GrailsParameterMap.java#L231-L240
32,618
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/logout/impl/SAML2LogoutValidator.java
SAML2LogoutValidator.validateLogoutRequest
protected void validateLogoutRequest(final LogoutRequest logoutRequest, final SAML2MessageContext context, final SignatureTrustEngine engine) { validateSignatureIfItExists(logoutRequest.getSignature(), context, engine); // don't check because of CAS v5 //validateIssueInstant(logoutRequest.getIssueInstant()); validateIssuerIfItExists(logoutRequest.getIssuer(), context); NameID nameId = logoutRequest.getNameID(); final EncryptedID encryptedID = logoutRequest.getEncryptedID(); if (encryptedID != null) { nameId = decryptEncryptedId(encryptedID, decrypter); } String sessionIndex = null; final List<SessionIndex> sessionIndexes = logoutRequest.getSessionIndexes(); if (sessionIndexes != null && !sessionIndexes.isEmpty()) { final SessionIndex sessionIndexObject = sessionIndexes.get(0); if (sessionIndexObject != null) { sessionIndex = sessionIndexObject.getSessionIndex(); } } final String sloKey = computeSloKey(sessionIndex, nameId); if (sloKey != null) { final String bindingUri = context.getSAMLBindingContext().getBindingUri(); if (SAMLConstants.SAML2_SOAP11_BINDING_URI.equals(bindingUri)) { logoutHandler.destroySessionBack(context.getWebContext(), sloKey); } else { logoutHandler.destroySessionFront(context.getWebContext(), sloKey); } } }
java
protected void validateLogoutRequest(final LogoutRequest logoutRequest, final SAML2MessageContext context, final SignatureTrustEngine engine) { validateSignatureIfItExists(logoutRequest.getSignature(), context, engine); // don't check because of CAS v5 //validateIssueInstant(logoutRequest.getIssueInstant()); validateIssuerIfItExists(logoutRequest.getIssuer(), context); NameID nameId = logoutRequest.getNameID(); final EncryptedID encryptedID = logoutRequest.getEncryptedID(); if (encryptedID != null) { nameId = decryptEncryptedId(encryptedID, decrypter); } String sessionIndex = null; final List<SessionIndex> sessionIndexes = logoutRequest.getSessionIndexes(); if (sessionIndexes != null && !sessionIndexes.isEmpty()) { final SessionIndex sessionIndexObject = sessionIndexes.get(0); if (sessionIndexObject != null) { sessionIndex = sessionIndexObject.getSessionIndex(); } } final String sloKey = computeSloKey(sessionIndex, nameId); if (sloKey != null) { final String bindingUri = context.getSAMLBindingContext().getBindingUri(); if (SAMLConstants.SAML2_SOAP11_BINDING_URI.equals(bindingUri)) { logoutHandler.destroySessionBack(context.getWebContext(), sloKey); } else { logoutHandler.destroySessionFront(context.getWebContext(), sloKey); } } }
[ "protected", "void", "validateLogoutRequest", "(", "final", "LogoutRequest", "logoutRequest", ",", "final", "SAML2MessageContext", "context", ",", "final", "SignatureTrustEngine", "engine", ")", "{", "validateSignatureIfItExists", "(", "logoutRequest", ".", "getSignature", ...
Validates the SAML logout request. @param logoutRequest the logout request @param context the context @param engine the signature engine
[ "Validates", "the", "SAML", "logout", "request", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/logout/impl/SAML2LogoutValidator.java#L71-L105
32,619
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/logout/impl/SAML2LogoutValidator.java
SAML2LogoutValidator.validateLogoutResponse
protected void validateLogoutResponse(final LogoutResponse logoutResponse, final SAML2MessageContext context, final SignatureTrustEngine engine) { validateSuccess(logoutResponse.getStatus()); validateSignatureIfItExists(logoutResponse.getSignature(), context, engine); validateIssueInstant(logoutResponse.getIssueInstant()); validateIssuerIfItExists(logoutResponse.getIssuer(), context); verifyEndpoint(context.getSPSSODescriptor().getSingleLogoutServices().get(0), logoutResponse.getDestination()); }
java
protected void validateLogoutResponse(final LogoutResponse logoutResponse, final SAML2MessageContext context, final SignatureTrustEngine engine) { validateSuccess(logoutResponse.getStatus()); validateSignatureIfItExists(logoutResponse.getSignature(), context, engine); validateIssueInstant(logoutResponse.getIssueInstant()); validateIssuerIfItExists(logoutResponse.getIssuer(), context); verifyEndpoint(context.getSPSSODescriptor().getSingleLogoutServices().get(0), logoutResponse.getDestination()); }
[ "protected", "void", "validateLogoutResponse", "(", "final", "LogoutResponse", "logoutResponse", ",", "final", "SAML2MessageContext", "context", ",", "final", "SignatureTrustEngine", "engine", ")", "{", "validateSuccess", "(", "logoutResponse", ".", "getStatus", "(", ")...
Validates the SAML logout response. @param logoutResponse the logout response @param context the context @param engine the signature engine
[ "Validates", "the", "SAML", "logout", "response", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/logout/impl/SAML2LogoutValidator.java#L114-L126
32,620
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java
ContextHelper.isGet
public static boolean isGet(final WebContext context) { return HttpConstants.HTTP_METHOD.GET.name().equalsIgnoreCase(context.getRequestMethod()); }
java
public static boolean isGet(final WebContext context) { return HttpConstants.HTTP_METHOD.GET.name().equalsIgnoreCase(context.getRequestMethod()); }
[ "public", "static", "boolean", "isGet", "(", "final", "WebContext", "context", ")", "{", "return", "HttpConstants", ".", "HTTP_METHOD", ".", "GET", ".", "name", "(", ")", ".", "equalsIgnoreCase", "(", "context", ".", "getRequestMethod", "(", ")", ")", ";", ...
Whether it is a GET request. @param context the web context @return whether it is a GET request
[ "Whether", "it", "is", "a", "GET", "request", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java#L50-L52
32,621
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java
ContextHelper.isPost
public static boolean isPost(final WebContext context) { return HttpConstants.HTTP_METHOD.POST.name().equalsIgnoreCase(context.getRequestMethod()); }
java
public static boolean isPost(final WebContext context) { return HttpConstants.HTTP_METHOD.POST.name().equalsIgnoreCase(context.getRequestMethod()); }
[ "public", "static", "boolean", "isPost", "(", "final", "WebContext", "context", ")", "{", "return", "HttpConstants", ".", "HTTP_METHOD", ".", "POST", ".", "name", "(", ")", ".", "equalsIgnoreCase", "(", "context", ".", "getRequestMethod", "(", ")", ")", ";",...
Whether it is a POST request. @param context the web context @return whether it is a POST request
[ "Whether", "it", "is", "a", "POST", "request", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java#L60-L62
32,622
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java
ContextHelper.isPut
public static boolean isPut(final WebContext context) { return HttpConstants.HTTP_METHOD.PUT.name().equalsIgnoreCase(context.getRequestMethod()); }
java
public static boolean isPut(final WebContext context) { return HttpConstants.HTTP_METHOD.PUT.name().equalsIgnoreCase(context.getRequestMethod()); }
[ "public", "static", "boolean", "isPut", "(", "final", "WebContext", "context", ")", "{", "return", "HttpConstants", ".", "HTTP_METHOD", ".", "PUT", ".", "name", "(", ")", ".", "equalsIgnoreCase", "(", "context", ".", "getRequestMethod", "(", ")", ")", ";", ...
Whether it is a PUT request. @param context the web context @return whether it is a PUT request
[ "Whether", "it", "is", "a", "PUT", "request", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java#L70-L72
32,623
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java
ContextHelper.isPatch
public static boolean isPatch(final WebContext context) { return HttpConstants.HTTP_METHOD.PATCH.name().equalsIgnoreCase(context.getRequestMethod()); }
java
public static boolean isPatch(final WebContext context) { return HttpConstants.HTTP_METHOD.PATCH.name().equalsIgnoreCase(context.getRequestMethod()); }
[ "public", "static", "boolean", "isPatch", "(", "final", "WebContext", "context", ")", "{", "return", "HttpConstants", ".", "HTTP_METHOD", ".", "PATCH", ".", "name", "(", ")", ".", "equalsIgnoreCase", "(", "context", ".", "getRequestMethod", "(", ")", ")", ";...
Whether it is a PATCH request. @param context the web context @return whether it is a PATCH request
[ "Whether", "it", "is", "a", "PATCH", "request", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java#L80-L82
32,624
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java
ContextHelper.isDelete
public static boolean isDelete(final WebContext context) { return HttpConstants.HTTP_METHOD.DELETE.name().equalsIgnoreCase(context.getRequestMethod()); }
java
public static boolean isDelete(final WebContext context) { return HttpConstants.HTTP_METHOD.DELETE.name().equalsIgnoreCase(context.getRequestMethod()); }
[ "public", "static", "boolean", "isDelete", "(", "final", "WebContext", "context", ")", "{", "return", "HttpConstants", ".", "HTTP_METHOD", ".", "DELETE", ".", "name", "(", ")", ".", "equalsIgnoreCase", "(", "context", ".", "getRequestMethod", "(", ")", ")", ...
Whether it is a DELETE request. @param context the web context @return whether it is a DELETE request
[ "Whether", "it", "is", "a", "DELETE", "request", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/context/ContextHelper.java#L90-L92
32,625
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/profile/impl/AbstractSAML2ResponseValidator.java
AbstractSAML2ResponseValidator.validateSuccess
protected final void validateSuccess(final Status status) { String statusValue = status.getStatusCode().getValue(); if (!StatusCode.SUCCESS.equals(statusValue)) { final StatusMessage statusMessage = status.getStatusMessage(); if (statusMessage != null) { statusValue += " / " + statusMessage.getMessage(); } throw new SAMLException("Response is not success ; actual " + statusValue); } }
java
protected final void validateSuccess(final Status status) { String statusValue = status.getStatusCode().getValue(); if (!StatusCode.SUCCESS.equals(statusValue)) { final StatusMessage statusMessage = status.getStatusMessage(); if (statusMessage != null) { statusValue += " / " + statusMessage.getMessage(); } throw new SAMLException("Response is not success ; actual " + statusValue); } }
[ "protected", "final", "void", "validateSuccess", "(", "final", "Status", "status", ")", "{", "String", "statusValue", "=", "status", ".", "getStatusCode", "(", ")", ".", "getValue", "(", ")", ";", "if", "(", "!", "StatusCode", ".", "SUCCESS", ".", "equals"...
Validates that the response is a success. @param status the response status.
[ "Validates", "that", "the", "response", "is", "a", "success", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/profile/impl/AbstractSAML2ResponseValidator.java#L72-L81
32,626
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/profile/impl/AbstractSAML2ResponseValidator.java
AbstractSAML2ResponseValidator.validateSignature
protected final void validateSignature(final Signature signature, final String idpEntityId, final SignatureTrustEngine trustEngine) { final SAMLSignatureProfileValidator validator = new SAMLSignatureProfileValidator(); try { validator.validate(signature); } catch (final SignatureException e) { throw new SAMLSignatureValidationException("SAMLSignatureProfileValidator failed to validate signature", e); } final CriteriaSet criteriaSet = new CriteriaSet(); criteriaSet.add(new UsageCriterion(UsageType.SIGNING)); criteriaSet.add(new EntityRoleCriterion(IDPSSODescriptor.DEFAULT_ELEMENT_NAME)); criteriaSet.add(new ProtocolCriterion(SAMLConstants.SAML20P_NS)); criteriaSet.add(new EntityIdCriterion(idpEntityId)); final boolean valid; try { valid = trustEngine.validate(signature, criteriaSet); } catch (final SecurityException e) { throw new SAMLSignatureValidationException("An error occurred during signature validation", e); } if (!valid) { throw new SAMLSignatureValidationException("Signature is not trusted"); } }
java
protected final void validateSignature(final Signature signature, final String idpEntityId, final SignatureTrustEngine trustEngine) { final SAMLSignatureProfileValidator validator = new SAMLSignatureProfileValidator(); try { validator.validate(signature); } catch (final SignatureException e) { throw new SAMLSignatureValidationException("SAMLSignatureProfileValidator failed to validate signature", e); } final CriteriaSet criteriaSet = new CriteriaSet(); criteriaSet.add(new UsageCriterion(UsageType.SIGNING)); criteriaSet.add(new EntityRoleCriterion(IDPSSODescriptor.DEFAULT_ELEMENT_NAME)); criteriaSet.add(new ProtocolCriterion(SAMLConstants.SAML20P_NS)); criteriaSet.add(new EntityIdCriterion(idpEntityId)); final boolean valid; try { valid = trustEngine.validate(signature, criteriaSet); } catch (final SecurityException e) { throw new SAMLSignatureValidationException("An error occurred during signature validation", e); } if (!valid) { throw new SAMLSignatureValidationException("Signature is not trusted"); } }
[ "protected", "final", "void", "validateSignature", "(", "final", "Signature", "signature", ",", "final", "String", "idpEntityId", ",", "final", "SignatureTrustEngine", "trustEngine", ")", "{", "final", "SAMLSignatureProfileValidator", "validator", "=", "new", "SAMLSigna...
Validate the given digital signature by checking its profile and value. @param signature the signature @param idpEntityId the idp entity id @param trustEngine the trust engine
[ "Validate", "the", "given", "digital", "signature", "by", "checking", "its", "profile", "and", "value", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/profile/impl/AbstractSAML2ResponseValidator.java#L99-L123
32,627
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/profile/impl/AbstractSAML2ResponseValidator.java
AbstractSAML2ResponseValidator.validateIssuer
protected final void validateIssuer(final Issuer issuer, final SAML2MessageContext context) { if (issuer.getFormat() != null && !issuer.getFormat().equals(NameIDType.ENTITY)) { throw new SAMLIssuerException("Issuer type is not entity but " + issuer.getFormat()); } final String entityId = context.getSAMLPeerEntityContext().getEntityId(); if (entityId == null || !entityId.equals(issuer.getValue())) { throw new SAMLIssuerException("Issuer " + issuer.getValue() + " does not match idp entityId " + entityId); } }
java
protected final void validateIssuer(final Issuer issuer, final SAML2MessageContext context) { if (issuer.getFormat() != null && !issuer.getFormat().equals(NameIDType.ENTITY)) { throw new SAMLIssuerException("Issuer type is not entity but " + issuer.getFormat()); } final String entityId = context.getSAMLPeerEntityContext().getEntityId(); if (entityId == null || !entityId.equals(issuer.getValue())) { throw new SAMLIssuerException("Issuer " + issuer.getValue() + " does not match idp entityId " + entityId); } }
[ "protected", "final", "void", "validateIssuer", "(", "final", "Issuer", "issuer", ",", "final", "SAML2MessageContext", "context", ")", "{", "if", "(", "issuer", ".", "getFormat", "(", ")", "!=", "null", "&&", "!", "issuer", ".", "getFormat", "(", ")", ".",...
Validate issuer format and value. @param issuer the issuer @param context the context
[ "Validate", "issuer", "format", "and", "value", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/profile/impl/AbstractSAML2ResponseValidator.java#L137-L146
32,628
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/profile/impl/AbstractSAML2ResponseValidator.java
AbstractSAML2ResponseValidator.decryptEncryptedId
protected final NameID decryptEncryptedId(final EncryptedID encryptedId, final Decrypter decrypter) throws SAMLException { if (encryptedId == null) { return null; } if (decrypter == null) { logger.warn("Encrypted attributes returned, but no keystore was provided."); return null; } try { final NameID decryptedId = (NameID) decrypter.decrypt(encryptedId); return decryptedId; } catch (final DecryptionException e) { throw new SAMLNameIdDecryptionException("Decryption of an EncryptedID failed.", e); } }
java
protected final NameID decryptEncryptedId(final EncryptedID encryptedId, final Decrypter decrypter) throws SAMLException { if (encryptedId == null) { return null; } if (decrypter == null) { logger.warn("Encrypted attributes returned, but no keystore was provided."); return null; } try { final NameID decryptedId = (NameID) decrypter.decrypt(encryptedId); return decryptedId; } catch (final DecryptionException e) { throw new SAMLNameIdDecryptionException("Decryption of an EncryptedID failed.", e); } }
[ "protected", "final", "NameID", "decryptEncryptedId", "(", "final", "EncryptedID", "encryptedId", ",", "final", "Decrypter", "decrypter", ")", "throws", "SAMLException", "{", "if", "(", "encryptedId", "==", "null", ")", "{", "return", "null", ";", "}", "if", "...
Decrypts an EncryptedID, using a decrypter. @param encryptedId The EncryptedID to be decrypted. @param decrypter The decrypter to use. @return Decrypted ID or {@code null} if any input is {@code null}. @throws SAMLException If the input ID cannot be decrypted.
[ "Decrypts", "an", "EncryptedID", "using", "a", "decrypter", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/profile/impl/AbstractSAML2ResponseValidator.java#L195-L210
32,629
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPPostEncoder.java
Pac4jHTTPPostEncoder.populateVelocityContext
protected void populateVelocityContext(VelocityContext velocityContext, MessageContext<SAMLObject> messageContext, String endpointURL) throws MessageEncodingException { String encodedEndpointURL = HTMLEncoder.encodeForHTMLAttribute(endpointURL); log.debug("Encoding action url of '{}' with encoded value '{}'", endpointURL, encodedEndpointURL); velocityContext.put("action", encodedEndpointURL); velocityContext.put("binding", getBindingURI()); SAMLObject outboundMessage = messageContext.getMessage(); log.debug("Marshalling and Base64 encoding SAML message"); Element domMessage = marshallMessage(outboundMessage); String messageXML = SerializeSupport.nodeToString(domMessage); log.trace("Output XML message: {}", messageXML); String encodedMessage = Base64Support.encode(messageXML.getBytes(StandardCharsets.UTF_8), Base64Support.UNCHUNKED); if (outboundMessage instanceof RequestAbstractType) { velocityContext.put("SAMLRequest", encodedMessage); } else if (outboundMessage instanceof StatusResponseType) { velocityContext.put("SAMLResponse", encodedMessage); } else { throw new MessageEncodingException( "SAML message is neither a SAML RequestAbstractType or StatusResponseType"); } String relayState = SAMLBindingSupport.getRelayState(messageContext); if (SAMLBindingSupport.checkRelayState(relayState)) { String encodedRelayState = HTMLEncoder.encodeForHTMLAttribute(relayState); log.debug("Setting RelayState parameter to: '{}', encoded as '{}'", relayState, encodedRelayState); velocityContext.put("RelayState", encodedRelayState); } }
java
protected void populateVelocityContext(VelocityContext velocityContext, MessageContext<SAMLObject> messageContext, String endpointURL) throws MessageEncodingException { String encodedEndpointURL = HTMLEncoder.encodeForHTMLAttribute(endpointURL); log.debug("Encoding action url of '{}' with encoded value '{}'", endpointURL, encodedEndpointURL); velocityContext.put("action", encodedEndpointURL); velocityContext.put("binding", getBindingURI()); SAMLObject outboundMessage = messageContext.getMessage(); log.debug("Marshalling and Base64 encoding SAML message"); Element domMessage = marshallMessage(outboundMessage); String messageXML = SerializeSupport.nodeToString(domMessage); log.trace("Output XML message: {}", messageXML); String encodedMessage = Base64Support.encode(messageXML.getBytes(StandardCharsets.UTF_8), Base64Support.UNCHUNKED); if (outboundMessage instanceof RequestAbstractType) { velocityContext.put("SAMLRequest", encodedMessage); } else if (outboundMessage instanceof StatusResponseType) { velocityContext.put("SAMLResponse", encodedMessage); } else { throw new MessageEncodingException( "SAML message is neither a SAML RequestAbstractType or StatusResponseType"); } String relayState = SAMLBindingSupport.getRelayState(messageContext); if (SAMLBindingSupport.checkRelayState(relayState)) { String encodedRelayState = HTMLEncoder.encodeForHTMLAttribute(relayState); log.debug("Setting RelayState parameter to: '{}', encoded as '{}'", relayState, encodedRelayState); velocityContext.put("RelayState", encodedRelayState); } }
[ "protected", "void", "populateVelocityContext", "(", "VelocityContext", "velocityContext", ",", "MessageContext", "<", "SAMLObject", ">", "messageContext", ",", "String", "endpointURL", ")", "throws", "MessageEncodingException", "{", "String", "encodedEndpointURL", "=", "...
Populate the Velocity context instance which will be used to render the POST body. @param velocityContext the Velocity context instance to populate with data @param messageContext the SAML message context source of data @param endpointURL endpoint URL to which to encode message @throws MessageEncodingException thrown if there is a problem encoding the message
[ "Populate", "the", "Velocity", "context", "instance", "which", "will", "be", "used", "to", "render", "the", "POST", "body", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPPostEncoder.java#L166-L197
32,630
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPPostEncoder.java
Pac4jHTTPPostEncoder.marshallMessage
protected Element marshallMessage(XMLObject message) throws MessageEncodingException { log.debug("Marshalling message"); try { return XMLObjectSupport.marshall(message); } catch (MarshallingException e) { throw new MessageEncodingException("Error marshalling message", e); } }
java
protected Element marshallMessage(XMLObject message) throws MessageEncodingException { log.debug("Marshalling message"); try { return XMLObjectSupport.marshall(message); } catch (MarshallingException e) { throw new MessageEncodingException("Error marshalling message", e); } }
[ "protected", "Element", "marshallMessage", "(", "XMLObject", "message", ")", "throws", "MessageEncodingException", "{", "log", ".", "debug", "(", "\"Marshalling message\"", ")", ";", "try", "{", "return", "XMLObjectSupport", ".", "marshall", "(", "message", ")", "...
Helper method that marshalls the given message. @param message message the marshall and serialize @return marshalled message @throws MessageEncodingException thrown if the give message can not be marshalled into its DOM representation
[ "Helper", "method", "that", "marshalls", "the", "given", "message", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPPostEncoder.java#L224-L232
32,631
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/ProfileManager.java
ProfileManager.getAll
public List<U> getAll(final boolean readFromSession) { final LinkedHashMap<String, U> profiles = retrieveAll(readFromSession); return ProfileHelper.flatIntoAProfileList(profiles); }
java
public List<U> getAll(final boolean readFromSession) { final LinkedHashMap<String, U> profiles = retrieveAll(readFromSession); return ProfileHelper.flatIntoAProfileList(profiles); }
[ "public", "List", "<", "U", ">", "getAll", "(", "final", "boolean", "readFromSession", ")", "{", "final", "LinkedHashMap", "<", "String", ",", "U", ">", "profiles", "=", "retrieveAll", "(", "readFromSession", ")", ";", "return", "ProfileHelper", ".", "flatIn...
Retrieve all user profiles. @param readFromSession if the user profiles must be read from session @return the user profiles
[ "Retrieve", "all", "user", "profiles", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/ProfileManager.java#L58-L61
32,632
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/ProfileManager.java
ProfileManager.retrieveAll
protected LinkedHashMap<String, U> retrieveAll(final boolean readFromSession) { final LinkedHashMap<String, U> profiles = new LinkedHashMap<>(); this.context.getRequestAttribute(Pac4jConstants.USER_PROFILES) .ifPresent(request -> { if (request instanceof LinkedHashMap) { profiles.putAll((LinkedHashMap<String, U>) request); } if (request instanceof CommonProfile) { profiles.put(retrieveClientName((U) request), (U) request); } }); if (readFromSession) { this.sessionStore.get(this.context, Pac4jConstants.USER_PROFILES) .ifPresent(sessionAttribute -> { if (sessionAttribute instanceof LinkedHashMap) { profiles.putAll((LinkedHashMap<String, U>) sessionAttribute); } if (sessionAttribute instanceof CommonProfile) { profiles.put(retrieveClientName((U) sessionAttribute), (U) sessionAttribute); } }); } removeExpiredProfiles(profiles); return profiles; }
java
protected LinkedHashMap<String, U> retrieveAll(final boolean readFromSession) { final LinkedHashMap<String, U> profiles = new LinkedHashMap<>(); this.context.getRequestAttribute(Pac4jConstants.USER_PROFILES) .ifPresent(request -> { if (request instanceof LinkedHashMap) { profiles.putAll((LinkedHashMap<String, U>) request); } if (request instanceof CommonProfile) { profiles.put(retrieveClientName((U) request), (U) request); } }); if (readFromSession) { this.sessionStore.get(this.context, Pac4jConstants.USER_PROFILES) .ifPresent(sessionAttribute -> { if (sessionAttribute instanceof LinkedHashMap) { profiles.putAll((LinkedHashMap<String, U>) sessionAttribute); } if (sessionAttribute instanceof CommonProfile) { profiles.put(retrieveClientName((U) sessionAttribute), (U) sessionAttribute); } }); } removeExpiredProfiles(profiles); return profiles; }
[ "protected", "LinkedHashMap", "<", "String", ",", "U", ">", "retrieveAll", "(", "final", "boolean", "readFromSession", ")", "{", "final", "LinkedHashMap", "<", "String", ",", "U", ">", "profiles", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "this", "...
Retrieve the map of profiles from the session or the request. @param readFromSession if the user profiles must be read from session @return the map of profiles
[ "Retrieve", "the", "map", "of", "profiles", "from", "the", "session", "or", "the", "request", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/ProfileManager.java#L69-L95
32,633
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/InternalAttributeHandler.java
InternalAttributeHandler.prepare
public Object prepare(final Object value) { if (value == null || value instanceof String || !stringify) { return value; } else { if (value instanceof Boolean) { return PREFIX_BOOLEAN.concat(value.toString()); } else if (value instanceof Integer) { return PREFIX_INT.concat(value.toString()); } else if (value instanceof Long) { return PREFIX_LONG.concat(value.toString()); } else if (value instanceof Date) { return PREFIX_DATE.concat(newSdf().format((Date) value)); } else if (value instanceof URI) { return PREFIX_URI.concat(value.toString()); } else { return PREFIX_SB64.concat(serializationHelper.serializeToBase64((Serializable) value)); } } }
java
public Object prepare(final Object value) { if (value == null || value instanceof String || !stringify) { return value; } else { if (value instanceof Boolean) { return PREFIX_BOOLEAN.concat(value.toString()); } else if (value instanceof Integer) { return PREFIX_INT.concat(value.toString()); } else if (value instanceof Long) { return PREFIX_LONG.concat(value.toString()); } else if (value instanceof Date) { return PREFIX_DATE.concat(newSdf().format((Date) value)); } else if (value instanceof URI) { return PREFIX_URI.concat(value.toString()); } else { return PREFIX_SB64.concat(serializationHelper.serializeToBase64((Serializable) value)); } } }
[ "public", "Object", "prepare", "(", "final", "Object", "value", ")", "{", "if", "(", "value", "==", "null", "||", "value", "instanceof", "String", "||", "!", "stringify", ")", "{", "return", "value", ";", "}", "else", "{", "if", "(", "value", "instance...
Before saving the attribute into the attributes map. @param value the original value @return the prepared value
[ "Before", "saving", "the", "attribute", "into", "the", "attributes", "map", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/InternalAttributeHandler.java#L44-L62
32,634
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/InternalAttributeHandler.java
InternalAttributeHandler.restore
public Object restore(final Object value) { if (value != null && value instanceof String) { final String sValue = (String) value; if (sValue.startsWith(PREFIX)) { if (sValue.startsWith(PREFIX_BOOLEAN)) { return Boolean.parseBoolean(sValue.substring(PREFIX_BOOLEAN.length())); } else if (sValue.startsWith(PREFIX_INT)) { return Integer.parseInt(sValue.substring(PREFIX_INT.length())); } else if (sValue.startsWith(PREFIX_LONG)) { return Long.parseLong(sValue.substring(PREFIX_LONG.length())); } else if (sValue.startsWith(PREFIX_DATE)) { final String d = sValue.substring(PREFIX_DATE.length()); try { return newSdf().parse(d); } catch (final ParseException e) { logger.warn("Unable to parse stringified date: {}", d, e); } } else if (sValue.startsWith(PREFIX_URI)) { final String uri = sValue.substring(PREFIX_URI.length()); try { return new URI(uri); } catch (final URISyntaxException e) { logger.warn("Unable to parse stringified URI: {}", uri, e); } } else if (sValue.startsWith(PREFIX_SB64)) { return serializationHelper.deserializeFromBase64(sValue.substring(PREFIX_SB64.length())); } } } return value; }
java
public Object restore(final Object value) { if (value != null && value instanceof String) { final String sValue = (String) value; if (sValue.startsWith(PREFIX)) { if (sValue.startsWith(PREFIX_BOOLEAN)) { return Boolean.parseBoolean(sValue.substring(PREFIX_BOOLEAN.length())); } else if (sValue.startsWith(PREFIX_INT)) { return Integer.parseInt(sValue.substring(PREFIX_INT.length())); } else if (sValue.startsWith(PREFIX_LONG)) { return Long.parseLong(sValue.substring(PREFIX_LONG.length())); } else if (sValue.startsWith(PREFIX_DATE)) { final String d = sValue.substring(PREFIX_DATE.length()); try { return newSdf().parse(d); } catch (final ParseException e) { logger.warn("Unable to parse stringified date: {}", d, e); } } else if (sValue.startsWith(PREFIX_URI)) { final String uri = sValue.substring(PREFIX_URI.length()); try { return new URI(uri); } catch (final URISyntaxException e) { logger.warn("Unable to parse stringified URI: {}", uri, e); } } else if (sValue.startsWith(PREFIX_SB64)) { return serializationHelper.deserializeFromBase64(sValue.substring(PREFIX_SB64.length())); } } } return value; }
[ "public", "Object", "restore", "(", "final", "Object", "value", ")", "{", "if", "(", "value", "!=", "null", "&&", "value", "instanceof", "String", ")", "{", "final", "String", "sValue", "=", "(", "String", ")", "value", ";", "if", "(", "sValue", ".", ...
After retrieving the attribute from the attributes map. @param value the retrieved value @return the restored value
[ "After", "retrieving", "the", "attribute", "from", "the", "attributes", "map", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/InternalAttributeHandler.java#L70-L100
32,635
pac4j/pac4j
pac4j-config/src/main/java/org/pac4j/config/ldaptive/LdaptiveAuthenticatorBuilder.java
LdaptiveAuthenticatorBuilder.newSearchEntryResolver
public static EntryResolver newSearchEntryResolver(final LdapAuthenticationProperties l) { final PooledSearchEntryResolver entryResolver = new PooledSearchEntryResolver(); entryResolver.setBaseDn(l.getBaseDn()); entryResolver.setUserFilter(l.getUserFilter()); entryResolver.setSubtreeSearch(l.isSubtreeSearch()); entryResolver.setConnectionFactory(LdaptiveAuthenticatorBuilder.newPooledConnectionFactory(l)); return entryResolver; }
java
public static EntryResolver newSearchEntryResolver(final LdapAuthenticationProperties l) { final PooledSearchEntryResolver entryResolver = new PooledSearchEntryResolver(); entryResolver.setBaseDn(l.getBaseDn()); entryResolver.setUserFilter(l.getUserFilter()); entryResolver.setSubtreeSearch(l.isSubtreeSearch()); entryResolver.setConnectionFactory(LdaptiveAuthenticatorBuilder.newPooledConnectionFactory(l)); return entryResolver; }
[ "public", "static", "EntryResolver", "newSearchEntryResolver", "(", "final", "LdapAuthenticationProperties", "l", ")", "{", "final", "PooledSearchEntryResolver", "entryResolver", "=", "new", "PooledSearchEntryResolver", "(", ")", ";", "entryResolver", ".", "setBaseDn", "(...
New dn resolver entry resolver. @param l the ldap settings @return the entry resolver
[ "New", "dn", "resolver", "entry", "resolver", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-config/src/main/java/org/pac4j/config/ldaptive/LdaptiveAuthenticatorBuilder.java#L166-L173
32,636
pac4j/pac4j
pac4j-oauth/src/main/java/org/pac4j/oauth/config/OAuthConfiguration.java
OAuthConfiguration.buildService
public S buildService(final WebContext context, final IndirectClient client, final String state) { init(); final String finalCallbackUrl = client.computeFinalCallbackUrl(context); return getApi().createService(this.key, this.secret, finalCallbackUrl, this.scope, null, state, this.responseType, null, this.httpClientConfig, null); }
java
public S buildService(final WebContext context, final IndirectClient client, final String state) { init(); final String finalCallbackUrl = client.computeFinalCallbackUrl(context); return getApi().createService(this.key, this.secret, finalCallbackUrl, this.scope, null, state, this.responseType, null, this.httpClientConfig, null); }
[ "public", "S", "buildService", "(", "final", "WebContext", "context", ",", "final", "IndirectClient", "client", ",", "final", "String", "state", ")", "{", "init", "(", ")", ";", "final", "String", "finalCallbackUrl", "=", "client", ".", "computeFinalCallbackUrl"...
Build an OAuth service from the web context and with a state. @param context the web context @param client the client @param state a given state @return the OAuth service
[ "Build", "an", "OAuth", "service", "from", "the", "web", "context", "and", "with", "a", "state", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-oauth/src/main/java/org/pac4j/oauth/config/OAuthConfiguration.java#L62-L69
32,637
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/ProfileAuthorizer.java
ProfileAuthorizer.isAllAuthorized
public boolean isAllAuthorized(final WebContext context, final List<U> profiles) { for (final U profile : profiles) { if (!isProfileAuthorized(context, profile)) { return handleError(context); } } return true; }
java
public boolean isAllAuthorized(final WebContext context, final List<U> profiles) { for (final U profile : profiles) { if (!isProfileAuthorized(context, profile)) { return handleError(context); } } return true; }
[ "public", "boolean", "isAllAuthorized", "(", "final", "WebContext", "context", ",", "final", "List", "<", "U", ">", "profiles", ")", "{", "for", "(", "final", "U", "profile", ":", "profiles", ")", "{", "if", "(", "!", "isProfileAuthorized", "(", "context",...
If all profiles are authorized. @param context the web context @param profiles the user profiles @return whether all profiles are authorized
[ "If", "all", "profiles", "are", "authorized", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/authorization/authorizer/ProfileAuthorizer.java#L23-L30
32,638
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/transport/AbstractPac4jDecoder.java
AbstractPac4jDecoder.populateBindingContext
protected void populateBindingContext(final SAML2MessageContext messageContext) { SAMLBindingContext bindingContext = messageContext.getSubcontext(SAMLBindingContext.class, true); bindingContext.setBindingUri(getBindingURI(messageContext)); bindingContext.setHasBindingSignature(false); bindingContext.setIntendedDestinationEndpointURIRequired(SAMLBindingSupport.isMessageSigned(messageContext)); }
java
protected void populateBindingContext(final SAML2MessageContext messageContext) { SAMLBindingContext bindingContext = messageContext.getSubcontext(SAMLBindingContext.class, true); bindingContext.setBindingUri(getBindingURI(messageContext)); bindingContext.setHasBindingSignature(false); bindingContext.setIntendedDestinationEndpointURIRequired(SAMLBindingSupport.isMessageSigned(messageContext)); }
[ "protected", "void", "populateBindingContext", "(", "final", "SAML2MessageContext", "messageContext", ")", "{", "SAMLBindingContext", "bindingContext", "=", "messageContext", ".", "getSubcontext", "(", "SAMLBindingContext", ".", "class", ",", "true", ")", ";", "bindingC...
Populate the context which carries information specific to this binding. @param messageContext the current message context
[ "Populate", "the", "context", "which", "carries", "information", "specific", "to", "this", "binding", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/transport/AbstractPac4jDecoder.java#L99-L104
32,639
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/transport/AbstractPac4jDecoder.java
AbstractPac4jDecoder.unmarshallMessage
protected XMLObject unmarshallMessage(InputStream messageStream) throws MessageDecodingException { try { XMLObject message = XMLObjectSupport.unmarshallFromInputStream(getParserPool(), messageStream); return message; } catch (XMLParserException e) { throw new MessageDecodingException("Error unmarshalling message from input stream", e); } catch (UnmarshallingException e) { throw new MessageDecodingException("Error unmarshalling message from input stream", e); } }
java
protected XMLObject unmarshallMessage(InputStream messageStream) throws MessageDecodingException { try { XMLObject message = XMLObjectSupport.unmarshallFromInputStream(getParserPool(), messageStream); return message; } catch (XMLParserException e) { throw new MessageDecodingException("Error unmarshalling message from input stream", e); } catch (UnmarshallingException e) { throw new MessageDecodingException("Error unmarshalling message from input stream", e); } }
[ "protected", "XMLObject", "unmarshallMessage", "(", "InputStream", "messageStream", ")", "throws", "MessageDecodingException", "{", "try", "{", "XMLObject", "message", "=", "XMLObjectSupport", ".", "unmarshallFromInputStream", "(", "getParserPool", "(", ")", ",", "messa...
Helper method that deserializes and unmarshalls the message from the given stream. @param messageStream input stream containing the message @return the inbound message @throws MessageDecodingException thrown if there is a problem deserializing and unmarshalling the message
[ "Helper", "method", "that", "deserializes", "and", "unmarshalls", "the", "message", "from", "the", "given", "stream", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/transport/AbstractPac4jDecoder.java#L123-L132
32,640
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/service/AbstractProfileService.java
AbstractProfileService.convertProfileAndPasswordToAttributes
protected Map<String, Object> convertProfileAndPasswordToAttributes(final U profile, final String password) { final Map<String, Object> storageAttributes = new HashMap<>(); storageAttributes.put(getIdAttribute(), profile.getId()); storageAttributes.put(LINKEDID, profile.getLinkedId()); storageAttributes.put(getUsernameAttribute(), profile.getUsername()); // if a password has been provided, encode it if (isNotBlank(password)) { final String encodedPassword; // encode password if we have a passwordEncoder (MongoDB, SQL but not for LDAP) if (passwordEncoder != null) { encodedPassword = passwordEncoder.encode(password); } else { encodedPassword = password; } storageAttributes.put(getPasswordAttribute(), encodedPassword); } // legacy mode: save the defined attributes if (isLegacyMode()) { for (final String attributeName : attributeNames) { storageAttributes.put(attributeName, profile.getAttribute(attributeName)); } } else { // new behaviour (>= v2.0): save the serialized profile storageAttributes.put(SERIALIZED_PROFILE, javaSerializationHelper.serializeToBase64(profile)); } return storageAttributes; }
java
protected Map<String, Object> convertProfileAndPasswordToAttributes(final U profile, final String password) { final Map<String, Object> storageAttributes = new HashMap<>(); storageAttributes.put(getIdAttribute(), profile.getId()); storageAttributes.put(LINKEDID, profile.getLinkedId()); storageAttributes.put(getUsernameAttribute(), profile.getUsername()); // if a password has been provided, encode it if (isNotBlank(password)) { final String encodedPassword; // encode password if we have a passwordEncoder (MongoDB, SQL but not for LDAP) if (passwordEncoder != null) { encodedPassword = passwordEncoder.encode(password); } else { encodedPassword = password; } storageAttributes.put(getPasswordAttribute(), encodedPassword); } // legacy mode: save the defined attributes if (isLegacyMode()) { for (final String attributeName : attributeNames) { storageAttributes.put(attributeName, profile.getAttribute(attributeName)); } } else { // new behaviour (>= v2.0): save the serialized profile storageAttributes.put(SERIALIZED_PROFILE, javaSerializationHelper.serializeToBase64(profile)); } return storageAttributes; }
[ "protected", "Map", "<", "String", ",", "Object", ">", "convertProfileAndPasswordToAttributes", "(", "final", "U", "profile", ",", "final", "String", "password", ")", "{", "final", "Map", "<", "String", ",", "Object", ">", "storageAttributes", "=", "new", "Has...
Convert a profile and a password into a map of attributes for the storage. @param profile the profile @param password the password @return the attributes
[ "Convert", "a", "profile", "and", "a", "password", "into", "a", "map", "of", "attributes", "for", "the", "storage", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/service/AbstractProfileService.java#L122-L148
32,641
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/service/AbstractProfileService.java
AbstractProfileService.defineAttributesToRead
protected List<String> defineAttributesToRead() { final List<String> names = new ArrayList<>(); names.add(getIdAttribute()); names.add(LINKEDID); // legacy mode: 'getIdAttribute()' + linkedid + username + attributes if (isLegacyMode()) { names.add(getUsernameAttribute()); names.addAll(Arrays.asList(attributeNames)); } else { // new beahviour (>= v2.0): 'getIdAttribute()' + linkedid + serializedprofile names.add(SERIALIZED_PROFILE); } return names; }
java
protected List<String> defineAttributesToRead() { final List<String> names = new ArrayList<>(); names.add(getIdAttribute()); names.add(LINKEDID); // legacy mode: 'getIdAttribute()' + linkedid + username + attributes if (isLegacyMode()) { names.add(getUsernameAttribute()); names.addAll(Arrays.asList(attributeNames)); } else { // new beahviour (>= v2.0): 'getIdAttribute()' + linkedid + serializedprofile names.add(SERIALIZED_PROFILE); } return names; }
[ "protected", "List", "<", "String", ">", "defineAttributesToRead", "(", ")", "{", "final", "List", "<", "String", ">", "names", "=", "new", "ArrayList", "<>", "(", ")", ";", "names", ".", "add", "(", "getIdAttribute", "(", ")", ")", ";", "names", ".", ...
Define the attributes to read in the storage. @return the attributes
[ "Define", "the", "attributes", "to", "read", "in", "the", "storage", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/service/AbstractProfileService.java#L196-L209
32,642
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/service/AbstractProfileService.java
AbstractProfileService.convertAttributesToProfile
protected U convertAttributesToProfile(final List<Map<String, Object>> listStorageAttributes, final String username) { if (listStorageAttributes == null || listStorageAttributes.size() == 0) { return null; } final Map<String, Object> storageAttributes = listStorageAttributes.get(0); final String linkedId = (String) storageAttributes.get(LINKEDID); // legacy mode: only read the defined attributes if (isLegacyMode()) { final U profile = getProfileDefinition().newProfile(); for (final String attributeName : attributeNames) { getProfileDefinition().convertAndAdd(profile, PROFILE_ATTRIBUTE, attributeName, storageAttributes.get(attributeName)); } final Object retrievedUsername = storageAttributes.get(getUsernameAttribute()); if (retrievedUsername != null) { profile.setId(ProfileHelper.sanitizeIdentifier(profile, retrievedUsername)); } else { profile.setId(username); } if (isNotBlank(linkedId)) { profile.setLinkedId(linkedId); } return profile; } else { // new behaviour (>= v2.0): read the serialized profile final String serializedProfile = (String) storageAttributes.get(SERIALIZED_PROFILE); if (serializedProfile == null) { throw new TechnicalException("No serialized profile found. You should certainly define the explicit attribute names you " + "want to retrieve"); } final U profile = (U) javaSerializationHelper.deserializeFromBase64(serializedProfile); if (profile == null) { throw new TechnicalException("No deserialized profile available. You should certainly define the explicit attribute " + "names you want to retrieve"); } final Object id = storageAttributes.get(getIdAttribute()); if (isBlank(profile.getId()) && id != null) { profile.setId(ProfileHelper.sanitizeIdentifier(profile, id)); } if (isBlank(profile.getLinkedId()) && isNotBlank(linkedId)) { profile.setLinkedId(linkedId); } return profile; } }
java
protected U convertAttributesToProfile(final List<Map<String, Object>> listStorageAttributes, final String username) { if (listStorageAttributes == null || listStorageAttributes.size() == 0) { return null; } final Map<String, Object> storageAttributes = listStorageAttributes.get(0); final String linkedId = (String) storageAttributes.get(LINKEDID); // legacy mode: only read the defined attributes if (isLegacyMode()) { final U profile = getProfileDefinition().newProfile(); for (final String attributeName : attributeNames) { getProfileDefinition().convertAndAdd(profile, PROFILE_ATTRIBUTE, attributeName, storageAttributes.get(attributeName)); } final Object retrievedUsername = storageAttributes.get(getUsernameAttribute()); if (retrievedUsername != null) { profile.setId(ProfileHelper.sanitizeIdentifier(profile, retrievedUsername)); } else { profile.setId(username); } if (isNotBlank(linkedId)) { profile.setLinkedId(linkedId); } return profile; } else { // new behaviour (>= v2.0): read the serialized profile final String serializedProfile = (String) storageAttributes.get(SERIALIZED_PROFILE); if (serializedProfile == null) { throw new TechnicalException("No serialized profile found. You should certainly define the explicit attribute names you " + "want to retrieve"); } final U profile = (U) javaSerializationHelper.deserializeFromBase64(serializedProfile); if (profile == null) { throw new TechnicalException("No deserialized profile available. You should certainly define the explicit attribute " + "names you want to retrieve"); } final Object id = storageAttributes.get(getIdAttribute()); if (isBlank(profile.getId()) && id != null) { profile.setId(ProfileHelper.sanitizeIdentifier(profile, id)); } if (isBlank(profile.getLinkedId()) && isNotBlank(linkedId)) { profile.setLinkedId(linkedId); } return profile; } }
[ "protected", "U", "convertAttributesToProfile", "(", "final", "List", "<", "Map", "<", "String", ",", "Object", ">", ">", "listStorageAttributes", ",", "final", "String", "username", ")", "{", "if", "(", "listStorageAttributes", "==", "null", "||", "listStorageA...
Convert the list of map of attributes from the storage into a profile. @param listStorageAttributes the list of map of attributes @param username the username used for login @return the profile
[ "Convert", "the", "list", "of", "map", "of", "attributes", "from", "the", "storage", "into", "a", "profile", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/service/AbstractProfileService.java#L218-L262
32,643
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/exception/http/RedirectionActionHelper.java
RedirectionActionHelper.buildRedirectUrlAction
public static RedirectionAction buildRedirectUrlAction(final WebContext context, final String location) { if (ContextHelper.isPost(context) && useModernHttpCodes) { return new SeeOtherAction(location); } else { return new FoundAction(location); } }
java
public static RedirectionAction buildRedirectUrlAction(final WebContext context, final String location) { if (ContextHelper.isPost(context) && useModernHttpCodes) { return new SeeOtherAction(location); } else { return new FoundAction(location); } }
[ "public", "static", "RedirectionAction", "buildRedirectUrlAction", "(", "final", "WebContext", "context", ",", "final", "String", "location", ")", "{", "if", "(", "ContextHelper", ".", "isPost", "(", "context", ")", "&&", "useModernHttpCodes", ")", "{", "return", ...
Build the appropriate redirection action for a location. @param context the web context @param location the location @return the appropriate redirection action
[ "Build", "the", "appropriate", "redirection", "action", "for", "a", "location", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/exception/http/RedirectionActionHelper.java#L25-L31
32,644
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/exception/http/RedirectionActionHelper.java
RedirectionActionHelper.buildFormPostContentAction
public static RedirectionAction buildFormPostContentAction(final WebContext context, final String content) { if (ContextHelper.isPost(context) && useModernHttpCodes) { return new TemporaryRedirectAction(content); } else { return new OkAction(content); } }
java
public static RedirectionAction buildFormPostContentAction(final WebContext context, final String content) { if (ContextHelper.isPost(context) && useModernHttpCodes) { return new TemporaryRedirectAction(content); } else { return new OkAction(content); } }
[ "public", "static", "RedirectionAction", "buildFormPostContentAction", "(", "final", "WebContext", "context", ",", "final", "String", "content", ")", "{", "if", "(", "ContextHelper", ".", "isPost", "(", "context", ")", "&&", "useModernHttpCodes", ")", "{", "return...
Build the appropriate redirection action for a content which is a form post. @param context the web context @param content the content @return the appropriate redirection action
[ "Build", "the", "appropriate", "redirection", "action", "for", "a", "content", "which", "is", "a", "form", "post", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/exception/http/RedirectionActionHelper.java#L40-L46
32,645
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/exception/http/RedirectionActionHelper.java
RedirectionActionHelper.buildFormPostContent
public static String buildFormPostContent(final WebContext context) { final String requestedUrl = context.getFullRequestURL(); final Map<String, String[]> parameters = context.getRequestParameters(); final StringBuilder buffer = new StringBuilder(); buffer.append("<html>\n"); buffer.append("<body>\n"); buffer.append("<form action=\"" + escapeHtml(requestedUrl) + "\" name=\"f\" method=\"post\">\n"); if (parameters != null) { for (final Map.Entry<String, String[]> entry : parameters.entrySet()) { final String[] values = entry.getValue(); if (values != null && values.length > 0) { buffer.append("<input type='hidden' name=\"" + escapeHtml(entry.getKey()) + "\" value=\"" + values[0] + "\" />\n"); } } } buffer.append("<input value='POST' type='submit' />\n"); buffer.append("</form>\n"); buffer.append("<script type='text/javascript'>document.forms['f'].submit();</script>\n"); buffer.append("</body>\n"); buffer.append("</html>\n"); return buffer.toString(); }
java
public static String buildFormPostContent(final WebContext context) { final String requestedUrl = context.getFullRequestURL(); final Map<String, String[]> parameters = context.getRequestParameters(); final StringBuilder buffer = new StringBuilder(); buffer.append("<html>\n"); buffer.append("<body>\n"); buffer.append("<form action=\"" + escapeHtml(requestedUrl) + "\" name=\"f\" method=\"post\">\n"); if (parameters != null) { for (final Map.Entry<String, String[]> entry : parameters.entrySet()) { final String[] values = entry.getValue(); if (values != null && values.length > 0) { buffer.append("<input type='hidden' name=\"" + escapeHtml(entry.getKey()) + "\" value=\"" + values[0] + "\" />\n"); } } } buffer.append("<input value='POST' type='submit' />\n"); buffer.append("</form>\n"); buffer.append("<script type='text/javascript'>document.forms['f'].submit();</script>\n"); buffer.append("</body>\n"); buffer.append("</html>\n"); return buffer.toString(); }
[ "public", "static", "String", "buildFormPostContent", "(", "final", "WebContext", "context", ")", "{", "final", "String", "requestedUrl", "=", "context", ".", "getFullRequestURL", "(", ")", ";", "final", "Map", "<", "String", ",", "String", "[", "]", ">", "p...
Build a form POST content from the web context. @param context the web context @return the form POST content
[ "Build", "a", "form", "POST", "content", "from", "the", "web", "context", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/exception/http/RedirectionActionHelper.java#L54-L75
32,646
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/definition/ProfileDefinition.java
ProfileDefinition.convertAndAdd
public void convertAndAdd(final CommonProfile profile, final AttributeLocation attributeLocation, final String name, final Object value) { if (value != null) { final Object convertedValue; final AttributeConverter<? extends Object> converter = this.converters.get(name); if (converter != null) { convertedValue = converter.convert(value); if (convertedValue != null) { logger.debug("converted to => key: {} / value: {} / {}", name, convertedValue, convertedValue.getClass()); } } else { convertedValue = value; logger.debug("no conversion => key: {} / value: {} / {}", name, convertedValue, convertedValue.getClass()); } if (attributeLocation.equals(AUTHENTICATION_ATTRIBUTE)) { profile.addAuthenticationAttribute(name, convertedValue); } else { profile.addAttribute(name, convertedValue); } } }
java
public void convertAndAdd(final CommonProfile profile, final AttributeLocation attributeLocation, final String name, final Object value) { if (value != null) { final Object convertedValue; final AttributeConverter<? extends Object> converter = this.converters.get(name); if (converter != null) { convertedValue = converter.convert(value); if (convertedValue != null) { logger.debug("converted to => key: {} / value: {} / {}", name, convertedValue, convertedValue.getClass()); } } else { convertedValue = value; logger.debug("no conversion => key: {} / value: {} / {}", name, convertedValue, convertedValue.getClass()); } if (attributeLocation.equals(AUTHENTICATION_ATTRIBUTE)) { profile.addAuthenticationAttribute(name, convertedValue); } else { profile.addAttribute(name, convertedValue); } } }
[ "public", "void", "convertAndAdd", "(", "final", "CommonProfile", "profile", ",", "final", "AttributeLocation", "attributeLocation", ",", "final", "String", "name", ",", "final", "Object", "value", ")", "{", "if", "(", "value", "!=", "null", ")", "{", "final",...
Convert a profile or authentication attribute, if necessary, and add it to the profile. @param profile The profile. @param attributeLocation Location of the attribute inside the profile: classic profile attribute, authentication attribute, ... @param name The attribute name. @param value The attribute value.
[ "Convert", "a", "profile", "or", "authentication", "attribute", "if", "necessary", "and", "add", "it", "to", "the", "profile", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/definition/ProfileDefinition.java#L57-L78
32,647
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/definition/ProfileDefinition.java
ProfileDefinition.convertAndAdd
public void convertAndAdd(final CommonProfile profile, final Map<String, Object> profileAttributes, final Map<String, Object> authenticationAttributes) { if (profileAttributes != null) { profileAttributes.entrySet().stream() .forEach(entry -> convertAndAdd(profile, PROFILE_ATTRIBUTE, entry.getKey(), entry.getValue())); } if (authenticationAttributes != null) { authenticationAttributes.entrySet().stream() .forEach(entry -> convertAndAdd(profile, AUTHENTICATION_ATTRIBUTE, entry.getKey(), entry.getValue())); } }
java
public void convertAndAdd(final CommonProfile profile, final Map<String, Object> profileAttributes, final Map<String, Object> authenticationAttributes) { if (profileAttributes != null) { profileAttributes.entrySet().stream() .forEach(entry -> convertAndAdd(profile, PROFILE_ATTRIBUTE, entry.getKey(), entry.getValue())); } if (authenticationAttributes != null) { authenticationAttributes.entrySet().stream() .forEach(entry -> convertAndAdd(profile, AUTHENTICATION_ATTRIBUTE, entry.getKey(), entry.getValue())); } }
[ "public", "void", "convertAndAdd", "(", "final", "CommonProfile", "profile", ",", "final", "Map", "<", "String", ",", "Object", ">", "profileAttributes", ",", "final", "Map", "<", "String", ",", "Object", ">", "authenticationAttributes", ")", "{", "if", "(", ...
Convert the profile and authentication attributes, if necessary, and add them to the profile. @param profile The profile. @param profileAttributes The profile attributes. May be {@code null}. @param authenticationAttributes The authentication attributes. May be {@code null}.
[ "Convert", "the", "profile", "and", "authentication", "attributes", "if", "necessary", "and", "add", "them", "to", "the", "profile", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/definition/ProfileDefinition.java#L87-L98
32,648
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/definition/ProfileDefinition.java
ProfileDefinition.setProfileFactory
protected void setProfileFactory(final Function<Object[], P> profileFactory) { CommonHelper.assertNotNull("profileFactory", profileFactory); this.newProfile = profileFactory; }
java
protected void setProfileFactory(final Function<Object[], P> profileFactory) { CommonHelper.assertNotNull("profileFactory", profileFactory); this.newProfile = profileFactory; }
[ "protected", "void", "setProfileFactory", "(", "final", "Function", "<", "Object", "[", "]", ",", "P", ">", "profileFactory", ")", "{", "CommonHelper", ".", "assertNotNull", "(", "\"profileFactory\"", ",", "profileFactory", ")", ";", "this", ".", "newProfile", ...
Define the way to build the profile. @param profileFactory the way to build the profile
[ "Define", "the", "way", "to", "build", "the", "profile", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/definition/ProfileDefinition.java#L105-L108
32,649
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/definition/ProfileDefinition.java
ProfileDefinition.secondary
protected void secondary(final String name, final AttributeConverter<? extends Object> converter) { secondaries.add(name); converters.put(name, converter); }
java
protected void secondary(final String name, final AttributeConverter<? extends Object> converter) { secondaries.add(name); converters.put(name, converter); }
[ "protected", "void", "secondary", "(", "final", "String", "name", ",", "final", "AttributeConverter", "<", "?", "extends", "Object", ">", "converter", ")", "{", "secondaries", ".", "add", "(", "name", ")", ";", "converters", ".", "put", "(", "name", ",", ...
Add an attribute as a secondary one and its converter. @param name name of the attribute @param converter converter
[ "Add", "an", "attribute", "as", "a", "secondary", "one", "and", "its", "converter", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/definition/ProfileDefinition.java#L127-L130
32,650
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPRedirectDeflateEncoder.java
Pac4jHTTPRedirectDeflateEncoder.removeSignature
protected void removeSignature(SAMLObject message) { if (message instanceof SignableSAMLObject) { final SignableSAMLObject signableMessage = (SignableSAMLObject) message; if (signableMessage.isSigned()) { log.debug("Removing SAML protocol message signature"); signableMessage.setSignature(null); } } }
java
protected void removeSignature(SAMLObject message) { if (message instanceof SignableSAMLObject) { final SignableSAMLObject signableMessage = (SignableSAMLObject) message; if (signableMessage.isSigned()) { log.debug("Removing SAML protocol message signature"); signableMessage.setSignature(null); } } }
[ "protected", "void", "removeSignature", "(", "SAMLObject", "message", ")", "{", "if", "(", "message", "instanceof", "SignableSAMLObject", ")", "{", "final", "SignableSAMLObject", "signableMessage", "=", "(", "SignableSAMLObject", ")", "message", ";", "if", "(", "s...
Removes the signature from the protocol message. @param message current message context
[ "Removes", "the", "signature", "from", "the", "protocol", "message", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPRedirectDeflateEncoder.java#L102-L110
32,651
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPRedirectDeflateEncoder.java
Pac4jHTTPRedirectDeflateEncoder.buildRedirectURL
protected String buildRedirectURL(MessageContext<SAMLObject> messageContext, String endpoint, String message) throws MessageEncodingException { log.debug("Building URL to redirect client to"); URLBuilder urlBuilder; try { urlBuilder = new URLBuilder(endpoint); } catch (MalformedURLException e) { throw new MessageEncodingException("Endpoint URL " + endpoint + " is not a valid URL", e); } List<Pair<String, String>> queryParams = urlBuilder.getQueryParams(); queryParams.clear(); SAMLObject outboundMessage = messageContext.getMessage(); if (outboundMessage instanceof RequestAbstractType) { queryParams.add(new Pair<>("SAMLRequest", message)); } else if (outboundMessage instanceof StatusResponseType) { queryParams.add(new Pair<>("SAMLResponse", message)); } else { throw new MessageEncodingException( "SAML message is neither a SAML RequestAbstractType or StatusResponseType"); } String relayState = SAMLBindingSupport.getRelayState(messageContext); if (SAMLBindingSupport.checkRelayState(relayState)) { queryParams.add(new Pair<>("RelayState", relayState)); } SignatureSigningParameters signingParameters = SAMLMessageSecuritySupport.getContextSigningParameters(messageContext); if (signingParameters != null && signingParameters.getSigningCredential() != null) { String sigAlgURI = getSignatureAlgorithmURI(signingParameters); Pair<String, String> sigAlg = new Pair<>("SigAlg", sigAlgURI); queryParams.add(sigAlg); String sigMaterial = urlBuilder.buildQueryString(); queryParams.add(new Pair<>("Signature", generateSignature( signingParameters.getSigningCredential(), sigAlgURI, sigMaterial))); } else { log.debug("No signing credential was supplied, skipping HTTP-Redirect DEFLATE signing"); } return urlBuilder.buildURL(); }
java
protected String buildRedirectURL(MessageContext<SAMLObject> messageContext, String endpoint, String message) throws MessageEncodingException { log.debug("Building URL to redirect client to"); URLBuilder urlBuilder; try { urlBuilder = new URLBuilder(endpoint); } catch (MalformedURLException e) { throw new MessageEncodingException("Endpoint URL " + endpoint + " is not a valid URL", e); } List<Pair<String, String>> queryParams = urlBuilder.getQueryParams(); queryParams.clear(); SAMLObject outboundMessage = messageContext.getMessage(); if (outboundMessage instanceof RequestAbstractType) { queryParams.add(new Pair<>("SAMLRequest", message)); } else if (outboundMessage instanceof StatusResponseType) { queryParams.add(new Pair<>("SAMLResponse", message)); } else { throw new MessageEncodingException( "SAML message is neither a SAML RequestAbstractType or StatusResponseType"); } String relayState = SAMLBindingSupport.getRelayState(messageContext); if (SAMLBindingSupport.checkRelayState(relayState)) { queryParams.add(new Pair<>("RelayState", relayState)); } SignatureSigningParameters signingParameters = SAMLMessageSecuritySupport.getContextSigningParameters(messageContext); if (signingParameters != null && signingParameters.getSigningCredential() != null) { String sigAlgURI = getSignatureAlgorithmURI(signingParameters); Pair<String, String> sigAlg = new Pair<>("SigAlg", sigAlgURI); queryParams.add(sigAlg); String sigMaterial = urlBuilder.buildQueryString(); queryParams.add(new Pair<>("Signature", generateSignature( signingParameters.getSigningCredential(), sigAlgURI, sigMaterial))); } else { log.debug("No signing credential was supplied, skipping HTTP-Redirect DEFLATE signing"); } return urlBuilder.buildURL(); }
[ "protected", "String", "buildRedirectURL", "(", "MessageContext", "<", "SAMLObject", ">", "messageContext", ",", "String", "endpoint", ",", "String", "message", ")", "throws", "MessageEncodingException", "{", "log", ".", "debug", "(", "\"Building URL to redirect client ...
Builds the URL to redirect the client to. @param messageContext current message context @param endpoint endpoint URL to send encoded message to @param message Deflated and Base64 encoded message @return URL to redirect client to @throws MessageEncodingException thrown if the SAML message is neither a RequestAbstractType or Response
[ "Builds", "the", "URL", "to", "redirect", "the", "client", "to", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPRedirectDeflateEncoder.java#L169-L214
32,652
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPRedirectDeflateEncoder.java
Pac4jHTTPRedirectDeflateEncoder.getSignatureAlgorithmURI
protected String getSignatureAlgorithmURI(SignatureSigningParameters signingParameters) throws MessageEncodingException { if (signingParameters.getSignatureAlgorithm() != null) { return signingParameters.getSignatureAlgorithm(); } throw new MessageEncodingException("The signing algorithm URI could not be determined"); }
java
protected String getSignatureAlgorithmURI(SignatureSigningParameters signingParameters) throws MessageEncodingException { if (signingParameters.getSignatureAlgorithm() != null) { return signingParameters.getSignatureAlgorithm(); } throw new MessageEncodingException("The signing algorithm URI could not be determined"); }
[ "protected", "String", "getSignatureAlgorithmURI", "(", "SignatureSigningParameters", "signingParameters", ")", "throws", "MessageEncodingException", "{", "if", "(", "signingParameters", ".", "getSignatureAlgorithm", "(", ")", "!=", "null", ")", "{", "return", "signingPar...
Gets the signature algorithm URI to use. @param signingParameters the signing parameters to use @return signature algorithm to use with the associated signing credential @throws MessageEncodingException thrown if the algorithm URI is not supplied explicitly and could not be derived from the supplied credential
[ "Gets", "the", "signature", "algorithm", "URI", "to", "use", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPRedirectDeflateEncoder.java#L226-L234
32,653
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPRedirectDeflateEncoder.java
Pac4jHTTPRedirectDeflateEncoder.generateSignature
protected String generateSignature(Credential signingCredential, String algorithmURI, String queryString) throws MessageEncodingException { log.debug(String.format("Generating signature with key type '%s', algorithm URI '%s' over query string '%s'", CredentialSupport.extractSigningKey(signingCredential).getAlgorithm(), algorithmURI, queryString)); String b64Signature; try { byte[] rawSignature = XMLSigningUtil.signWithURI(signingCredential, algorithmURI, queryString.getBytes(StandardCharsets.UTF_8)); b64Signature = Base64Support.encode(rawSignature, Base64Support.UNCHUNKED); log.debug("Generated digital signature value (base64-encoded) {}", b64Signature); } catch (final org.opensaml.security.SecurityException e) { throw new MessageEncodingException("Unable to sign URL query string", e); } return b64Signature; }
java
protected String generateSignature(Credential signingCredential, String algorithmURI, String queryString) throws MessageEncodingException { log.debug(String.format("Generating signature with key type '%s', algorithm URI '%s' over query string '%s'", CredentialSupport.extractSigningKey(signingCredential).getAlgorithm(), algorithmURI, queryString)); String b64Signature; try { byte[] rawSignature = XMLSigningUtil.signWithURI(signingCredential, algorithmURI, queryString.getBytes(StandardCharsets.UTF_8)); b64Signature = Base64Support.encode(rawSignature, Base64Support.UNCHUNKED); log.debug("Generated digital signature value (base64-encoded) {}", b64Signature); } catch (final org.opensaml.security.SecurityException e) { throw new MessageEncodingException("Unable to sign URL query string", e); } return b64Signature; }
[ "protected", "String", "generateSignature", "(", "Credential", "signingCredential", ",", "String", "algorithmURI", ",", "String", "queryString", ")", "throws", "MessageEncodingException", "{", "log", ".", "debug", "(", "String", ".", "format", "(", "\"Generating signa...
Generates the signature over the query string. @param signingCredential credential that will be used to sign query string @param algorithmURI algorithm URI of the signing credential @param queryString query string to be signed @return base64 encoded signature of query string @throws MessageEncodingException there is an error computing the signature
[ "Generates", "the", "signature", "over", "the", "query", "string", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPRedirectDeflateEncoder.java#L247-L264
32,654
pac4j/pac4j
pac4j-oauth/src/main/java/org/pac4j/oauth/profile/JsonHelper.java
JsonHelper.getFirstNode
public static JsonNode getFirstNode(final String text, final String path) { try { JsonNode node = mapper.readValue(text, JsonNode.class); if (path != null) { node = (JsonNode) getElement(node, path); } return node; } catch (final IOException e) { logger.error("Cannot get first node", e); } return null; }
java
public static JsonNode getFirstNode(final String text, final String path) { try { JsonNode node = mapper.readValue(text, JsonNode.class); if (path != null) { node = (JsonNode) getElement(node, path); } return node; } catch (final IOException e) { logger.error("Cannot get first node", e); } return null; }
[ "public", "static", "JsonNode", "getFirstNode", "(", "final", "String", "text", ",", "final", "String", "path", ")", "{", "try", "{", "JsonNode", "node", "=", "mapper", ".", "readValue", "(", "text", ",", "JsonNode", ".", "class", ")", ";", "if", "(", ...
Return the first node of a JSON response. @param text JSON text @param path path to find the first node @return the first node of the JSON response or null if exception is thrown
[ "Return", "the", "first", "node", "of", "a", "JSON", "response", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-oauth/src/main/java/org/pac4j/oauth/profile/JsonHelper.java#L49-L60
32,655
pac4j/pac4j
pac4j-oauth/src/main/java/org/pac4j/oauth/profile/JsonHelper.java
JsonHelper.getElement
public static Object getElement(final JsonNode json, final String name) { if (json != null && name != null) { JsonNode node = json; for (String nodeName : name.split("\\.")) { if (node != null) { if (nodeName.matches("\\d+")) { node = node.get(Integer.parseInt(nodeName)); } else { node = node.get(nodeName); } } } if (node != null) { if (node.isNumber()) { return node.numberValue(); } else if (node.isBoolean()) { return node.booleanValue(); } else if (node.isTextual()) { return node.textValue(); } else if (node.isNull()) { return null; } else { return node; } } } return null; }
java
public static Object getElement(final JsonNode json, final String name) { if (json != null && name != null) { JsonNode node = json; for (String nodeName : name.split("\\.")) { if (node != null) { if (nodeName.matches("\\d+")) { node = node.get(Integer.parseInt(nodeName)); } else { node = node.get(nodeName); } } } if (node != null) { if (node.isNumber()) { return node.numberValue(); } else if (node.isBoolean()) { return node.booleanValue(); } else if (node.isTextual()) { return node.textValue(); } else if (node.isNull()) { return null; } else { return node; } } } return null; }
[ "public", "static", "Object", "getElement", "(", "final", "JsonNode", "json", ",", "final", "String", "name", ")", "{", "if", "(", "json", "!=", "null", "&&", "name", "!=", "null", ")", "{", "JsonNode", "node", "=", "json", ";", "for", "(", "String", ...
Return the field with name in JSON as a string, a boolean, a number or a node. @param json json @param name node name @return the field
[ "Return", "the", "field", "with", "name", "in", "JSON", "as", "a", "string", "a", "boolean", "a", "number", "or", "a", "node", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-oauth/src/main/java/org/pac4j/oauth/profile/JsonHelper.java#L69-L96
32,656
pac4j/pac4j
pac4j-oauth/src/main/java/org/pac4j/oauth/profile/JsonHelper.java
JsonHelper.toJSONString
public static String toJSONString(final Object obj) { try { return mapper.writeValueAsString(obj); } catch (final JsonProcessingException e) { logger.error("Cannot to JSON string", e); } return null; }
java
public static String toJSONString(final Object obj) { try { return mapper.writeValueAsString(obj); } catch (final JsonProcessingException e) { logger.error("Cannot to JSON string", e); } return null; }
[ "public", "static", "String", "toJSONString", "(", "final", "Object", "obj", ")", "{", "try", "{", "return", "mapper", ".", "writeValueAsString", "(", "obj", ")", ";", "}", "catch", "(", "final", "JsonProcessingException", "e", ")", "{", "logger", ".", "er...
Returns the JSON string for the object. @param obj the object @return the JSON string
[ "Returns", "the", "JSON", "string", "for", "the", "object", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-oauth/src/main/java/org/pac4j/oauth/profile/JsonHelper.java#L104-L111
32,657
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/config/SAML2Configuration.java
SAML2Configuration.createSelfSignedCert
private X509Certificate createSelfSignedCert(X500Name dn, String sigName, AlgorithmIdentifier sigAlgID, KeyPair keyPair) throws Exception { final V3TBSCertificateGenerator certGen = new V3TBSCertificateGenerator(); certGen.setSerialNumber(new ASN1Integer(BigInteger.valueOf(1))); certGen.setIssuer(dn); certGen.setSubject(dn); certGen.setStartDate(new Time(new Date(System.currentTimeMillis() - 1000L))); final Calendar c = Calendar.getInstance(); c.setTime(new Date()); c.add(Calendar.YEAR, 1); certGen.setEndDate(new Time(c.getTime())); certGen.setSignature(sigAlgID); certGen.setSubjectPublicKeyInfo(SubjectPublicKeyInfo.getInstance(keyPair.getPublic().getEncoded())); Signature sig = Signature.getInstance(sigName); sig.initSign(keyPair.getPrivate()); sig.update(certGen.generateTBSCertificate().getEncoded(ASN1Encoding.DER)); TBSCertificate tbsCert = certGen.generateTBSCertificate(); ASN1EncodableVector v = new ASN1EncodableVector(); v.add(tbsCert); v.add(sigAlgID); v.add(new DERBitString(sig.sign())); final X509Certificate cert = (X509Certificate) CertificateFactory.getInstance("X.509") .generateCertificate(new ByteArrayInputStream(new DERSequence(v).getEncoded(ASN1Encoding.DER))); // check the certificate - this will confirm the encoded sig algorithm ID is correct. cert.verify(keyPair.getPublic()); return cert; }
java
private X509Certificate createSelfSignedCert(X500Name dn, String sigName, AlgorithmIdentifier sigAlgID, KeyPair keyPair) throws Exception { final V3TBSCertificateGenerator certGen = new V3TBSCertificateGenerator(); certGen.setSerialNumber(new ASN1Integer(BigInteger.valueOf(1))); certGen.setIssuer(dn); certGen.setSubject(dn); certGen.setStartDate(new Time(new Date(System.currentTimeMillis() - 1000L))); final Calendar c = Calendar.getInstance(); c.setTime(new Date()); c.add(Calendar.YEAR, 1); certGen.setEndDate(new Time(c.getTime())); certGen.setSignature(sigAlgID); certGen.setSubjectPublicKeyInfo(SubjectPublicKeyInfo.getInstance(keyPair.getPublic().getEncoded())); Signature sig = Signature.getInstance(sigName); sig.initSign(keyPair.getPrivate()); sig.update(certGen.generateTBSCertificate().getEncoded(ASN1Encoding.DER)); TBSCertificate tbsCert = certGen.generateTBSCertificate(); ASN1EncodableVector v = new ASN1EncodableVector(); v.add(tbsCert); v.add(sigAlgID); v.add(new DERBitString(sig.sign())); final X509Certificate cert = (X509Certificate) CertificateFactory.getInstance("X.509") .generateCertificate(new ByteArrayInputStream(new DERSequence(v).getEncoded(ASN1Encoding.DER))); // check the certificate - this will confirm the encoded sig algorithm ID is correct. cert.verify(keyPair.getPublic()); return cert; }
[ "private", "X509Certificate", "createSelfSignedCert", "(", "X500Name", "dn", ",", "String", "sigName", ",", "AlgorithmIdentifier", "sigAlgID", ",", "KeyPair", "keyPair", ")", "throws", "Exception", "{", "final", "V3TBSCertificateGenerator", "certGen", "=", "new", "V3T...
Generate a self-signed certificate for dn using the provided signature algorithm and key pair. @param dn X.500 name to associate with certificate issuer/subject. @param sigName name of the signature algorithm to use. @param sigAlgID algorithm ID associated with the signature algorithm name. @param keyPair the key pair to associate with the certificate. @return an X509Certificate containing the public key in keyPair. @throws Exception
[ "Generate", "a", "self", "-", "signed", "certificate", "for", "dn", "using", "the", "provided", "signature", "algorithm", "and", "key", "pair", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/config/SAML2Configuration.java#L621-L660
32,658
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/util/JavaSerializationHelper.java
JavaSerializationHelper.serializeToBytes
public byte[] serializeToBytes(final Serializable o) { byte[] bytes = null; try (final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos)) { oos.writeObject(o); oos.flush(); bytes = baos.toByteArray(); } catch (final IOException e) { logger.warn("cannot Java serialize object", e); } return bytes; }
java
public byte[] serializeToBytes(final Serializable o) { byte[] bytes = null; try (final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos)) { oos.writeObject(o); oos.flush(); bytes = baos.toByteArray(); } catch (final IOException e) { logger.warn("cannot Java serialize object", e); } return bytes; }
[ "public", "byte", "[", "]", "serializeToBytes", "(", "final", "Serializable", "o", ")", "{", "byte", "[", "]", "bytes", "=", "null", ";", "try", "(", "final", "ByteArrayOutputStream", "baos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "final", "Ob...
Serialize a Java object into a bytes array. @param o the object to serialize @return the bytes array of the serialized object
[ "Serialize", "a", "Java", "object", "into", "a", "bytes", "array", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/util/JavaSerializationHelper.java#L48-L59
32,659
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/util/JavaSerializationHelper.java
JavaSerializationHelper.deserializeFromBytes
public Serializable deserializeFromBytes(final byte[] bytes) { Serializable o = null; try (final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); final ObjectInputStream ois = new RestrictedObjectInputStream(bais, this.trustedPackages, this.trustedClasses)) { o = (Serializable) ois.readObject(); } catch (final IOException | ClassNotFoundException e) { logger.warn("cannot Java deserialize object", e); } return o; }
java
public Serializable deserializeFromBytes(final byte[] bytes) { Serializable o = null; try (final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); final ObjectInputStream ois = new RestrictedObjectInputStream(bais, this.trustedPackages, this.trustedClasses)) { o = (Serializable) ois.readObject(); } catch (final IOException | ClassNotFoundException e) { logger.warn("cannot Java deserialize object", e); } return o; }
[ "public", "Serializable", "deserializeFromBytes", "(", "final", "byte", "[", "]", "bytes", ")", "{", "Serializable", "o", "=", "null", ";", "try", "(", "final", "ByteArrayInputStream", "bais", "=", "new", "ByteArrayInputStream", "(", "bytes", ")", ";", "final"...
Deserialize a bytes array into a Java object. @param bytes the serialized object as a bytes array @return the deserialized Java object
[ "Deserialize", "a", "bytes", "array", "into", "a", "Java", "object", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/util/JavaSerializationHelper.java#L77-L86
32,660
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java
CommonHelper.addParameter
public static String addParameter(final String url, final String name, final String value) { if (url != null) { final StringBuilder sb = new StringBuilder(); sb.append(url); if (name != null) { if (url.indexOf("?") >= 0) { sb.append("&"); } else { sb.append("?"); } sb.append(name); sb.append("="); if (value != null) { sb.append(urlEncode(value)); } } return sb.toString(); } return null; }
java
public static String addParameter(final String url, final String name, final String value) { if (url != null) { final StringBuilder sb = new StringBuilder(); sb.append(url); if (name != null) { if (url.indexOf("?") >= 0) { sb.append("&"); } else { sb.append("?"); } sb.append(name); sb.append("="); if (value != null) { sb.append(urlEncode(value)); } } return sb.toString(); } return null; }
[ "public", "static", "String", "addParameter", "(", "final", "String", "url", ",", "final", "String", "name", ",", "final", "String", "value", ")", "{", "if", "(", "url", "!=", "null", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", ...
Add a new parameter to an url. @param url url @param name name of the parameter @param value value of the parameter @return the new url with the parameter appended
[ "Add", "a", "new", "parameter", "to", "an", "url", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java#L165-L184
32,661
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java
CommonHelper.urlEncode
public static String urlEncode(final String text) { try { return URLEncoder.encode(text, StandardCharsets.UTF_8.name()); } catch (final UnsupportedEncodingException e) { final String message = "Unable to encode text : " + text; throw new TechnicalException(message, e); } }
java
public static String urlEncode(final String text) { try { return URLEncoder.encode(text, StandardCharsets.UTF_8.name()); } catch (final UnsupportedEncodingException e) { final String message = "Unable to encode text : " + text; throw new TechnicalException(message, e); } }
[ "public", "static", "String", "urlEncode", "(", "final", "String", "text", ")", "{", "try", "{", "return", "URLEncoder", ".", "encode", "(", "text", ",", "StandardCharsets", ".", "UTF_8", ".", "name", "(", ")", ")", ";", "}", "catch", "(", "final", "Un...
URL encode a text using UTF-8. @param text text to encode @return the encoded text
[ "URL", "encode", "a", "text", "using", "UTF", "-", "8", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java#L192-L199
32,662
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java
CommonHelper.toNiceString
public static String toNiceString(final Class<?> clazz, final Object... args) { final StringBuilder sb = new StringBuilder(); sb.append("#"); sb.append(clazz.getSimpleName()); sb.append("# |"); boolean b = true; for (final Object arg : args) { if (b) { sb.append(" "); sb.append(arg); sb.append(":"); } else { sb.append(" "); sb.append(arg); sb.append(" |"); } b = !b; } return sb.toString(); }
java
public static String toNiceString(final Class<?> clazz, final Object... args) { final StringBuilder sb = new StringBuilder(); sb.append("#"); sb.append(clazz.getSimpleName()); sb.append("# |"); boolean b = true; for (final Object arg : args) { if (b) { sb.append(" "); sb.append(arg); sb.append(":"); } else { sb.append(" "); sb.append(arg); sb.append(" |"); } b = !b; } return sb.toString(); }
[ "public", "static", "String", "toNiceString", "(", "final", "Class", "<", "?", ">", "clazz", ",", "final", "Object", "...", "args", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"#\"", ...
Build a "nice toString" for an object. @param clazz class @param args arguments @return a "nice toString" text
[ "Build", "a", "nice", "toString", "for", "an", "object", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java#L208-L227
32,663
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java
CommonHelper.randomString
public static String randomString(final int size) { final StringBuilder builder = new StringBuilder(); while (builder.length() < size) { final String suffix = java.util.UUID.randomUUID().toString().replace("-", ""); builder.append(suffix); } return builder.substring(0, size); }
java
public static String randomString(final int size) { final StringBuilder builder = new StringBuilder(); while (builder.length() < size) { final String suffix = java.util.UUID.randomUUID().toString().replace("-", ""); builder.append(suffix); } return builder.substring(0, size); }
[ "public", "static", "String", "randomString", "(", "final", "int", "size", ")", "{", "final", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "builder", ".", "length", "(", ")", "<", "size", ")", "{", "final", "Strin...
Return a random string of a certain size. @param size the size @return the random size
[ "Return", "a", "random", "string", "of", "a", "certain", "size", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java#L235-L242
32,664
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java
CommonHelper.newDate
public static Date newDate(final Date original) { return original != null ? new Date(original.getTime()) : null; }
java
public static Date newDate(final Date original) { return original != null ? new Date(original.getTime()) : null; }
[ "public", "static", "Date", "newDate", "(", "final", "Date", "original", ")", "{", "return", "original", "!=", "null", "?", "new", "Date", "(", "original", ".", "getTime", "(", ")", ")", ":", "null", ";", "}" ]
Copy a date. @param original original date @return date copy
[ "Copy", "a", "date", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java#L250-L252
32,665
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java
CommonHelper.asURI
public static URI asURI(final String s) { try { return new URI(s); } catch (final URISyntaxException e) { throw new TechnicalException("Cannot make an URI from: " + s, e); } }
java
public static URI asURI(final String s) { try { return new URI(s); } catch (final URISyntaxException e) { throw new TechnicalException("Cannot make an URI from: " + s, e); } }
[ "public", "static", "URI", "asURI", "(", "final", "String", "s", ")", "{", "try", "{", "return", "new", "URI", "(", "s", ")", ";", "}", "catch", "(", "final", "URISyntaxException", "e", ")", "{", "throw", "new", "TechnicalException", "(", "\"Cannot make ...
Convert a string into an URI. @param s the string @return the URI
[ "Convert", "a", "string", "into", "an", "URI", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java#L260-L266
32,666
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java
CommonHelper.getConstructor
public static Constructor getConstructor(final String name) throws ClassNotFoundException, NoSuchMethodException { Constructor constructor = constructorsCache.get(name); if (constructor == null) { synchronized (constructorsCache) { constructor = constructorsCache.get(name); if (constructor == null) { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); if (tccl == null) { constructor = Class.forName(name).getDeclaredConstructor(); } else { constructor = Class.forName(name, true, tccl).getDeclaredConstructor(); } constructorsCache.put(name, constructor); } } } return constructor; }
java
public static Constructor getConstructor(final String name) throws ClassNotFoundException, NoSuchMethodException { Constructor constructor = constructorsCache.get(name); if (constructor == null) { synchronized (constructorsCache) { constructor = constructorsCache.get(name); if (constructor == null) { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); if (tccl == null) { constructor = Class.forName(name).getDeclaredConstructor(); } else { constructor = Class.forName(name, true, tccl).getDeclaredConstructor(); } constructorsCache.put(name, constructor); } } } return constructor; }
[ "public", "static", "Constructor", "getConstructor", "(", "final", "String", "name", ")", "throws", "ClassNotFoundException", ",", "NoSuchMethodException", "{", "Constructor", "constructor", "=", "constructorsCache", ".", "get", "(", "name", ")", ";", "if", "(", "...
Get the constructor of the class. @param name the name of the class @return the constructor @throws ClassNotFoundException class not found @throws NoSuchMethodException method not found
[ "Get", "the", "constructor", "of", "the", "class", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java#L331-L349
32,667
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.build
public void build(final Object id, final Map<String, Object> attributes) { setId(ProfileHelper.sanitizeIdentifier(this, id)); addAttributes(attributes); }
java
public void build(final Object id, final Map<String, Object> attributes) { setId(ProfileHelper.sanitizeIdentifier(this, id)); addAttributes(attributes); }
[ "public", "void", "build", "(", "final", "Object", "id", ",", "final", "Map", "<", "String", ",", "Object", ">", "attributes", ")", "{", "setId", "(", "ProfileHelper", ".", "sanitizeIdentifier", "(", "this", ",", "id", ")", ")", ";", "addAttributes", "("...
Build a profile from user identifier and attributes. @param id user identifier @param attributes user attributes
[ "Build", "a", "profile", "from", "user", "identifier", "and", "attributes", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L66-L69
32,668
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.build
public void build(final Object id, final Map<String, Object> attributes, final Map<String, Object> authenticationAttributes ) { build(id, attributes); addAuthenticationAttributes(authenticationAttributes); }
java
public void build(final Object id, final Map<String, Object> attributes, final Map<String, Object> authenticationAttributes ) { build(id, attributes); addAuthenticationAttributes(authenticationAttributes); }
[ "public", "void", "build", "(", "final", "Object", "id", ",", "final", "Map", "<", "String", ",", "Object", ">", "attributes", ",", "final", "Map", "<", "String", ",", "Object", ">", "authenticationAttributes", ")", "{", "build", "(", "id", ",", "attribu...
Build a profile from user identifier, attributes, and authentication attributes. @param id user identifier @param attributes user attributes @param authenticationAttributes authentication attributes
[ "Build", "a", "profile", "from", "user", "identifier", "attributes", "and", "authentication", "attributes", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L78-L81
32,669
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.addAuthenticationAttributes
public void addAuthenticationAttributes(Map<String, Object> attributeMap) { if (attributeMap != null) { for (final Map.Entry<String, Object> entry : attributeMap.entrySet()) { addAuthenticationAttribute(entry.getKey(), entry.getValue()); } } }
java
public void addAuthenticationAttributes(Map<String, Object> attributeMap) { if (attributeMap != null) { for (final Map.Entry<String, Object> entry : attributeMap.entrySet()) { addAuthenticationAttribute(entry.getKey(), entry.getValue()); } } }
[ "public", "void", "addAuthenticationAttributes", "(", "Map", "<", "String", ",", "Object", ">", "attributeMap", ")", "{", "if", "(", "attributeMap", "!=", "null", ")", "{", "for", "(", "final", "Map", ".", "Entry", "<", "String", ",", "Object", ">", "ent...
Add authentication attributes. @param attributeMap the authentication attributes
[ "Add", "authentication", "attributes", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L188-L194
32,670
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.getAttribute
@Override public Object getAttribute(final String name) { return ProfileHelper.getInternalAttributeHandler().restore(this.attributes.get(name)); }
java
@Override public Object getAttribute(final String name) { return ProfileHelper.getInternalAttributeHandler().restore(this.attributes.get(name)); }
[ "@", "Override", "public", "Object", "getAttribute", "(", "final", "String", "name", ")", "{", "return", "ProfileHelper", ".", "getInternalAttributeHandler", "(", ")", ".", "restore", "(", "this", ".", "attributes", ".", "get", "(", "name", ")", ")", ";", ...
Return the attribute with name. @param name attribute name @return the attribute with name
[ "Return", "the", "attribute", "with", "name", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L249-L252
32,671
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.getAuthenticationAttribute
public Object getAuthenticationAttribute(final String name) { return ProfileHelper.getInternalAttributeHandler().restore(this.authenticationAttributes.get(name)); }
java
public Object getAuthenticationAttribute(final String name) { return ProfileHelper.getInternalAttributeHandler().restore(this.authenticationAttributes.get(name)); }
[ "public", "Object", "getAuthenticationAttribute", "(", "final", "String", "name", ")", "{", "return", "ProfileHelper", ".", "getInternalAttributeHandler", "(", ")", ".", "restore", "(", "this", ".", "authenticationAttributes", ".", "get", "(", "name", ")", ")", ...
Return the authentication attribute with name. @param name authentication attribute name @return the authentication attribute with name
[ "Return", "the", "authentication", "attribute", "with", "name", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L260-L262
32,672
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.containsAttribute
@Override public boolean containsAttribute(final String name) { CommonHelper.assertNotNull("name", name); return this.attributes.containsKey(name); }
java
@Override public boolean containsAttribute(final String name) { CommonHelper.assertNotNull("name", name); return this.attributes.containsKey(name); }
[ "@", "Override", "public", "boolean", "containsAttribute", "(", "final", "String", "name", ")", "{", "CommonHelper", ".", "assertNotNull", "(", "\"name\"", ",", "name", ")", ";", "return", "this", ".", "attributes", ".", "containsKey", "(", "name", ")", ";",...
Check to see if profile contains attribute name. @param name the name @return true/false
[ "Check", "to", "see", "if", "profile", "contains", "attribute", "name", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L270-L274
32,673
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.getAuthenticationAttribute
public <T> T getAuthenticationAttribute(final String name, final Class<T> clazz) { final Object attribute = getAuthenticationAttribute(name); return getAttributeByType(name, clazz, attribute); }
java
public <T> T getAuthenticationAttribute(final String name, final Class<T> clazz) { final Object attribute = getAuthenticationAttribute(name); return getAttributeByType(name, clazz, attribute); }
[ "public", "<", "T", ">", "T", "getAuthenticationAttribute", "(", "final", "String", "name", ",", "final", "Class", "<", "T", ">", "clazz", ")", "{", "final", "Object", "attribute", "=", "getAuthenticationAttribute", "(", "name", ")", ";", "return", "getAttri...
Return authentication attribute with name @param name Name of authentication attribute @param clazz The class of the authentication attribute @param <T> The type of the authentication attribute @return the named attribute
[ "Return", "authentication", "attribute", "with", "name" ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L309-L313
32,674
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.addRole
@Override public void addRole(final String role) { CommonHelper.assertNotBlank("role", role); this.roles.add(role); }
java
@Override public void addRole(final String role) { CommonHelper.assertNotBlank("role", role); this.roles.add(role); }
[ "@", "Override", "public", "void", "addRole", "(", "final", "String", "role", ")", "{", "CommonHelper", ".", "assertNotBlank", "(", "\"role\"", ",", "role", ")", ";", "this", ".", "roles", ".", "add", "(", "role", ")", ";", "}" ]
Add a role. @param role the role to add.
[ "Add", "a", "role", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L335-L339
32,675
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.addRoles
@Override public void addRoles(final Collection<String> roles) { CommonHelper.assertNotNull("roles", roles); this.roles.addAll(roles); }
java
@Override public void addRoles(final Collection<String> roles) { CommonHelper.assertNotNull("roles", roles); this.roles.addAll(roles); }
[ "@", "Override", "public", "void", "addRoles", "(", "final", "Collection", "<", "String", ">", "roles", ")", "{", "CommonHelper", ".", "assertNotNull", "(", "\"roles\"", ",", "roles", ")", ";", "this", ".", "roles", ".", "addAll", "(", "roles", ")", ";",...
Add roles. @param roles the roles to add.
[ "Add", "roles", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L346-L350
32,676
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.addPermission
@Override public void addPermission(final String permission) { CommonHelper.assertNotBlank("permission", permission); this.permissions.add(permission); }
java
@Override public void addPermission(final String permission) { CommonHelper.assertNotBlank("permission", permission); this.permissions.add(permission); }
[ "@", "Override", "public", "void", "addPermission", "(", "final", "String", "permission", ")", "{", "CommonHelper", ".", "assertNotBlank", "(", "\"permission\"", ",", "permission", ")", ";", "this", ".", "permissions", ".", "add", "(", "permission", ")", ";", ...
Add a permission. @param permission the permission to add.
[ "Add", "a", "permission", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L372-L376
32,677
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java
BasicUserProfile.addPermissions
@Override public void addPermissions(final Collection<String> permissions) { CommonHelper.assertNotNull("permissions", permissions); this.permissions.addAll(permissions); }
java
@Override public void addPermissions(final Collection<String> permissions) { CommonHelper.assertNotNull("permissions", permissions); this.permissions.addAll(permissions); }
[ "@", "Override", "public", "void", "addPermissions", "(", "final", "Collection", "<", "String", ">", "permissions", ")", "{", "CommonHelper", ".", "assertNotNull", "(", "\"permissions\"", ",", "permissions", ")", ";", "this", ".", "permissions", ".", "addAll", ...
Add permissions. @param permissions the permissions to add.
[ "Add", "permissions", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/BasicUserProfile.java#L382-L386
32,678
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/engine/decision/DefaultProfileStorageDecision.java
DefaultProfileStorageDecision.mustLoadProfilesFromSession
@Override public boolean mustLoadProfilesFromSession(final C context, final List<Client> currentClients) { return isEmpty(currentClients) || currentClients.get(0) instanceof IndirectClient || currentClients.get(0) instanceof AnonymousClient; }
java
@Override public boolean mustLoadProfilesFromSession(final C context, final List<Client> currentClients) { return isEmpty(currentClients) || currentClients.get(0) instanceof IndirectClient || currentClients.get(0) instanceof AnonymousClient; }
[ "@", "Override", "public", "boolean", "mustLoadProfilesFromSession", "(", "final", "C", "context", ",", "final", "List", "<", "Client", ">", "currentClients", ")", "{", "return", "isEmpty", "(", "currentClients", ")", "||", "currentClients", ".", "get", "(", "...
Load the profiles from the web session if no clients are defined or if the first client is an indirect one or if the first client is the anonymous one. @param context the web context @param currentClients the current clients @return whether the profiles must be loaded from the web session
[ "Load", "the", "profiles", "from", "the", "web", "session", "if", "no", "clients", "are", "defined", "or", "if", "the", "first", "client", "is", "an", "indirect", "one", "or", "if", "the", "first", "client", "is", "the", "anonymous", "one", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/engine/decision/DefaultProfileStorageDecision.java#L30-L34
32,679
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/engine/decision/DefaultProfileStorageDecision.java
DefaultProfileStorageDecision.mustSaveProfileInSession
@Override public boolean mustSaveProfileInSession(final C context, final List<Client> currentClients, final DirectClient directClient, final UserProfile profile) { return false; }
java
@Override public boolean mustSaveProfileInSession(final C context, final List<Client> currentClients, final DirectClient directClient, final UserProfile profile) { return false; }
[ "@", "Override", "public", "boolean", "mustSaveProfileInSession", "(", "final", "C", "context", ",", "final", "List", "<", "Client", ">", "currentClients", ",", "final", "DirectClient", "directClient", ",", "final", "UserProfile", "profile", ")", "{", "return", ...
Never save the profile in session after a direct client authentication. @param context the web context @param currentClients the current clients @param directClient the direct clients @param profile the retrieved profile after login @return <code>false</code>
[ "Never", "save", "the", "profile", "in", "session", "after", "a", "direct", "client", "authentication", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/engine/decision/DefaultProfileStorageDecision.java#L45-L49
32,680
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/client/Clients.java
Clients.updateIndirectClient
protected void updateIndirectClient(final IndirectClient client) { if (this.callbackUrl != null && client.getCallbackUrl() == null) { client.setCallbackUrl(this.callbackUrl); } if (this.urlResolver != null && client.getUrlResolver() == null) { client.setUrlResolver(this.urlResolver); } if (this.callbackUrlResolver != null && client.getCallbackUrlResolver() == null) { client.setCallbackUrlResolver(this.callbackUrlResolver); } if (this.ajaxRequestResolver != null && client.getAjaxRequestResolver() == null) { client.setAjaxRequestResolver(this.ajaxRequestResolver); } }
java
protected void updateIndirectClient(final IndirectClient client) { if (this.callbackUrl != null && client.getCallbackUrl() == null) { client.setCallbackUrl(this.callbackUrl); } if (this.urlResolver != null && client.getUrlResolver() == null) { client.setUrlResolver(this.urlResolver); } if (this.callbackUrlResolver != null && client.getCallbackUrlResolver() == null) { client.setCallbackUrlResolver(this.callbackUrlResolver); } if (this.ajaxRequestResolver != null && client.getAjaxRequestResolver() == null) { client.setAjaxRequestResolver(this.ajaxRequestResolver); } }
[ "protected", "void", "updateIndirectClient", "(", "final", "IndirectClient", "client", ")", "{", "if", "(", "this", ".", "callbackUrl", "!=", "null", "&&", "client", ".", "getCallbackUrl", "(", ")", "==", "null", ")", "{", "client", ".", "setCallbackUrl", "(...
Setup the indirect client. @param client the indirect client
[ "Setup", "the", "indirect", "client", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/client/Clients.java#L102-L115
32,681
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/client/Clients.java
Clients.findClient
public Optional<Client> findClient(final String name) { CommonHelper.assertNotBlank("name", name); init(); final String lowerTrimmedName = name.toLowerCase().trim(); final Client client = _clients.get(lowerTrimmedName); if (client != null) { return Optional.of(client); } LOGGER.debug("No client found for name: {}", name); return Optional.empty(); }
java
public Optional<Client> findClient(final String name) { CommonHelper.assertNotBlank("name", name); init(); final String lowerTrimmedName = name.toLowerCase().trim(); final Client client = _clients.get(lowerTrimmedName); if (client != null) { return Optional.of(client); } LOGGER.debug("No client found for name: {}", name); return Optional.empty(); }
[ "public", "Optional", "<", "Client", ">", "findClient", "(", "final", "String", "name", ")", "{", "CommonHelper", ".", "assertNotBlank", "(", "\"name\"", ",", "name", ")", ";", "init", "(", ")", ";", "final", "String", "lowerTrimmedName", "=", "name", ".",...
Return the right client according to the specific name. @param name name of the client @return the right client
[ "Return", "the", "right", "client", "according", "to", "the", "specific", "name", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/client/Clients.java#L123-L133
32,682
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/client/Clients.java
Clients.findClient
@SuppressWarnings("unchecked") public <C extends Client> Optional<C> findClient(final Class<C> clazz) { CommonHelper.assertNotNull("clazz", clazz); init(); if (clazz != null) { for (final Client client : getClients()) { if (clazz.isAssignableFrom(client.getClass())) { return Optional.of((C) client); } } } LOGGER.debug("No client found for class: {}", clazz); return Optional.empty(); }
java
@SuppressWarnings("unchecked") public <C extends Client> Optional<C> findClient(final Class<C> clazz) { CommonHelper.assertNotNull("clazz", clazz); init(); if (clazz != null) { for (final Client client : getClients()) { if (clazz.isAssignableFrom(client.getClass())) { return Optional.of((C) client); } } } LOGGER.debug("No client found for class: {}", clazz); return Optional.empty(); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "C", "extends", "Client", ">", "Optional", "<", "C", ">", "findClient", "(", "final", "Class", "<", "C", ">", "clazz", ")", "{", "CommonHelper", ".", "assertNotNull", "(", "\"clazz\"", ",",...
Return the right client according to the specific class. @param clazz class of the client @param <C> the kind of client @return the right client
[ "Return", "the", "right", "client", "according", "to", "the", "specific", "class", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/client/Clients.java#L142-L155
32,683
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java
SAML2AuthnResponseValidator.getSessionIndex
protected String getSessionIndex(final Assertion subjectAssertion) { List<AuthnStatement> authnStatements = subjectAssertion.getAuthnStatements(); if (authnStatements != null && authnStatements.size() > 0) { AuthnStatement statement = authnStatements.get(0); if (statement != null) { return statement.getSessionIndex(); } } return null; }
java
protected String getSessionIndex(final Assertion subjectAssertion) { List<AuthnStatement> authnStatements = subjectAssertion.getAuthnStatements(); if (authnStatements != null && authnStatements.size() > 0) { AuthnStatement statement = authnStatements.get(0); if (statement != null) { return statement.getSessionIndex(); } } return null; }
[ "protected", "String", "getSessionIndex", "(", "final", "Assertion", "subjectAssertion", ")", "{", "List", "<", "AuthnStatement", ">", "authnStatements", "=", "subjectAssertion", ".", "getAuthnStatements", "(", ")", ";", "if", "(", "authnStatements", "!=", "null", ...
Searches the sessionIndex in the assertion @param subjectAssertion assertion from the response @return the sessionIndex if found in the assertion
[ "Searches", "the", "sessionIndex", "in", "the", "assertion" ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java#L160-L169
32,684
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java
SAML2AuthnResponseValidator.decryptEncryptedAssertions
protected final void decryptEncryptedAssertions(final Response response, final Decrypter decrypter) { for (final EncryptedAssertion encryptedAssertion : response.getEncryptedAssertions()) { try { final Assertion decryptedAssertion = decrypter.decrypt(encryptedAssertion); response.getAssertions().add(decryptedAssertion); } catch (final DecryptionException e) { logger.error("Decryption of assertion failed, continue with the next one", e); } } }
java
protected final void decryptEncryptedAssertions(final Response response, final Decrypter decrypter) { for (final EncryptedAssertion encryptedAssertion : response.getEncryptedAssertions()) { try { final Assertion decryptedAssertion = decrypter.decrypt(encryptedAssertion); response.getAssertions().add(decryptedAssertion); } catch (final DecryptionException e) { logger.error("Decryption of assertion failed, continue with the next one", e); } } }
[ "protected", "final", "void", "decryptEncryptedAssertions", "(", "final", "Response", "response", ",", "final", "Decrypter", "decrypter", ")", "{", "for", "(", "final", "EncryptedAssertion", "encryptedAssertion", ":", "response", ".", "getEncryptedAssertions", "(", ")...
Decrypt encrypted assertions and add them to the assertions list of the response. @param response the response @param decrypter the decrypter
[ "Decrypt", "encrypted", "assertions", "and", "add", "them", "to", "the", "assertions", "list", "of", "the", "response", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java#L294-L305
32,685
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java
SAML2AuthnResponseValidator.isValidBearerSubjectConfirmationData
protected final boolean isValidBearerSubjectConfirmationData(final SubjectConfirmationData data, final SAML2MessageContext context) { if (data == null) { logger.debug("SubjectConfirmationData cannot be null for Bearer confirmation"); return false; } // TODO Validate inResponseTo if (data.getNotBefore() != null) { logger.debug("SubjectConfirmationData notBefore must be null for Bearer confirmation"); return false; } if (data.getNotOnOrAfter() == null) { logger.debug("SubjectConfirmationData notOnOrAfter cannot be null for Bearer confirmation"); return false; } if (data.getNotOnOrAfter().plusSeconds(acceptedSkew).isBeforeNow()) { logger.debug("SubjectConfirmationData notOnOrAfter is too old"); return false; } try { if (data.getRecipient() == null) { logger.debug("SubjectConfirmationData recipient cannot be null for Bearer confirmation"); return false; } else { final Endpoint endpoint = context.getSAMLEndpointContext().getEndpoint(); if (endpoint == null) { logger.warn("No endpoint was found in the SAML endpoint context"); return false; } final URI recipientUri = new URI(data.getRecipient()); final URI appEndpointUri = new URI(endpoint.getLocation()); if (!SAML2Utils.urisEqualAfterPortNormalization(recipientUri, appEndpointUri)) { logger.debug("SubjectConfirmationData recipient {} does not match SP assertion consumer URL, found. " + "SP ACS URL from context: {}", recipientUri, appEndpointUri); return false; } } } catch (URISyntaxException use) { logger.error("Unable to check SubjectConfirmationData recipient, a URI has invalid syntax.", use); return false; } return true; }
java
protected final boolean isValidBearerSubjectConfirmationData(final SubjectConfirmationData data, final SAML2MessageContext context) { if (data == null) { logger.debug("SubjectConfirmationData cannot be null for Bearer confirmation"); return false; } // TODO Validate inResponseTo if (data.getNotBefore() != null) { logger.debug("SubjectConfirmationData notBefore must be null for Bearer confirmation"); return false; } if (data.getNotOnOrAfter() == null) { logger.debug("SubjectConfirmationData notOnOrAfter cannot be null for Bearer confirmation"); return false; } if (data.getNotOnOrAfter().plusSeconds(acceptedSkew).isBeforeNow()) { logger.debug("SubjectConfirmationData notOnOrAfter is too old"); return false; } try { if (data.getRecipient() == null) { logger.debug("SubjectConfirmationData recipient cannot be null for Bearer confirmation"); return false; } else { final Endpoint endpoint = context.getSAMLEndpointContext().getEndpoint(); if (endpoint == null) { logger.warn("No endpoint was found in the SAML endpoint context"); return false; } final URI recipientUri = new URI(data.getRecipient()); final URI appEndpointUri = new URI(endpoint.getLocation()); if (!SAML2Utils.urisEqualAfterPortNormalization(recipientUri, appEndpointUri)) { logger.debug("SubjectConfirmationData recipient {} does not match SP assertion consumer URL, found. " + "SP ACS URL from context: {}", recipientUri, appEndpointUri); return false; } } } catch (URISyntaxException use) { logger.error("Unable to check SubjectConfirmationData recipient, a URI has invalid syntax.", use); return false; } return true; }
[ "protected", "final", "boolean", "isValidBearerSubjectConfirmationData", "(", "final", "SubjectConfirmationData", "data", ",", "final", "SAML2MessageContext", "context", ")", "{", "if", "(", "data", "==", "null", ")", "{", "logger", ".", "debug", "(", "\"SubjectConf...
Validate Bearer subject confirmation data - notBefore - NotOnOrAfter - recipient @param data the data @param context the context @return true if all Bearer subject checks are passing
[ "Validate", "Bearer", "subject", "confirmation", "data", "-", "notBefore", "-", "NotOnOrAfter", "-", "recipient" ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java#L419-L468
32,686
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java
SAML2AuthnResponseValidator.validateAssertionConditions
protected final void validateAssertionConditions(final Conditions conditions, final SAML2MessageContext context) { if (conditions == null) { return; } if (conditions.getNotBefore() != null && conditions.getNotBefore().minusSeconds(acceptedSkew).isAfterNow()) { throw new SAMLAssertionConditionException("Assertion condition notBefore is not valid"); } if (conditions.getNotOnOrAfter() != null && conditions.getNotOnOrAfter().plusSeconds(acceptedSkew).isBeforeNow()) { throw new SAMLAssertionConditionException("Assertion condition notOnOrAfter is not valid"); } final String entityId = context.getSAMLSelfEntityContext().getEntityId(); validateAudienceRestrictions(conditions.getAudienceRestrictions(), entityId); }
java
protected final void validateAssertionConditions(final Conditions conditions, final SAML2MessageContext context) { if (conditions == null) { return; } if (conditions.getNotBefore() != null && conditions.getNotBefore().minusSeconds(acceptedSkew).isAfterNow()) { throw new SAMLAssertionConditionException("Assertion condition notBefore is not valid"); } if (conditions.getNotOnOrAfter() != null && conditions.getNotOnOrAfter().plusSeconds(acceptedSkew).isBeforeNow()) { throw new SAMLAssertionConditionException("Assertion condition notOnOrAfter is not valid"); } final String entityId = context.getSAMLSelfEntityContext().getEntityId(); validateAudienceRestrictions(conditions.getAudienceRestrictions(), entityId); }
[ "protected", "final", "void", "validateAssertionConditions", "(", "final", "Conditions", "conditions", ",", "final", "SAML2MessageContext", "context", ")", "{", "if", "(", "conditions", "==", "null", ")", "{", "return", ";", "}", "if", "(", "conditions", ".", ...
Validate assertionConditions - notBefore - notOnOrAfter @param conditions the conditions @param context the context
[ "Validate", "assertionConditions", "-", "notBefore", "-", "notOnOrAfter" ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java#L478-L494
32,687
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java
SAML2AuthnResponseValidator.validateAudienceRestrictions
protected final void validateAudienceRestrictions(final List<AudienceRestriction> audienceRestrictions, final String spEntityId) { if (audienceRestrictions == null || audienceRestrictions.isEmpty()) { throw new SAMLAssertionAudienceException("Audience restrictions cannot be null or empty"); } final Set<String> audienceUris = new HashSet<>(); for (final AudienceRestriction audienceRestriction : audienceRestrictions) { if (audienceRestriction.getAudiences() != null) { for (final Audience audience : audienceRestriction.getAudiences()) { audienceUris.add(audience.getAudienceURI()); } } } if (!audienceUris.contains(spEntityId)) { throw new SAMLAssertionAudienceException("Assertion audience " + audienceUris + " does not match SP configuration " + spEntityId); } }
java
protected final void validateAudienceRestrictions(final List<AudienceRestriction> audienceRestrictions, final String spEntityId) { if (audienceRestrictions == null || audienceRestrictions.isEmpty()) { throw new SAMLAssertionAudienceException("Audience restrictions cannot be null or empty"); } final Set<String> audienceUris = new HashSet<>(); for (final AudienceRestriction audienceRestriction : audienceRestrictions) { if (audienceRestriction.getAudiences() != null) { for (final Audience audience : audienceRestriction.getAudiences()) { audienceUris.add(audience.getAudienceURI()); } } } if (!audienceUris.contains(spEntityId)) { throw new SAMLAssertionAudienceException("Assertion audience " + audienceUris + " does not match SP configuration " + spEntityId); } }
[ "protected", "final", "void", "validateAudienceRestrictions", "(", "final", "List", "<", "AudienceRestriction", ">", "audienceRestrictions", ",", "final", "String", "spEntityId", ")", "{", "if", "(", "audienceRestrictions", "==", "null", "||", "audienceRestrictions", ...
Validate audience by matching the SP entityId. @param audienceRestrictions the audience restrictions @param spEntityId the sp entity id
[ "Validate", "audience", "by", "matching", "the", "SP", "entityId", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java#L502-L521
32,688
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java
SAML2AuthnResponseValidator.validateAssertionSignature
protected final void validateAssertionSignature(final Signature signature, final SAML2MessageContext context, final SignatureTrustEngine engine) { final SAMLPeerEntityContext peerContext = context.getSAMLPeerEntityContext(); if (signature != null) { final String entityId = peerContext.getEntityId(); validateSignature(signature, entityId, engine); } else { if (wantsAssertionsSigned(context) && !peerContext.isAuthenticated()) { throw new SAMLSignatureRequiredException("Assertion or response must be signed"); } } }
java
protected final void validateAssertionSignature(final Signature signature, final SAML2MessageContext context, final SignatureTrustEngine engine) { final SAMLPeerEntityContext peerContext = context.getSAMLPeerEntityContext(); if (signature != null) { final String entityId = peerContext.getEntityId(); validateSignature(signature, entityId, engine); } else { if (wantsAssertionsSigned(context) && !peerContext.isAuthenticated()) { throw new SAMLSignatureRequiredException("Assertion or response must be signed"); } } }
[ "protected", "final", "void", "validateAssertionSignature", "(", "final", "Signature", "signature", ",", "final", "SAML2MessageContext", "context", ",", "final", "SignatureTrustEngine", "engine", ")", "{", "final", "SAMLPeerEntityContext", "peerContext", "=", "context", ...
Validate assertion signature. If none is found and the SAML response did not have one and the SP requires the assertions to be signed, the validation fails. @param signature the signature @param context the context @param engine the engine
[ "Validate", "assertion", "signature", ".", "If", "none", "is", "found", "and", "the", "SAML", "response", "did", "not", "have", "one", "and", "the", "SP", "requires", "the", "assertions", "to", "be", "signed", "the", "validation", "fails", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2AuthnResponseValidator.java#L553-L566
32,689
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/store/HttpSessionStore.java
HttpSessionStore.set
@Override public void set(final String messageID, final XMLObject message) { log.debug("Storing message {} to session {}", messageID, context.getSessionStore().getOrCreateSessionId(context)); final LinkedHashMap<String, XMLObject> messages = getMessages(); messages.put(messageID, message); updateSession(messages); }
java
@Override public void set(final String messageID, final XMLObject message) { log.debug("Storing message {} to session {}", messageID, context.getSessionStore().getOrCreateSessionId(context)); final LinkedHashMap<String, XMLObject> messages = getMessages(); messages.put(messageID, message); updateSession(messages); }
[ "@", "Override", "public", "void", "set", "(", "final", "String", "messageID", ",", "final", "XMLObject", "message", ")", "{", "log", ".", "debug", "(", "\"Storing message {} to session {}\"", ",", "messageID", ",", "context", ".", "getSessionStore", "(", ")", ...
Stores a request message into the repository. RequestAbstractType must have an ID set. Any previous message with the same ID will be overwritten. @param messageID ID of message @param message message to be stored
[ "Stores", "a", "request", "message", "into", "the", "repository", ".", "RequestAbstractType", "must", "have", "an", "ID", "set", ".", "Any", "previous", "message", "with", "the", "same", "ID", "will", "be", "overwritten", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/store/HttpSessionStore.java#L65-L71
32,690
pac4j/pac4j
pac4j-saml/src/main/java/org/pac4j/saml/store/HttpSessionStore.java
HttpSessionStore.updateSession
private void updateSession(final LinkedHashMap<String, XMLObject> messages) { context.getSessionStore().set(context, SAML_STORAGE_KEY, messages); }
java
private void updateSession(final LinkedHashMap<String, XMLObject> messages) { context.getSessionStore().set(context, SAML_STORAGE_KEY, messages); }
[ "private", "void", "updateSession", "(", "final", "LinkedHashMap", "<", "String", ",", "XMLObject", ">", "messages", ")", "{", "context", ".", "getSessionStore", "(", ")", ".", "set", "(", "context", ",", "SAML_STORAGE_KEY", ",", "messages", ")", ";", "}" ]
Updates session with the internalMessages key. Some application servers require session value to be updated in order to replicate the session across nodes or persist it correctly.
[ "Updates", "session", "with", "the", "internalMessages", "key", ".", "Some", "application", "servers", "require", "session", "value", "to", "be", "updated", "in", "order", "to", "replicate", "the", "session", "across", "nodes", "or", "persist", "it", "correctly"...
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-saml/src/main/java/org/pac4j/saml/store/HttpSessionStore.java#L141-L143
32,691
pac4j/pac4j
pac4j-cas/src/main/java/org/pac4j/cas/profile/CasProxyProfile.java
CasProxyProfile.getProxyTicketFor
public String getProxyTicketFor(final String service) { if (this.attributePrincipal != null) { logger.debug("Requesting PT from principal: {} and for service: {}", attributePrincipal, service); final String pt = this.attributePrincipal.getProxyTicketFor(service); logger.debug("Get PT: {}", pt); return pt; } return null; }
java
public String getProxyTicketFor(final String service) { if (this.attributePrincipal != null) { logger.debug("Requesting PT from principal: {} and for service: {}", attributePrincipal, service); final String pt = this.attributePrincipal.getProxyTicketFor(service); logger.debug("Get PT: {}", pt); return pt; } return null; }
[ "public", "String", "getProxyTicketFor", "(", "final", "String", "service", ")", "{", "if", "(", "this", ".", "attributePrincipal", "!=", "null", ")", "{", "logger", ".", "debug", "(", "\"Requesting PT from principal: {} and for service: {}\"", ",", "attributePrincipa...
Get a proxy ticket for a given service. @param service the CAS service @return the proxy ticket for the given service
[ "Get", "a", "proxy", "ticket", "for", "a", "given", "service", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-cas/src/main/java/org/pac4j/cas/profile/CasProxyProfile.java#L37-L45
32,692
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/client/BaseClient.java
BaseClient.retrieveCredentials
protected Optional<C> retrieveCredentials(final WebContext context) { try { final Optional<C> optCredentials = this.credentialsExtractor.extract(context); optCredentials.ifPresent(credentials -> { final long t0 = System.currentTimeMillis(); try { this.authenticator.validate(credentials, context); } finally { final long t1 = System.currentTimeMillis(); logger.debug("Credentials validation took: {} ms", t1 - t0); } }); return optCredentials; } catch (CredentialsException e) { logger.info("Failed to retrieve or validate credentials: {}", e.getMessage()); logger.debug("Failed to retrieve or validate credentials", e); return Optional.empty(); } }
java
protected Optional<C> retrieveCredentials(final WebContext context) { try { final Optional<C> optCredentials = this.credentialsExtractor.extract(context); optCredentials.ifPresent(credentials -> { final long t0 = System.currentTimeMillis(); try { this.authenticator.validate(credentials, context); } finally { final long t1 = System.currentTimeMillis(); logger.debug("Credentials validation took: {} ms", t1 - t0); } }); return optCredentials; } catch (CredentialsException e) { logger.info("Failed to retrieve or validate credentials: {}", e.getMessage()); logger.debug("Failed to retrieve or validate credentials", e); return Optional.empty(); } }
[ "protected", "Optional", "<", "C", ">", "retrieveCredentials", "(", "final", "WebContext", "context", ")", "{", "try", "{", "final", "Optional", "<", "C", ">", "optCredentials", "=", "this", ".", "credentialsExtractor", ".", "extract", "(", "context", ")", "...
Retrieve the credentials. @param context the web context @return the credentials
[ "Retrieve", "the", "credentials", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/client/BaseClient.java#L59-L78
32,693
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/client/BaseClient.java
BaseClient.retrieveUserProfile
protected final Optional<UserProfile> retrieveUserProfile(final C credentials, final WebContext context) { final Optional<UserProfile> profile = this.profileCreator.create(credentials, context); logger.debug("profile: {}", profile); return profile; }
java
protected final Optional<UserProfile> retrieveUserProfile(final C credentials, final WebContext context) { final Optional<UserProfile> profile = this.profileCreator.create(credentials, context); logger.debug("profile: {}", profile); return profile; }
[ "protected", "final", "Optional", "<", "UserProfile", ">", "retrieveUserProfile", "(", "final", "C", "credentials", ",", "final", "WebContext", "context", ")", "{", "final", "Optional", "<", "UserProfile", ">", "profile", "=", "this", ".", "profileCreator", ".",...
Retrieve a user profile. @param credentials the credentials @param context the web context @return the user profile
[ "Retrieve", "a", "user", "profile", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/client/BaseClient.java#L107-L111
32,694
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/engine/DefaultSecurityLogic.java
DefaultSecurityLogic.forbidden
protected HttpAction forbidden(final C context, final List<Client> currentClients, final List<UserProfile> profiles, final String authorizers) { return ForbiddenAction.INSTANCE; }
java
protected HttpAction forbidden(final C context, final List<Client> currentClients, final List<UserProfile> profiles, final String authorizers) { return ForbiddenAction.INSTANCE; }
[ "protected", "HttpAction", "forbidden", "(", "final", "C", "context", ",", "final", "List", "<", "Client", ">", "currentClients", ",", "final", "List", "<", "UserProfile", ">", "profiles", ",", "final", "String", "authorizers", ")", "{", "return", "ForbiddenAc...
Return a forbidden error. @param context the web context @param currentClients the current clients @param profiles the current profiles @param authorizers the authorizers @return a forbidden error
[ "Return", "a", "forbidden", "error", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/engine/DefaultSecurityLogic.java#L182-L185
32,695
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/engine/DefaultSecurityLogic.java
DefaultSecurityLogic.startAuthentication
protected boolean startAuthentication(final C context, final List<Client> currentClients) { return isNotEmpty(currentClients) && currentClients.get(0) instanceof IndirectClient; }
java
protected boolean startAuthentication(final C context, final List<Client> currentClients) { return isNotEmpty(currentClients) && currentClients.get(0) instanceof IndirectClient; }
[ "protected", "boolean", "startAuthentication", "(", "final", "C", "context", ",", "final", "List", "<", "Client", ">", "currentClients", ")", "{", "return", "isNotEmpty", "(", "currentClients", ")", "&&", "currentClients", ".", "get", "(", "0", ")", "instanceo...
Return whether we must start a login process if the first client is an indirect one. @param context the web context @param currentClients the current clients @return whether we must start a login process
[ "Return", "whether", "we", "must", "start", "a", "login", "process", "if", "the", "first", "client", "is", "an", "indirect", "one", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/engine/DefaultSecurityLogic.java#L194-L196
32,696
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/engine/DefaultSecurityLogic.java
DefaultSecurityLogic.saveRequestedUrl
protected void saveRequestedUrl(final C context, final List<Client> currentClients, AjaxRequestResolver ajaxRequestResolver) { if (ajaxRequestResolver == null || !ajaxRequestResolver.isAjax(context)) { savedRequestHandler.save(context); } }
java
protected void saveRequestedUrl(final C context, final List<Client> currentClients, AjaxRequestResolver ajaxRequestResolver) { if (ajaxRequestResolver == null || !ajaxRequestResolver.isAjax(context)) { savedRequestHandler.save(context); } }
[ "protected", "void", "saveRequestedUrl", "(", "final", "C", "context", ",", "final", "List", "<", "Client", ">", "currentClients", ",", "AjaxRequestResolver", "ajaxRequestResolver", ")", "{", "if", "(", "ajaxRequestResolver", "==", "null", "||", "!", "ajaxRequestR...
Save the requested url. @param context the web context @param currentClients the current clients
[ "Save", "the", "requested", "url", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/engine/DefaultSecurityLogic.java#L204-L208
32,697
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/engine/DefaultSecurityLogic.java
DefaultSecurityLogic.redirectToIdentityProvider
protected HttpAction redirectToIdentityProvider(final C context, final List<Client> currentClients) { final IndirectClient currentClient = (IndirectClient) currentClients.get(0); return (HttpAction) currentClient.redirect(context).get(); }
java
protected HttpAction redirectToIdentityProvider(final C context, final List<Client> currentClients) { final IndirectClient currentClient = (IndirectClient) currentClients.get(0); return (HttpAction) currentClient.redirect(context).get(); }
[ "protected", "HttpAction", "redirectToIdentityProvider", "(", "final", "C", "context", ",", "final", "List", "<", "Client", ">", "currentClients", ")", "{", "final", "IndirectClient", "currentClient", "=", "(", "IndirectClient", ")", "currentClients", ".", "get", ...
Perform a redirection to start the login process of the first indirect client. @param context the web context @param currentClients the current clients @return the performed redirection
[ "Perform", "a", "redirection", "to", "start", "the", "login", "process", "of", "the", "first", "indirect", "client", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/engine/DefaultSecurityLogic.java#L217-L220
32,698
pac4j/pac4j
pac4j-core/src/main/java/org/pac4j/core/profile/CommonProfile.java
CommonProfile.getGender
public Gender getGender() { final Gender gender = (Gender) getAttribute(CommonProfileDefinition.GENDER); if (gender == null) { return Gender.UNSPECIFIED; } else { return gender; } }
java
public Gender getGender() { final Gender gender = (Gender) getAttribute(CommonProfileDefinition.GENDER); if (gender == null) { return Gender.UNSPECIFIED; } else { return gender; } }
[ "public", "Gender", "getGender", "(", ")", "{", "final", "Gender", "gender", "=", "(", "Gender", ")", "getAttribute", "(", "CommonProfileDefinition", ".", "GENDER", ")", ";", "if", "(", "gender", "==", "null", ")", "{", "return", "Gender", ".", "UNSPECIFIE...
Return the gender of the user. @return the gender of the user
[ "Return", "the", "gender", "of", "the", "user", "." ]
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/profile/CommonProfile.java#L82-L89
32,699
pac4j/pac4j
pac4j-http/src/main/java/org/pac4j/http/client/direct/DirectDigestAuthClient.java
DirectDigestAuthClient.retrieveCredentials
@Override protected Optional<DigestCredentials> retrieveCredentials(final WebContext context) { // set the www-authenticate in case of error final String nonce = calculateNonce(); context.setResponseHeader(HttpConstants.AUTHENTICATE_HEADER, "Digest realm=\"" + realm + "\", qop=\"auth\", nonce=\"" + nonce + "\""); return super.retrieveCredentials(context); }
java
@Override protected Optional<DigestCredentials> retrieveCredentials(final WebContext context) { // set the www-authenticate in case of error final String nonce = calculateNonce(); context.setResponseHeader(HttpConstants.AUTHENTICATE_HEADER, "Digest realm=\"" + realm + "\", qop=\"auth\", nonce=\"" + nonce + "\""); return super.retrieveCredentials(context); }
[ "@", "Override", "protected", "Optional", "<", "DigestCredentials", ">", "retrieveCredentials", "(", "final", "WebContext", "context", ")", "{", "// set the www-authenticate in case of error", "final", "String", "nonce", "=", "calculateNonce", "(", ")", ";", "context", ...
Per RFC 2617 If a server receives a request for an access-protected object, and an acceptable Authorization header is not sent, the server responds with a "401 Unauthorized" status code, and a WWW-Authenticate header
[ "Per", "RFC", "2617", "If", "a", "server", "receives", "a", "request", "for", "an", "access", "-", "protected", "object", "and", "an", "acceptable", "Authorization", "header", "is", "not", "sent", "the", "server", "responds", "with", "a", "401", "Unauthorize...
d9cd029f8783792b31dd48bf1e32f80628f2c4a3
https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-http/src/main/java/org/pac4j/http/client/direct/DirectDigestAuthClient.java#L51-L59