Java Code Examples for org.apache.commons.codec.binary.StringUtils#equals()
The following examples show how to use
org.apache.commons.codec.binary.StringUtils#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SonosLinkSecurityInterceptor.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@Override public void check(DecodedJWT jwt) throws InsufficientAuthenticationException { AuthenticationType authenticationType = AuthenticationType.valueOf(settingsService.getSonosLinkMethod()); // no need for extra checks because there isn't a link code if (authenticationType == AuthenticationType.ANONYMOUS) { return; } String linkcode = jwt.getClaim(CLAIM_LINKCODE).asString(); SonosLink sonosLink = sonosLinkDao.findByLinkcode(linkcode); if (!StringUtils.equals(jwt.getSubject(), sonosLink.getUsername()) || !StringUtils.equals(linkcode, sonosLink.getLinkcode()) || !StringUtils.equals(jwt.getClaim(CLAIM_HOUSEHOLDID).asString(), sonosLink.getHouseholdId())) { throw new InsufficientAuthenticationException("Sonos creds not valid"); } }
Example 2
Source File: ActionDelete.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception { try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { ActionResult<Wo> result = new ActionResult<>(); Business business = new Business(emc); if (!business.editable(effectivePerson)) { throw new ExceptionAccessDenied(effectivePerson); } Component component = emc.flag(flag, Component.class); if (null == component) { throw new ExceptionEntityNotExist(flag, Component.class); } if (StringUtils.equals(component.getType(),Component.TYPE_SYSTEM)) { throw new ExceptionDeleteSystemComponent(); } emc.beginTransaction(Component.class); emc.remove(component, CheckRemoveType.all); emc.commit(); Wo wo = new Wo(); wo.setValue(true); result.setData(wo); ApplicationCache.notify(Component.class); return result; } }
Example 3
Source File: GoogleAuthenticatorUtils.java From google-authenticator-integration with MIT License | 6 votes |
/** * 校验方法 * * @param secretKey 密钥 * @param totpCode TOTP 一次性密码 * @return 验证结果 */ public static boolean verification(String secretKey, String totpCode) { long time = System.currentTimeMillis() / 1000 / 30; // 优先计算当前时间,然后再计算偏移量,因为大部分情况下客户端与服务的时间一致 if (StringUtils.equals(totpCode, generateTOTP(secretKey, time))) { return true; } for (int i = -TIME_OFFSET; i <= TIME_OFFSET; i++) { // i == 0 的情况已经算过 if (i != 0) { if (StringUtils.equals(totpCode, generateTOTP(secretKey, time + i))) { return true; } } } return false; }
Example 4
Source File: BlockCheckService.java From WeBASE-Collect-Bee with Apache License 2.0 | 5 votes |
public void checkForks(long currentBlockHeight) throws IOException { log.info("current block height is {}, and begin to check forks", currentBlockHeight); List<BlockTaskPool> uncertainBlocks = blockTaskPoolRepository.findByCertainty((short) BlockCertaintyEnum.UNCERTAIN.getCertainty()); for (BlockTaskPool pool : uncertainBlocks) { if (pool.getBlockHeight() <= currentBlockHeight - BlockConstants.MAX_FORK_CERTAINTY_BLOCK_NUMBER) { if (pool.getSyncStatus() == TxInfoStatusEnum.DOING.getStatus()) { log.error("block {} is doing!", pool.getBlockHeight()); continue; } if (pool.getSyncStatus() == TxInfoStatusEnum.INIT.getStatus()) { log.error("block {} is not sync!", pool.getBlockHeight()); blockTaskPoolRepository.setCertaintyByBlockHeight((short) BlockCertaintyEnum.FIXED.getCertainty(), pool.getBlockHeight()); continue; } Block block = ethClient.getBlock(BigInteger.valueOf(pool.getBlockHeight())); String newHash = block.getHash(); if (!StringUtils.equals(newHash, blockDetailInfoDAO.getBlockDetailInfoByBlockHeight(pool.getBlockHeight()).getBlockHash())) { log.info("Block {} is forked!!! ready to resync", pool.getBlockHeight()); rollBackService.rollback(pool.getBlockHeight(), pool.getBlockHeight() + 1); blockTaskPoolRepository.setSyncStatusAndCertaintyByBlockHeight( (short) TxInfoStatusEnum.INIT.getStatus(), (short) BlockCertaintyEnum.FIXED.getCertainty(), pool.getBlockHeight()); } else { log.info("Block {} is not forked!", pool.getBlockHeight()); blockTaskPoolRepository.setCertaintyByBlockHeight((short) BlockCertaintyEnum.FIXED.getCertainty(), pool.getBlockHeight()); } } } }
Example 5
Source File: RoleREST.java From ranger with Apache License 2.0 | 5 votes |
private boolean containsInvalidMember(List<RangerRole.RoleMember> users) { boolean ret = false; for (RangerRole.RoleMember user : users) { for (String invalidUser : INVALID_USERS) { if (StringUtils.equals(user.getName(), invalidUser)) { ret = true; break; } } if (ret) { break; } } return ret; }
Example 6
Source File: Node.java From nano-framework with Apache License 2.0 | 5 votes |
public void setLivetime(final Long livetime) { if (StringUtils.equals(String.valueOf(this.livetime), String.valueOf(livetime))) { return; } this.livetime = livetime; kvClient.putValue(config.getClusterId() + "/Node/" + id + "/livetime", String.valueOf(livetime)); }
Example 7
Source File: Node.java From nano-framework with Apache License 2.0 | 5 votes |
public void setUptime(final Long uptime) { if (StringUtils.equals(String.valueOf(this.uptime), String.valueOf(uptime))) { return; } this.uptime = uptime; kvClient.putValue(config.getClusterId() + "/Node/" + id + "/uptime", String.valueOf(uptime)); }
Example 8
Source File: Node.java From nano-framework with Apache License 2.0 | 5 votes |
public void setHost(final String host) { if (StringUtils.equals(this.host, host)) { return; } this.host = host; kvClient.putValue(config.getClusterId() + "/Node/" + id + "/host", host); }
Example 9
Source File: Node.java From nano-framework with Apache License 2.0 | 5 votes |
public void setId(final String id) { if (StringUtils.equals(this.id, id)) { return; } this.id = id; kvClient.putValue(config.getClusterId() + "/Node/" + id + '/'); }
Example 10
Source File: DocumentUploadDescriptor.java From TranskribusCore with GNU General Public License v3.0 | 5 votes |
@Override public boolean equals(Object obj) { if(!(obj instanceof PageUploadDescriptor)) { logger.debug("Type is different"); return false; } PageUploadDescriptor p = (PageUploadDescriptor)obj; if(!StringUtils.equals(this.fileName, p.getFileName())){ logger.debug("IMG filename is different"); return false; } if(!StringUtils.equals(this.pageXmlName, p.getPageXmlName())){ logger.debug("XML filename is different"); return false; } if(this.pageNr != p.getPageNr()) { return false; } if(!StringUtils.equals(this.imgChecksum, p.getImgChecksum())){ logger.debug("IMG checksum is different"); return false; } if(!StringUtils.equals(this.pageXmlChecksum, p.getPageXmlChecksum())){ logger.debug("XML checksum is different"); return false; } return true; }
Example 11
Source File: DriveMoveFeature.java From cyberduck with GNU General Public License v3.0 | 5 votes |
@Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { try { if(status.isExists()) { delete.delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } final String id = fileid.getFileid(file, new DisabledListProgressListener()); if(!StringUtils.equals(file.getName(), renamed.getName())) { // Rename title final File properties = new File(); properties.setName(renamed.getName()); properties.setMimeType(status.getMime()); session.getClient().files().update(id, properties). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } // Retrieve the existing parents to remove final StringBuilder previousParents = new StringBuilder(); final File reference = session.getClient().files().get(id) .setFields("parents") .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")) .execute(); for(String parent : reference.getParents()) { previousParents.append(parent); previousParents.append(','); } // Move the file to the new folder session.getClient().files().update(id, null) .setAddParents(fileid.getFileid(renamed.getParent(), new DisabledListProgressListener())) .setRemoveParents(previousParents.toString()) .setFields("id, parents") .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")) .execute(); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new DriveAttributesFinderFeature(session, fileid).find(renamed)); } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot rename {0}", e, file); } }
Example 12
Source File: FabricManager.java From fabric-net-server with Apache License 2.0 | 5 votes |
public void setUser(String leagueName, String orgName, String peerName, String username, String skPath, String certificatePath) throws InvalidArgumentException { if (StringUtils.equals(username, org.getUsername())) { return; } User user = org.getUser(username); if (null == user) { IntermediateUser intermediateUser = new IntermediateUser(leagueName, orgName, peerName, username, skPath, certificatePath); org.setUsername(username); org.addUser(leagueName, orgName, peerName, intermediateUser, org.getFabricStore()); } org.getClient().setUserContext(org.getUser(username)); }
Example 13
Source File: CustomAuthenticationSuccessHandler.java From fast-family-master with Apache License 2.0 | 5 votes |
@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { String header = request.getHeader("Authorization"); if (header == null || !header.startsWith("Basic ")) { throw new UnapprovedClientAuthenticationException("请求头中无client信息"); } String[] tokens = this.extractAndDecodeHeader(header, request); if (tokens.length != 2) { throw new BadCredentialsException("Invalid basic authentication token"); } String clientId = tokens[0]; String clientSecret = tokens[1]; ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientId); if (clientDetails == null) { throw new UnapprovedClientAuthenticationException("clientId 对应的配置信息不存在" + clientId); } else if (!StringUtils.equals(clientDetails.getClientSecret(), clientSecret)) { throw new UnapprovedClientAuthenticationException("clientSecret 不匹配" + clientId); } TokenRequest tokenRequest = new TokenRequest(new HashMap<>(), clientId, clientDetails.getScope(), "custom"); OAuth2Request oAuth2Request = tokenRequest.createOAuth2Request(clientDetails); OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(oAuth2Request, authentication); OAuth2AccessToken token = authorizationServerTokenServices.createAccessToken(oAuth2Authentication); //此处可自定义扩展返回结果。 extendAuthenticationSuccessHandler.customAuthenticationSuccessResult(response, token, authentication); }
Example 14
Source File: SpectraBulkService.java From cyberduck with GNU General Public License v3.0 | 4 votes |
private List<TransferStatus> query(final Path file, final TransferStatus status, final String job, final MasterObjectList master) throws BackgroundException { final List<TransferStatus> chunks = new ArrayList<>(); int counter = 0; for(Objects objects : master.getObjects()) { final UUID nodeId = objects.getNodeId(); if(null == nodeId) { log.warn(String.format("No node returned in master object list for file %s", file)); } else { if(log.isInfoEnabled()) { log.info(String.format("Determined node %s for %s", nodeId, file)); } } for(JobNode node : master.getNodes()) { if(node.getId().equals(nodeId)) { final Host host = session.getHost(); // The IP address or DNS name of the BlackPearl node. if(StringUtils.equals(node.getEndPoint(), host.getHostname())) { break; } if(StringUtils.equals(node.getEndPoint(), new Resolver().resolve(host.getHostname(), new DisabledCancelCallback()).getHostAddress())) { break; } log.warn(String.format("Redirect to %s for file %s", node.getEndPoint(), file)); } } if(log.isInfoEnabled()) { log.info(String.format("Object list with %d objects for job %s", objects.getObjects().size(), job)); } for(BulkObject object : objects.getObjects()) { if(log.isDebugEnabled()) { log.debug(String.format("Found object %s looking for %s", object, file)); } if(object.getName().equals(containerService.getKey(file))) { if(log.isInfoEnabled()) { log.info(String.format("Found chunk %s matching file %s", object, file)); } final TransferStatus chunk = new TransferStatus() .exists(status.isExists()) .withMetadata(status.getMetadata()) .withParameters(status.getParameters()); // Server sends multiple chunks with offsets if(object.getOffset() > 0L) { chunk.setAppend(true); } chunk.setLength(object.getLength()); chunk.setOffset(object.getOffset()); // Job parameter already present from #pre final Map<String, String> parameters = new HashMap<>(chunk.getParameters()); // Set offset for chunk. parameters.put(REQUEST_PARAMETER_OFFSET, Long.toString(chunk.getOffset())); chunk.setParameters(parameters); if(log.isInfoEnabled()) { log.info(String.format("Add chunk %s for file %s", chunk, file)); } chunks.add(chunk); counter++; } } } if(counter < status.getPart()) { // Still missing chunks return Collections.emptyList(); } return chunks; }
Example 15
Source File: PendingClearOperation.java From arcusplatform with Apache License 2.0 | 4 votes |
@Override protected boolean eventTypeMatches(String eventType) { return StringUtils.equals(eventType, IrrigationSchedulableCapability.ScheduleClearedEvent.NAME) || StringUtils.equals(eventType, IrrigationSchedulableCapability.ScheduleClearFailedEvent.NAME); }
Example 16
Source File: PendingSetOperation.java From arcusplatform with Apache License 2.0 | 4 votes |
@Override protected boolean eventTypeMatches(String eventType) { return StringUtils.equals(eventType, IrrigationSchedulableCapability.ScheduleAppliedEvent.NAME) || StringUtils.equals(eventType, IrrigationSchedulableCapability.ScheduleFailedEvent.NAME); }
Example 17
Source File: IntervalSchedule.java From arcusplatform with Apache License 2.0 | 4 votes |
@Override protected boolean eventTypeMatches(String eventType) { return StringUtils.equals(eventType, IrrigationSchedulableCapability.SetIntervalStartSucceededEvent.NAME) || StringUtils.equals(eventType, IrrigationSchedulableCapability.SetIntervalStartFailedEvent.NAME); }
Example 18
Source File: LdapConfigurationNamePredicate.java From oxTrust with MIT License | 4 votes |
@Override public boolean apply(GluuLdapConfiguration ldapConfiguration) { return StringUtils.equals(ldapConfiguration.getConfigId(), name); }
Example 19
Source File: DoubleMetaphone.java From pivaa with GNU General Public License v3.0 | 2 votes |
/** * Check if the Double Metaphone values of two <code>String</code> values * are equal, optionally using the alternate value. * * @param value1 The left-hand side of the encoded {@link String#equals(Object)}. * @param value2 The right-hand side of the encoded {@link String#equals(Object)}. * @param alternate use the alternate value if <code>true</code>. * @return <code>true</code> if the encoded <code>String</code>s are equal; * <code>false</code> otherwise. */ public boolean isDoubleMetaphoneEqual(final String value1, final String value2, final boolean alternate) { return StringUtils.equals(doubleMetaphone(value1, alternate), doubleMetaphone(value2, alternate)); }
Example 20
Source File: DoubleMetaphone.java From text_converter with GNU General Public License v3.0 | 2 votes |
/** * Check if the Double Metaphone values of two <code>String</code> values * are equal, optionally using the alternate value. * * @param value1 The left-hand side of the encoded {@link String#equals(Object)}. * @param value2 The right-hand side of the encoded {@link String#equals(Object)}. * @param alternate use the alternate value if <code>true</code>. * @return <code>true</code> if the encoded <code>String</code>s are equal; * <code>false</code> otherwise. */ public boolean isDoubleMetaphoneEqual(final String value1, final String value2, final boolean alternate) { return StringUtils.equals(doubleMetaphone(value1, alternate), doubleMetaphone(value2, alternate)); }