_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q170200
SecurityJackson2Modules.createWhitelistedDefaultTyping
test
private static TypeResolverBuilder<? extends TypeResolverBuilder> createWhitelistedDefaultTyping() { TypeResolverBuilder<? extends TypeResolverBuilder> result = new WhitelistTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL); result = result.init(JsonTypeInfo.Id.CLASS, null); result = result.inclusion(Jso...
java
{ "resource": "" }
q170201
AbstractSecurityWebApplicationInitializer.insertSpringSecurityFilterChain
test
private void insertSpringSecurityFilterChain(ServletContext servletContext) { String filterName = DEFAULT_FILTER_NAME; DelegatingFilterProxy springSecurityFilterChain = new DelegatingFilterProxy( filterName); String contextAttribute = getWebApplicationContextAttribute(); if (contextAttribute != null) { s...
java
{ "resource": "" }
q170202
JdbcTokenRepositoryImpl.getTokenForSeries
test
public PersistentRememberMeToken getTokenForSeries(String seriesId) { try { return getJdbcTemplate().queryForObject(tokensBySeriesSql, new RowMapper<PersistentRememberMeToken>() { public PersistentRememberMeToken mapRow(ResultSet rs, int rowNum) throws SQLException { return new Persistent...
java
{ "resource": "" }
q170203
SimpleAttributes2GrantedAuthoritiesMapper.getGrantedAuthorities
test
public List<GrantedAuthority> getGrantedAuthorities(Collection<String> attributes) { List<GrantedAuthority> result = new ArrayList<>(attributes.size()); for (String attribute : attributes) { result.add(getGrantedAuthority(attribute)); } return result; }
java
{ "resource": "" }
q170204
CipherUtils.newCipher
test
public static Cipher newCipher(String algorithm) { try { return Cipher.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("Not a valid encryption algorithm", e); } catch (NoSuchPaddingException e) { throw new IllegalStateException("Should not happen", e)...
java
{ "resource": "" }
q170205
AbstractPreAuthenticatedProcessingFilter.afterPropertiesSet
test
@Override public void afterPropertiesSet() { try { super.afterPropertiesSet(); } catch (ServletException e) { // convert to RuntimeException for passivity on afterPropertiesSet signature throw new RuntimeException(e); } Assert.notNull(authenticationManager, "An AuthenticationManager must be set"); ...
java
{ "resource": "" }
q170206
AbstractPreAuthenticatedProcessingFilter.doFilter
test
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (logger.isDebugEnabled()) { logger.debug("Checking secure context token: " + SecurityContextHolder.getContext().getAuthentication()); } if (requiresAuthentication((HttpS...
java
{ "resource": "" }
q170207
AbstractPreAuthenticatedProcessingFilter.principalChanged
test
protected boolean principalChanged(HttpServletRequest request, Authentication currentAuthentication) { Object principal = getPreAuthenticatedPrincipal(request); if ((principal instanceof String) && currentAuthentication.getName().equals(principal)) { return false; } if (principal != null && principal.equa...
java
{ "resource": "" }
q170208
AbstractPreAuthenticatedProcessingFilter.doAuthenticate
test
private void doAuthenticate(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Authentication authResult; Object principal = getPreAuthenticatedPrincipal(request); Object credentials = getPreAuthenticatedCredentials(request); if (principal == null) { if (logger...
java
{ "resource": "" }
q170209
OnCommittedResponseWrapper.checkContentLength
test
private void checkContentLength(long contentLengthToWrite) { this.contentWritten += contentLengthToWrite; boolean isBodyFullyWritten = this.contentLength > 0 && this.contentWritten >= this.contentLength; int bufferSize = getBufferSize(); boolean requiresFlush = bufferSize > 0 && this.contentWritten >= buffe...
java
{ "resource": "" }
q170210
SimpleAuthorityMapper.mapAuthorities
test
public Set<GrantedAuthority> mapAuthorities( Collection<? extends GrantedAuthority> authorities) { HashSet<GrantedAuthority> mapped = new HashSet<>( authorities.size()); for (GrantedAuthority authority : authorities) { mapped.add(mapAuthority(authority.getAuthority())); } if (defaultAuthority != null...
java
{ "resource": "" }
q170211
AbstractAuthenticationFilterConfigurer.loginProcessingUrl
test
public T loginProcessingUrl(String loginProcessingUrl) { this.loginProcessingUrl = loginProcessingUrl; authFilter .setRequiresAuthenticationRequestMatcher(createLoginProcessingUrlMatcher(loginProcessingUrl)); return getSelf(); }
java
{ "resource": "" }
q170212
AbstractAuthenticationFilterConfigurer.updateAuthenticationDefaults
test
protected final void updateAuthenticationDefaults() { if (loginProcessingUrl == null) { loginProcessingUrl(loginPage); } if (failureHandler == null) { failureUrl(loginPage + "?error"); } final LogoutConfigurer<B> logoutConfigurer = getBuilder().getConfigurer( LogoutConfigurer.class); if (logoutCo...
java
{ "resource": "" }
q170213
AbstractAuthenticationFilterConfigurer.updateAccessDefaults
test
protected final void updateAccessDefaults(B http) { if (permitAll) { PermitAllSupport.permitAll(http, loginPage, loginProcessingUrl, failureUrl); } }
java
{ "resource": "" }
q170214
LdapUserDetailsMapper.mapPassword
test
protected String mapPassword(Object passwordValue) { if (!(passwordValue instanceof String)) { // Assume it's binary passwordValue = new String((byte[]) passwordValue); } return (String) passwordValue; }
java
{ "resource": "" }
q170215
AbstractRememberMeServices.extractRememberMeCookie
test
protected String extractRememberMeCookie(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); if ((cookies == null) || (cookies.length == 0)) { return null; } for (Cookie cookie : cookies) { if (cookieName.equals(cookie.getName())) { return cookie.getValue(); } } return nul...
java
{ "resource": "" }
q170216
AbstractRememberMeServices.encodeCookie
test
protected String encodeCookie(String[] cookieTokens) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < cookieTokens.length; i++) { try { sb.append(URLEncoder.encode(cookieTokens[i], StandardCharsets.UTF_8.toString())); } catch (UnsupportedEncodingException e) { logger.error(e.getM...
java
{ "resource": "" }
q170217
AbstractRememberMeServices.setCookie
test
protected void setCookie(String[] tokens, int maxAge, HttpServletRequest request, HttpServletResponse response) { String cookieValue = encodeCookie(tokens); Cookie cookie = new Cookie(cookieName, cookieValue); cookie.setMaxAge(maxAge); cookie.setPath(getCookiePath(request)); if (cookieDomain != null) { ...
java
{ "resource": "" }
q170218
CurrentSecurityContextArgumentResolver.resolveArgument
test
@Override public Mono<Object> resolveArgument(MethodParameter parameter, BindingContext bindingContext, ServerWebExchange exchange) { ReactiveAdapter adapter = getAdapterRegistry().getAdapter(parameter.getParameterType()); Mono<SecurityContext> reactiveSecurityContext = ReactiveSecurityContextHolder.getContext(...
java
{ "resource": "" }
q170219
DefaultServiceAuthenticationDetails.getQueryString
test
private String getQueryString(final HttpServletRequest request, final Pattern artifactPattern) { final String query = request.getQueryString(); if (query == null) { return null; } final String result = artifactPattern.matcher(query).replaceFirst(""); if (result.length() == 0) { return null; } // ...
java
{ "resource": "" }
q170220
DefaultServiceAuthenticationDetails.getServicePort
test
private static int getServicePort(URL casServiceUrl) { int port = casServiceUrl.getPort(); if (port == -1) { port = casServiceUrl.getDefaultPort(); } return port; }
java
{ "resource": "" }
q170221
SpringSecurityAuthenticationSource.getPrincipal
test
public String getPrincipal() { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); if (authentication == null) { log.warn("No Authentication object set in SecurityContext - returning empty String as Principal"); return ""; } Object principal = authentication.getP...
java
{ "resource": "" }
q170222
SecurityContextLogoutHandler.logout
test
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { Assert.notNull(request, "HttpServletRequest required"); if (invalidateHttpSession) { HttpSession session = request.getSession(false); if (session != null) { logger.debug("Invalidating session: ...
java
{ "resource": "" }
q170223
AbstractJaasAuthenticationProvider.authenticate
test
public Authentication authenticate(Authentication auth) throws AuthenticationException { if (!(auth instanceof UsernamePasswordAuthenticationToken)) { return null; } UsernamePasswordAuthenticationToken request = (UsernamePasswordAuthenticationToken) auth; Set<GrantedAuthority> authorities; try { //...
java
{ "resource": "" }
q170224
DefaultSpringSecurityContextSource.buildProviderUrl
test
private static String buildProviderUrl(List<String> urls, String baseDn) { Assert.notNull(baseDn, "The Base DN for the LDAP server must not be null."); Assert.notEmpty(urls, "At least one LDAP server URL must be provided."); String trimmedBaseDn = baseDn.trim(); StringBuilder providerUrl = new StringBuilder();...
java
{ "resource": "" }
q170225
ActiveDirectoryLdapAuthenticationProvider.setContextEnvironmentProperties
test
public void setContextEnvironmentProperties(Map<String, Object> environment) { Assert.notEmpty(environment, "environment must not be empty"); this.contextEnvironmentProperties = new Hashtable<>(environment); }
java
{ "resource": "" }
q170226
DefaultSavedRequest.getRedirectUrl
test
@Override public String getRedirectUrl() { return UrlUtils.buildFullRequestUrl(scheme, serverName, serverPort, requestURI, queryString); }
java
{ "resource": "" }
q170227
JspAuthorizeTag.doEndTag
test
public int doEndTag() throws JspException { try { if (!authorized && TagLibConfig.isUiSecurityDisabled()) { pageContext.getOut().write(TagLibConfig.getSecuredUiSuffix()); } } catch (IOException e) { throw new JspException(e); } return EVAL_PAGE; }
java
{ "resource": "" }
q170228
UserDetailsManagerConfigurer.initUserDetailsService
test
@Override protected void initUserDetailsService() throws Exception { for (UserDetailsBuilder userBuilder : userBuilders) { getUserDetailsService().createUser(userBuilder.build()); } for (UserDetails userDetails : this.users) { getUserDetailsService().createUser(userDetails); } }
java
{ "resource": "" }
q170229
UserDetailsServiceFactoryBean.getUserDetailsService
test
private UserDetailsService getUserDetailsService() { Map<String, ?> beans = getBeansOfType(CachingUserDetailsService.class); if (beans.size() == 0) { beans = getBeansOfType(UserDetailsService.class); } if (beans.size() == 0) { throw new ApplicationContextException("No UserDetailsService registered."); ...
java
{ "resource": "" }
q170230
DefaultServerOAuth2AuthorizationRequestResolver.addPkceParameters
test
private void addPkceParameters(Map<String, Object> attributes, Map<String, Object> additionalParameters) { String codeVerifier = this.codeVerifierGenerator.generateKey(); attributes.put(PkceParameterNames.CODE_VERIFIER, codeVerifier); try { String codeChallenge = createCodeChallenge(codeVerifier); additiona...
java
{ "resource": "" }
q170231
CasAuthenticationFilter.requiresAuthentication
test
protected boolean requiresAuthentication(final HttpServletRequest request, final HttpServletResponse response) { final boolean serviceTicketRequest = serviceTicketRequest(request, response); final boolean result = serviceTicketRequest || proxyReceptorRequest(request) || (proxyTicketRequest(serviceTicketReque...
java
{ "resource": "" }
q170232
CasAuthenticationFilter.serviceTicketRequest
test
private boolean serviceTicketRequest(final HttpServletRequest request, final HttpServletResponse response) { boolean result = super.requiresAuthentication(request, response); if (logger.isDebugEnabled()) { logger.debug("serviceTicketRequest = " + result); } return result; }
java
{ "resource": "" }
q170233
CasAuthenticationFilter.proxyTicketRequest
test
private boolean proxyTicketRequest(final boolean serviceTicketRequest, final HttpServletRequest request) { if (serviceTicketRequest) { return false; } final boolean result = authenticateAllArtifacts && obtainArtifact(request) != null && !authenticated(); if (logger.isDebugEnabled()) { logger.debug(...
java
{ "resource": "" }
q170234
CasAuthenticationFilter.authenticated
test
private boolean authenticated() { Authentication authentication = SecurityContextHolder.getContext() .getAuthentication(); return authentication != null && authentication.isAuthenticated() && !(authentication instanceof AnonymousAuthenticationToken); }
java
{ "resource": "" }
q170235
CasAuthenticationFilter.proxyReceptorRequest
test
private boolean proxyReceptorRequest(final HttpServletRequest request) { final boolean result = proxyReceptorConfigured() && proxyReceptorMatcher.matches(request); if (logger.isDebugEnabled()) { logger.debug("proxyReceptorRequest = " + result); } return result; }
java
{ "resource": "" }
q170236
DefaultMethodSecurityExpressionHandler.createSecurityExpressionRoot
test
protected MethodSecurityExpressionOperations createSecurityExpressionRoot( Authentication authentication, MethodInvocation invocation) { MethodSecurityExpressionRoot root = new MethodSecurityExpressionRoot( authentication); root.setThis(invocation.getThis()); root.setPermissionEvaluator(getPermissionEvalua...
java
{ "resource": "" }
q170237
ReactiveRemoteJWKSource.getJWKSet
test
private Mono<JWKSet> getJWKSet() { return this.webClient.get() .uri(this.jwkSetURL) .retrieve() .bodyToMono(String.class) .map(this::parse) .doOnNext(jwkSet -> this.cachedJWKSet.set(Mono.just(jwkSet))) .cache(); }
java
{ "resource": "" }
q170238
OpenIDAuthenticationFilter.utf8UrlEncode
test
private String utf8UrlEncode(String value) { try { return URLEncoder.encode(value, "UTF-8"); } catch (UnsupportedEncodingException e) { Error err = new AssertionError( "The Java platform guarantees UTF-8 support, but it seemingly is not present."); err.initCause(e); throw err; } }
java
{ "resource": "" }
q170239
WebSpherePreAuthenticatedWebAuthenticationDetailsSource.getWebSphereGroupsBasedGrantedAuthorities
test
private Collection<? extends GrantedAuthority> getWebSphereGroupsBasedGrantedAuthorities() { List<String> webSphereGroups = wasHelper.getGroupsForCurrentUser(); Collection<? extends GrantedAuthority> userGas = webSphereGroups2GrantedAuthoritiesMapper .getGrantedAuthorities(webSphereGroups); if (logger.isDebug...
java
{ "resource": "" }
q170240
CasAuthenticationProvider.loadUserByAssertion
test
protected UserDetails loadUserByAssertion(final Assertion assertion) { final CasAssertionAuthenticationToken token = new CasAssertionAuthenticationToken( assertion, ""); return this.authenticationUserDetailsService.loadUserDetails(token); }
java
{ "resource": "" }
q170241
WebSpherePreAuthenticatedProcessingFilter.getPreAuthenticatedPrincipal
test
protected Object getPreAuthenticatedPrincipal(HttpServletRequest httpRequest) { Object principal = wasHelper.getCurrentUserName(); if (logger.isDebugEnabled()) { logger.debug("PreAuthenticated WebSphere principal: " + principal); } return principal; }
java
{ "resource": "" }
q170242
EncodingUtils.concatenate
test
public static byte[] concatenate(byte[]... arrays) { int length = 0; for (byte[] array : arrays) { length += array.length; } byte[] newArray = new byte[length]; int destPos = 0; for (byte[] array : arrays) { System.arraycopy(array, 0, newArray, destPos, array.length); destPos += array.length; } ...
java
{ "resource": "" }
q170243
EncodingUtils.subArray
test
public static byte[] subArray(byte[] array, int beginIndex, int endIndex) { int length = endIndex - beginIndex; byte[] subarray = new byte[length]; System.arraycopy(array, beginIndex, subarray, 0, length); return subarray; }
java
{ "resource": "" }
q170244
MapBasedAttributes2GrantedAuthoritiesMapper.getGrantedAuthorities
test
public List<GrantedAuthority> getGrantedAuthorities(Collection<String> attributes) { ArrayList<GrantedAuthority> gaList = new ArrayList<>(); for (String attribute : attributes) { Collection<GrantedAuthority> c = attributes2grantedAuthoritiesMap .get(attribute); if (c != null) { gaList.addAll(c); }...
java
{ "resource": "" }
q170245
MapBasedAttributes2GrantedAuthoritiesMapper.preProcessMap
test
private Map<String, Collection<GrantedAuthority>> preProcessMap(Map<?, ?> orgMap) { Map<String, Collection<GrantedAuthority>> result = new HashMap<String, Collection<GrantedAuthority>>( orgMap.size()); for (Map.Entry<?, ?> entry : orgMap.entrySet()) { Assert.isInstanceOf(String.class, entry.getKey(), "...
java
{ "resource": "" }
q170246
MapBasedAttributes2GrantedAuthoritiesMapper.getGrantedAuthorityCollection
test
private Collection<GrantedAuthority> getGrantedAuthorityCollection(Object value) { Collection<GrantedAuthority> result = new ArrayList<>(); addGrantedAuthorityCollection(result, value); return result; }
java
{ "resource": "" }
q170247
MapBasedAttributes2GrantedAuthoritiesMapper.addGrantedAuthorityCollection
test
private void addGrantedAuthorityCollection(Collection<GrantedAuthority> result, Object value) { if (value == null) { return; } if (value instanceof Collection<?>) { addGrantedAuthorityCollection(result, (Collection<?>) value); } else if (value instanceof Object[]) { addGrantedAuthorityCollection(r...
java
{ "resource": "" }
q170248
J2eePreAuthenticatedProcessingFilter.getPreAuthenticatedPrincipal
test
protected Object getPreAuthenticatedPrincipal(HttpServletRequest httpRequest) { Object principal = httpRequest.getUserPrincipal() == null ? null : httpRequest .getUserPrincipal().getName(); if (logger.isDebugEnabled()) { logger.debug("PreAuthenticated J2EE principal: " + principal); } return principal; ...
java
{ "resource": "" }
q170249
AbstractConfiguredSecurityBuilder.getSharedObject
test
@SuppressWarnings("unchecked") public <C> C getSharedObject(Class<C> sharedType) { return (C) this.sharedObjects.get(sharedType); }
java
{ "resource": "" }
q170250
LoginUrlAuthenticationEntryPoint.buildHttpsRedirectUrlForRequest
test
protected String buildHttpsRedirectUrlForRequest(HttpServletRequest request) throws IOException, ServletException { int serverPort = portResolver.getServerPort(request); Integer httpsPort = portMapper.lookupHttpsPort(Integer.valueOf(serverPort)); if (httpsPort != null) { RedirectUrlBuilder urlBuilder = ne...
java
{ "resource": "" }
q170251
AspectJMethodSecurityInterceptor.invoke
test
public Object invoke(JoinPoint jp, AspectJCallback advisorProceed) { InterceptorStatusToken token = super .beforeInvocation(new MethodInvocationAdapter(jp)); Object result; try { result = advisorProceed.proceedWithObject(); } finally { super.finallyInvocation(token); } return super.afterInvoca...
java
{ "resource": "" }
q170252
UrlAuthorizationConfigurer.hasRole
test
private static String hasRole(String role) { Assert.isTrue( !role.startsWith("ROLE_"), () -> role + " should not start with ROLE_ since ROLE_ is automatically prepended when using hasRole. Consider using hasAuthority or access instead."); return "ROLE_" + role; }
java
{ "resource": "" }
q170253
UrlAuthorizationConfigurer.hasAnyRole
test
private static String[] hasAnyRole(String... roles) { for (int i = 0; i < roles.length; i++) { roles[i] = "ROLE_" + roles[i]; } return roles; }
java
{ "resource": "" }
q170254
PersistentTokenBasedRememberMeServices.processAutoLoginCookie
test
protected UserDetails processAutoLoginCookie(String[] cookieTokens, HttpServletRequest request, HttpServletResponse response) { if (cookieTokens.length != 2) { throw new InvalidCookieException("Cookie token did not contain " + 2 + " tokens, but contained '" + Arrays.asList(cookieTokens) + "'"); } fin...
java
{ "resource": "" }
q170255
PersistentTokenBasedRememberMeServices.onLoginSuccess
test
protected void onLoginSuccess(HttpServletRequest request, HttpServletResponse response, Authentication successfulAuthentication) { String username = successfulAuthentication.getName(); logger.debug("Creating new persistent login for user " + username); PersistentRememberMeToken persistentToken = new Persiste...
java
{ "resource": "" }
q170256
SwitchUserFilter.attemptSwitchUser
test
protected Authentication attemptSwitchUser(HttpServletRequest request) throws AuthenticationException { UsernamePasswordAuthenticationToken targetUserRequest; String username = request.getParameter(this.usernameParameter); if (username == null) { username = ""; } if (this.logger.isDebugEnabled()) { ...
java
{ "resource": "" }
q170257
SwitchUserFilter.attemptExitUser
test
protected Authentication attemptExitUser(HttpServletRequest request) throws AuthenticationCredentialsNotFoundException { // need to check to see if the current user has a SwitchUserGrantedAuthority Authentication current = SecurityContextHolder.getContext().getAuthentication(); if (null == current) { throw...
java
{ "resource": "" }
q170258
SwitchUserFilter.setExitUserUrl
test
public void setExitUserUrl(String exitUserUrl) { Assert.isTrue(UrlUtils.isValidRedirectUrl(exitUserUrl), "exitUserUrl cannot be empty and must be a valid redirect URL"); this.exitUserMatcher = createMatcher(exitUserUrl); }
java
{ "resource": "" }
q170259
IndexController.displayPublicIndex
test
@RequestMapping(value = "/hello.htm", method = RequestMethod.GET) public ModelAndView displayPublicIndex() { Contact rnd = contactManager.getRandomContact(); return new ModelAndView("hello", "contact", rnd); }
java
{ "resource": "" }
q170260
WebSecurityConfiguration.springSecurityFilterChain
test
@Bean(name = AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME) public Filter springSecurityFilterChain() throws Exception { boolean hasConfigurers = webSecurityConfigurers != null && !webSecurityConfigurers.isEmpty(); if (!hasConfigurers) { WebSecurityConfigurerAdapter adapter = objectObjectPos...
java
{ "resource": "" }
q170261
NimbusJwtDecoder.decode
test
@Override public Jwt decode(String token) throws JwtException { JWT jwt = parse(token); if (jwt instanceof SignedJWT) { Jwt createdJwt = createJwt(token, jwt); return validateJwt(createdJwt); } throw new JwtException("Unsupported algorithm of " + jwt.getHeader().getAlgorithm()); }
java
{ "resource": "" }
q170262
AbstractAuthorizeTag.authorizeUsingAccessExpression
test
public boolean authorizeUsingAccessExpression() throws IOException { if (SecurityContextHolder.getContext().getAuthentication() == null) { return false; } SecurityExpressionHandler<FilterInvocation> handler = getExpressionHandler(); Expression accessExpression; try { accessExpression = handler.getExpr...
java
{ "resource": "" }
q170263
AbstractAuthorizeTag.authorizeUsingUrlCheck
test
public boolean authorizeUsingUrlCheck() throws IOException { String contextPath = ((HttpServletRequest) getRequest()).getContextPath(); Authentication currentUser = SecurityContextHolder.getContext() .getAuthentication(); return getPrivilegeEvaluator().isAllowed(contextPath, getUrl(), getMethod(), current...
java
{ "resource": "" }
q170264
JwtGrantedAuthoritiesConverter.convert
test
@Override public Collection<GrantedAuthority> convert(Jwt jwt) { return getScopes(jwt) .stream() .map(authority -> SCOPE_AUTHORITY_PREFIX + authority) .map(SimpleGrantedAuthority::new) .collect(Collectors.toList()); }
java
{ "resource": "" }
q170265
LazyCsrfTokenRepository.generateToken
test
@Override public CsrfToken generateToken(HttpServletRequest request) { return wrap(request, this.delegate.generateToken(request)); }
java
{ "resource": "" }
q170266
AdminPermissionController.displayAdminPage
test
@RequestMapping(value = "/secure/adminPermission.htm", method = RequestMethod.GET) public ModelAndView displayAdminPage(@RequestParam("contactId") int contactId) { Contact contact = contactManager.getById(Long.valueOf(contactId)); Acl acl = aclService.readAclById(new ObjectIdentityImpl(contact)); Map<String, Ob...
java
{ "resource": "" }
q170267
AdminPermissionController.displayAddPermissionPageForContact
test
@RequestMapping(value = "/secure/addPermission.htm", method = RequestMethod.GET) public ModelAndView displayAddPermissionPageForContact( @RequestParam("contactId") long contactId) { Contact contact = contactManager.getById(contactId); AddPermission addPermission = new AddPermission(); addPermission.setContac...
java
{ "resource": "" }
q170268
AdminPermissionController.addPermission
test
@RequestMapping(value = "/secure/addPermission.htm", method = RequestMethod.POST) public String addPermission(AddPermission addPermission, BindingResult result, ModelMap model) { addPermissionValidator.validate(addPermission, result); if (result.hasErrors()) { model.put("recipients", listRecipients()); m...
java
{ "resource": "" }
q170269
AdminPermissionController.deletePermission
test
@RequestMapping(value = "/secure/deletePermission.htm") public ModelAndView deletePermission(@RequestParam("contactId") long contactId, @RequestParam("sid") String sid, @RequestParam("permission") int mask) { Contact contact = contactManager.getById(contactId); Sid sidObject = new PrincipalSid(sid); Permiss...
java
{ "resource": "" }
q170270
SecurityExpressionRoot.getRoleWithDefaultPrefix
test
private static String getRoleWithDefaultPrefix(String defaultRolePrefix, String role) { if (role == null) { return role; } if (defaultRolePrefix == null || defaultRolePrefix.length() == 0) { return role; } if (role.startsWith(defaultRolePrefix)) { return role; } return defaultRolePrefix + role; ...
java
{ "resource": "" }
q170271
UserDetailsResourceFactoryBean.fromString
test
public static UserDetailsResourceFactoryBean fromString(String users) { InMemoryResource resource = new InMemoryResource(users); return fromResource(resource); }
java
{ "resource": "" }
q170272
LdapAuthority.getAttributeValues
test
public List<String> getAttributeValues(String name) { List<String> result = null; if (attributes != null) { result = attributes.get(name); } if (result == null) { result = Collections.emptyList(); } return result; }
java
{ "resource": "" }
q170273
LdapAuthority.getFirstAttributeValue
test
public String getFirstAttributeValue(String name) { List<String> result = getAttributeValues(name); if (result.isEmpty()) { return null; } else { return result.get(0); } }
java
{ "resource": "" }
q170274
Utf8.encode
test
public static byte[] encode(CharSequence string) { try { ByteBuffer bytes = CHARSET.newEncoder().encode(CharBuffer.wrap(string)); byte[] bytesCopy = new byte[bytes.limit()]; System.arraycopy(bytes.array(), 0, bytesCopy, 0, bytes.limit()); return bytesCopy; } catch (CharacterCodingException e) { th...
java
{ "resource": "" }
q170275
Utf8.decode
test
public static String decode(byte[] bytes) { try { return CHARSET.newDecoder().decode(ByteBuffer.wrap(bytes)).toString(); } catch (CharacterCodingException e) { throw new IllegalArgumentException("Decoding failed", e); } }
java
{ "resource": "" }
q170276
AnnotationParameterNameDiscoverer.lookupParameterNames
test
private <T extends AccessibleObject> String[] lookupParameterNames( ParameterNameFactory<T> parameterNameFactory, T t) { Annotation[][] parameterAnnotations = parameterNameFactory.findParameterAnnotations(t); int parameterCount = parameterAnnotations.length; String[] paramNames = new String[parameterCount]; ...
java
{ "resource": "" }
q170277
AddDeleteContactController.addContact
test
@RequestMapping(value = "/secure/add.htm", method = RequestMethod.POST) public String addContact(WebContact form, BindingResult result) { validator.validate(form, result); if (result.hasErrors()) { return "add"; } Contact contact = new Contact(form.getName(), form.getEmail()); contactManager.create(cont...
java
{ "resource": "" }
q170278
MapBasedMethodSecurityMetadataSource.findAttributes
test
@Override protected Collection<ConfigAttribute> findAttributes(Method method, Class<?> targetClass) { if (targetClass == null) { return null; } return findAttributesSpecifiedAgainst(method, targetClass); }
java
{ "resource": "" }
q170279
MapBasedMethodSecurityMetadataSource.addSecureMethod
test
private void addSecureMethod(RegisteredMethod method, List<ConfigAttribute> attr) { Assert.notNull(method, "RegisteredMethod required"); Assert.notNull(attr, "Configuration attribute required"); if (logger.isInfoEnabled()) { logger.info("Adding secure method [" + method + "] with attributes [" + attr + "]...
java
{ "resource": "" }
q170280
MapBasedMethodSecurityMetadataSource.getAllConfigAttributes
test
@Override public Collection<ConfigAttribute> getAllConfigAttributes() { Set<ConfigAttribute> allAttributes = new HashSet<>(); for (List<ConfigAttribute> attributeList : methodMap.values()) { allAttributes.addAll(attributeList); } return allAttributes; }
java
{ "resource": "" }
q170281
MapBasedMethodSecurityMetadataSource.isMatch
test
private boolean isMatch(String methodName, String mappedName) { return (mappedName.endsWith("*") && methodName.startsWith(mappedName.substring(0, mappedName.length() - 1))) || (mappedName.startsWith("*") && methodName.endsWith(mappedName .substring(1, mappedName.length()))); }
java
{ "resource": "" }
q170282
AbstractRequestMatcherRegistry.anyRequest
test
public C anyRequest() { Assert.state(!this.anyRequestConfigured, "Can't configure anyRequest after itself"); C configurer = requestMatchers(ANY_REQUEST); this.anyRequestConfigured = true; return configurer; }
java
{ "resource": "" }
q170283
BindAuthenticator.handleBindException
test
protected void handleBindException(String userDn, String username, Throwable cause) { if (logger.isDebugEnabled()) { logger.debug("Failed to bind as " + userDn + ": " + cause); } }
java
{ "resource": "" }
q170284
ContactManagerBackend.getRandomContact
test
@Transactional(readOnly = true) public Contact getRandomContact() { logger.debug("Returning random contact"); Random rnd = new Random(); List<Contact> contacts = contactDao.findAll(); int getNumber = rnd.nextInt(contacts.size()); return contacts.get(getNumber); }
java
{ "resource": "" }
q170285
SimpleUrlAuthenticationSuccessHandler.clearAuthenticationAttributes
test
protected final void clearAuthenticationAttributes(HttpServletRequest request) { HttpSession session = request.getSession(false); if (session == null) { return; } session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); }
java
{ "resource": "" }
q170286
FieldUtils.getField
test
public static Field getField(Class<?> clazz, String fieldName) throws IllegalStateException { Assert.notNull(clazz, "Class required"); Assert.hasText(fieldName, "Field name required"); try { return clazz.getDeclaredField(fieldName); } catch (NoSuchFieldException nsf) { // Try superclass if (clazz...
java
{ "resource": "" }
q170287
CasAuthenticationEntryPoint.createServiceUrl
test
protected String createServiceUrl(final HttpServletRequest request, final HttpServletResponse response) { return CommonUtils.constructServiceUrl(null, response, this.serviceProperties.getService(), null, this.serviceProperties.getArtifactParameter(), this.encodeServiceUrlWithSessionId); }
java
{ "resource": "" }
q170288
CasAuthenticationEntryPoint.createRedirectUrl
test
protected String createRedirectUrl(final String serviceUrl) { return CommonUtils.constructRedirectUrl(this.loginUrl, this.serviceProperties.getServiceParameter(), serviceUrl, this.serviceProperties.isSendRenew(), false); }
java
{ "resource": "" }
q170289
LdapShaPasswordEncoder.extractPrefix
test
private String extractPrefix(String encPass) { if (!encPass.startsWith("{")) { return null; } int secondBrace = encPass.lastIndexOf('}'); if (secondBrace < 0) { throw new IllegalArgumentException( "Couldn't find closing brace for SHA prefix"); } return encPass.substring(0, secondBrace + 1); }
java
{ "resource": "" }
q170290
Http403ForbiddenEntryPoint.commence
test
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException arg2) throws IOException, ServletException { if (logger.isDebugEnabled()) { logger.debug("Pre-authenticated entry point called. Rejecting access"); } response.sendError(HttpServletResponse.SC_FORBIDDEN, "A...
java
{ "resource": "" }
q170291
DefaultFilterChainValidator.checkFilterStack
test
private void checkFilterStack(List<Filter> filters) { checkForDuplicates(SecurityContextPersistenceFilter.class, filters); checkForDuplicates(UsernamePasswordAuthenticationFilter.class, filters); checkForDuplicates(SessionManagementFilter.class, filters); checkForDuplicates(BasicAuthenticationFilter.class, filt...
java
{ "resource": "" }
q170292
ThrowableAnalyzer.getRegisteredTypes
test
@SuppressWarnings("unchecked") final Class<? extends Throwable>[] getRegisteredTypes() { Set<Class<? extends Throwable>> typeList = this.extractorMap.keySet(); return typeList.toArray(new Class[typeList.size()]); }
java
{ "resource": "" }
q170293
ThrowableAnalyzer.extractCause
test
private Throwable extractCause(Throwable throwable) { for (Map.Entry<Class<? extends Throwable>, ThrowableCauseExtractor> entry : extractorMap .entrySet()) { Class<? extends Throwable> throwableType = entry.getKey(); if (throwableType.isInstance(throwable)) { ThrowableCauseExtractor extractor = entry.ge...
java
{ "resource": "" }
q170294
GlobalMethodSecurityBeanDefinitionParser.registerAccessManager
test
@SuppressWarnings({ "unchecked", "rawtypes" }) private String registerAccessManager(ParserContext pc, boolean jsr250Enabled, BeanDefinition expressionVoter) { BeanDefinitionBuilder accessMgrBuilder = BeanDefinitionBuilder .rootBeanDefinition(AffirmativeBased.class); ManagedList voters = new ManagedList(4);...
java
{ "resource": "" }
q170295
AuthorityUtils.authorityListToSet
test
public static Set<String> authorityListToSet( Collection<? extends GrantedAuthority> userAuthorities) { Assert.notNull(userAuthorities, "userAuthorities cannot be null"); Set<String> set = new HashSet<>(userAuthorities.size()); for (GrantedAuthority authority : userAuthorities) { set.add(authority.getAutho...
java
{ "resource": "" }
q170296
StandardPasswordEncoder.matches
test
private boolean matches(byte[] expected, byte[] actual) { if (expected.length != actual.length) { return false; } int result = 0; for (int i = 0; i < expected.length; i++) { result |= expected[i] ^ actual[i]; } return result == 0; }
java
{ "resource": "" }
q170297
SimpleUrlAuthenticationFailureHandler.setDefaultFailureUrl
test
public void setDefaultFailureUrl(String defaultFailureUrl) { Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl), () -> "'" + defaultFailureUrl + "' is not a valid redirect URL"); this.defaultFailureUrl = defaultFailureUrl; }
java
{ "resource": "" }
q170298
DefaultLogoutPageGeneratingFilter.setResolveHiddenInputs
test
public void setResolveHiddenInputs( Function<HttpServletRequest, Map<String, String>> resolveHiddenInputs) { Assert.notNull(resolveHiddenInputs, "resolveHiddenInputs cannot be null"); this.resolveHiddenInputs = resolveHiddenInputs; }
java
{ "resource": "" }
q170299
UrlUtils.buildRequestUrl
test
private static String buildRequestUrl(String servletPath, String requestURI, String contextPath, String pathInfo, String queryString) { StringBuilder url = new StringBuilder(); if (servletPath != null) { url.append(servletPath); if (pathInfo != null) { url.append(pathInfo); } } else { url.a...
java
{ "resource": "" }