Skip to content

Commit

Permalink
Merge pull request #60 from aiven/issue30-builderclasses
Browse files Browse the repository at this point in the history
Issue30 builderclasses
  • Loading branch information
muralibasani authored Oct 10, 2022
2 parents f78c62c + e7d7469 commit 6670b10
Show file tree
Hide file tree
Showing 154 changed files with 10,263 additions and 3,026 deletions.
7 changes: 5 additions & 2 deletions src/main/java/io/aiven/klaw/auth/KwAuthenticationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ private DirContextOperations searchForUser(DirContext context, String username)
String searchRoot =
this.adRootDn != null ? this.adRootDn : this.searchRootFromPrincipal(bindPrincipal);
String searchFilterUpdated;
if (adFilter != null && !adFilter.equals("")) searchFilterUpdated = adFilter;
else searchFilterUpdated = searchFilter;
if (adFilter != null && !adFilter.equals("")) {
searchFilterUpdated = adFilter;
} else {
searchFilterUpdated = searchFilter;
}

try {
return SpringSecurityLdapTemplate.searchForSingleEntryInternal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ private String validateUrl(String urlFromAddressBar) {
if (urlFromAddressBar != null) {
urlFromAddressBar = urlFromAddressBar.replace(contextPath + "/", "");

if (urlFromAddressBar.contains("login")) urlFromAddressBar = "index";
if (urlFromAddressBar.contains("login")) {
urlFromAddressBar = "index";
}

if (!urlFromAddressBar.contains("loggedin=true")) {
if (urlFromAddressBar.contains("?")) urlFromAddressBar += "&loggedin=true";
else urlFromAddressBar += "?loggedin=true";
if (urlFromAddressBar.contains("?")) {
urlFromAddressBar += "&loggedin=true";
} else {
urlFromAddressBar += "?loggedin=true";
}
}

} else urlFromAddressBar = "";
} else {
urlFromAddressBar = "";
}

return urlFromAddressBar;
}
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/io/aiven/klaw/auth/KwRequestFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.core.Authentication;
Expand All @@ -36,15 +37,15 @@ public class KwRequestFilter extends UsernamePasswordAuthenticationFilter {

@Autowired KwAuthenticationService kwAuthenticationService;

@Autowired private AuthenticationManager authenticationManager;
@Lazy private AuthenticationManager authenticationManager;

@Autowired private KwAuthenticationFailureHandler kwAuthenticationFailureHandler;

@Autowired private KwAuthenticationSuccessHandler kwAuthenticationSuccessHandler;

@Override
@Autowired
public void setAuthenticationManager(AuthenticationManager authenticationManager) {
public void setAuthenticationManager(@Lazy AuthenticationManager authenticationManager) {
super.setAuthenticationManager(authenticationManager);
}

Expand All @@ -56,7 +57,9 @@ public Authentication attemptAuthentication(
if ("saas".equals(kwInstallationType)) {
String gRecaptchaResponse = request.getParameter("g-recaptcha-response");
boolean captchaResponse = validateCaptchaService.validateCaptcha(gRecaptchaResponse);
if (!captchaResponse) throw new AuthenticationServiceException("Invalid Captcha.");
if (!captchaResponse) {
throw new AuthenticationServiceException("Invalid Captcha.");
}
}

if ("ad".equals(authenticationType)) {
Expand All @@ -68,7 +71,9 @@ public Authentication attemptAuthentication(
// User in KW db
return super.attemptAuthentication(request, response);
}
} else return super.attemptAuthentication(request, response);
} else {
return super.attemptAuthentication(request, response);
}
}

@Override
Expand Down
Loading

0 comments on commit 6670b10

Please sign in to comment.