List of usage examples for org.apache.commons.lang3 StringUtils equals
public static boolean equals(final CharSequence cs1, final CharSequence cs2)
Compares two CharSequences, returning true if they represent equal sequences of characters.
null s are handled without exceptions.
From source file:com.chessoft.LoginBean.java
private boolean checkCredentials() { User user;/*from ww w. ja v a2s .com*/ try { user = loginDao.findUser(login); } catch (SQLException | ClassNotFoundException e) { e.printStackTrace(); return false; } if (user == null) { return false; } return StringUtils.equals(password, user.getPassword()); }
From source file:info.magnolia.ui.api.app.launcherlayout.AppLauncherLayout.java
public AppLauncherGroup getGroup(String name) { for (AppLauncherGroup group : getGroups()) { if (StringUtils.equals(group.getName(), name)) { return group; }/*from w w w.j a v a2 s.c om*/ } return null; }
From source file:ch.cyberduck.core.s3.S3EncryptionFeature.java
/** * @param file Default encryption setting for file * @return Return custom key for AWS-KMS if set for bucket in preferences. Otherwise default SSE algorithm. *//*from w ww. j a v a 2s.com*/ @Override public Algorithm getDefault(final Path file) { final String key = String.format("s3.encryption.key.%s", containerService.getContainer(file).getName()); if (StringUtils.isNotBlank(preferences.getProperty(key))) { return Algorithm.fromString(preferences.getProperty(key)); } // Return default setting in preferences final String setting = preferences.getProperty("s3.encryption.algorithm"); if (StringUtils.equals(SSE_AES256.algorithm, setting)) { return SSE_AES256; } return Algorithm.NONE; }
From source file:com.nike.cerberus.auth.connector.okta.OktaMFAAuthConnector.java
@Override public AuthResponse authenticate(String username, String password) { final AuthResult authResult = oktaApiClientHelper.authenticateUser(username, password, null); final String userId = oktaClientResponseUtils.getUserIdFromAuthResult(authResult); final String userLogin = oktaClientResponseUtils.getUserLoginFromAuthResult(authResult); final AuthData authData = new AuthData().setUserId(userId).setUsername(userLogin); final AuthResponse authResponse = new AuthResponse().setData(authData).setStatus(AuthStatus.MFA_REQUIRED); final List<Factor> factors; if (StringUtils.equals(authResult.getStatus(), OktaClientResponseUtils.AUTHENTICATION_MFA_REQUIRED_STATUS) || StringUtils.equals(authResult.getStatus(), OktaClientResponseUtils.AUTHENTICATION_MFA_ENROLL_STATUS)) { factors = oktaClientResponseUtils.getUserFactorsFromAuthResult(authResult); authData.setStateToken(authResult.getStateToken()); } else {/*from w w w . j a va 2s. c o m*/ factors = oktaApiClientHelper.getFactorsByUserId(userId); } oktaClientResponseUtils.validateUserFactors(factors); factors.forEach(factor -> authData.getDevices().add( new AuthMfaDevice().setId(factor.getId()).setName(oktaClientResponseUtils.getDeviceName(factor)))); return authResponse; }
From source file:com.adeptj.runtime.osgi.BridgeServletContextAttributeListener.java
@Override public void attributeReplaced(ServletContextAttributeEvent event) { if (StringUtils.equals(event.getName(), Constants.ATTRIBUTE_BUNDLE_CTX)) { ServiceTrackers.getInstance().closeEventDispatcherTracker(); /*// w ww . jav a2s . c o m * Now open the EventDispatcherTracker with fresh BundleContext which is already hold by * BundleContextHolder after being set in FrameworkLifecycleListener. * * Rationale: If we use the BundleContext contained in the passed event which is a stale * BundleContext in case of a framework restart event and results in a IllegalStateException. */ ServiceTrackers.getInstance() .openEventDispatcherTracker(BundleContextHolder.getInstance().getBundleContext()); } }
From source file:de.micromata.genome.gwiki.plugin.keywordsmarttags_1_0.GWikiFragmentKeywordHtml.java
private void createToolTip(StringBuilder sb, String matched, List<GWikiElementInfo> els) { GWikiContext ctx = GWikiContext.getCurrent(); boolean hasForeignLink = false; StringBuilder ts = new StringBuilder(); ts.append("<ul>"); for (GWikiElementInfo ei : els) { if (StringUtils.equals(ei.getId(), ctx.getCurrentElement().getElementInfo().getId()) == true) { continue; }/* w w w . ja va2 s. c o m*/ if (ctx.getWikiWeb().getAuthorization().isAllowToView(ctx, ei) == false) { continue; } hasForeignLink = true; ts.append("<li>") // .append(WebUtils.escapeHtml(matched)).append(": ") // .append("<a href='").append(ctx.localUrl(ei.getId())).append("'>") .append(ctx.getTranslatedProp(ei.getTitle())).append("</a>").append("</li>"); } ts.append("</ul>"); if (hasForeignLink == false) { sb.append(matched); return; } sb.append("<a class=\"wikiSmartTag\" href='#' onclick='return false;' onmouseover=\"displayHilfeLayer('") .append(WebUtils.escapeJavaScript(ts.toString())).append("', '").append(ctx.genHtmlId("")) .append("')\" onmouseout=\"doNotOpenHilfeLayer();\">") // .append(WebUtils.escapeHtml(matched)).append("</a>"); sb.append(""); }
From source file:com.glaf.base.online.web.springmvc.UserOnlineController.java
@RequestMapping("/doKickOut") @ResponseBody//from w w w . ja v a 2s . co m public void doKickOut(HttpServletRequest request) { LoginContext loginContext = RequestUtils.getLoginContext(request); if (loginContext.isSystemAdministrator()) { String actorId = request.getParameter("actorId"); if (!(StringUtils.equals(actorId, "admin") || StringUtils.equals(actorId, "root"))) { try { userOnlineService.logout(actorId); } catch (Exception ex) { } } } }
From source file:io.adeptj.runtime.osgi.BridgeServletContextAttributeListener.java
@Override public void attributeReplaced(ServletContextAttributeEvent event) { if (StringUtils.equals(event.getName(), ATTRIBUTE_BUNDLE_CTX)) { ServiceTrackers.getInstance().closeEventDispatcherTracker(); /*//from w ww .j a v a2 s .c o m * Now open the EventDispatcherTracker with fresh BundleContext which is already hold by * BundleContextHolder after being set in FrameworkLifecycleListener. * * Rationale: If we use the BundleContext contained in the passed event which is a stale * BundleContext in case of a framework restart event and results in a IllegalStateException. */ ServiceTrackers.getInstance() .openEventDispatcherTracker(BundleContextHolder.getInstance().getBundleContext()); } }
From source file:ca.uhn.fhir.model.primitive.UriDt.java
/** * Compares the given string to the string representation of this URI. In many cases it is preferable to use this * instead of the standard {@link #equals(Object)} method, since that method returns <code>false</code> unless it is * passed an instance of {@link UriDt}/* w w w. j av a 2 s . c om*/ */ public boolean equals(String theString) { return StringUtils.equals(getValueAsString(), theString); }
From source file:aiai.ai.sec.CustomUserDetails.java
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { // strength - 10 // pass - 123 // bcrypt - $2a$10$jaQkP.gqwgenn.xKtjWIbeP4X.LDJx92FKaQ9VfrN2jgdOUTPTMIu ComplexUsername complexUsername = ComplexUsername.getInstance(username); if (complexUsername == null) { throw new UsernameNotFoundException("Username not found"); }/*from ww w .j a v a 2s. c o m*/ if (StringUtils.equals(globals.restUsername, complexUsername.getUsername()) && StringUtils.equals(globals.restToken, complexUsername.getToken())) { Account account = new Account(); // fake Id, I hope it won't make any collision with real accounts // need to think of better solution for virtual accounts account.setId(Integer.MAX_VALUE - 6L); account.setUsername(globals.restUsername); account.setToken(globals.restToken); account.setAccountNonExpired(true); account.setAccountNonLocked(true); account.setCredentialsNonExpired(true); account.setEnabled(true); account.setPassword(globals.restPassword); account.setAuthorities("ROLE_ACCESS_REST"); return account; } if (StringUtils.equals(globals.masterUsername, complexUsername.getUsername()) && StringUtils.equals(globals.masterToken, complexUsername.getToken())) { Account account = new Account(); // fake Id, I hope it won't make any collision with real accounts // need to think of better solution for virtual accounts account.setId(Integer.MAX_VALUE - 5L); account.setUsername(globals.masterUsername); account.setToken(globals.masterToken); account.setAccountNonExpired(true); account.setAccountNonLocked(true); account.setCredentialsNonExpired(true); account.setEnabled(true); account.setPassword(globals.masterPassword); account.setAuthorities("ROLE_ADMIN, ROLE_MANAGER"); /* List<GrantedAuthority> authList = new ArrayList<>(); authList.add(new SimpleGrantedAuthority("ROLE_ADMIN")); authList.add(new SimpleGrantedAuthority("ROLE_MANAGER")); account.setAuthorities(authList); */ return account; } Account account = accountService.findByUsername(complexUsername.getUsername()); if (account == null) { throw new UsernameNotFoundException("Username not found"); } if (!complexUsername.getToken().equals(account.getToken())) { throw new UsernameNotFoundException("Username not found"); } return account; }