List of usage examples for org.apache.commons.codec.digest DigestUtils sha256Hex
public static String sha256Hex(String data)
From source file:io.java.back.business.ChamadoData.java
public Chamado testaCriaModela(int i) { Usuario usuario = new Usuario(); usuario.setAtivo(true);/*from w w w . j av a 2 s . c o m*/ //usuario.setId(1); usuario.setTipo(io.java.back.enumer.usuario.Tipo.ADMIN); usuario.setLogin("ADM-01"); usuario.setNome("Administrator"); usuario.setSenha(DigestUtils.sha256Hex("123")); usuario.setDataRegistro(new Date()); Chamado chamado = new Chamado(); if (i == 1) { chamado.setId(1); chamado.setMensagem("vamos"); chamado.setAssunto("tempo"); chamado.setStatus(Status.PENDENTE); chamado.setDataRegistro(new Date()); chamado.setTipo(Tipo.SOLICITACAO); chamado.setUsuario(usuario); chamado.setUsuarioStatus(usuario); } if (i == 2) { chamado.setId(2); chamado.setMensagem("vamos sempre"); chamado.setAssunto("tempo parado"); chamado.setStatus(Status.NOVO); chamado.setDataRegistro(new Date()); chamado.setTipo(Tipo.SOLICITACAO); chamado.setUsuario(usuario); chamado.setUsuarioStatus(usuario); } if (i == 3) { chamado.setId(3); chamado.setMensagem("vamos que vamos"); chamado.setAssunto("tempo ao tempo"); chamado.setStatus(Status.FECHADO); chamado.setDataRegistro(new Date()); chamado.setTipo(Tipo.CORRECAO); chamado.setUsuario(usuario); chamado.setUsuarioStatus(usuario); } return chamado; }
From source file:com.squid.kraken.v4.core.analysis.engine.query.rollup.AssociativeTemporaryRollupStrategy.java
@Override protected String getSubQueryIdentifierName() throws RenderingException { String original = "rollup:"; if (hasGrandTotal()) original += "/grandTotal"; for (GroupByAxis ax : getRollup()) { original += "/" + ax.getAxis().getId(); }/* w ww . j a va 2 s.com*/ original += "sql:"; original += getSelect().render(); return "T_" + DigestUtils.sha256Hex(original); }
From source file:io.cloudslang.lang.compiler.caching.CachedPrecompileServiceImpl.java
boolean hasChangedSinceCached(SlangSource source1, SlangSource source2) { String source1AsStr = source1.toString(); String source2AsStr = source2.toString(); return (source1AsStr.length() != source2AsStr.length()) || (!DigestUtils.md5Hex(source1AsStr).equals(DigestUtils.md5Hex(source2AsStr))) || (!DigestUtils.sha256Hex(source1AsStr).equals(DigestUtils.sha256Hex(source2AsStr))); }
From source file:io.github.msdk.spectra.splash.SplashCalculationAlgorithm.java
/** * encodes the actual spectrum//w ww . j av a 2 s. co m * * @param spectrum * @return */ private static String encodeSpectrum(double mzValues[], float intValues[], int size) { StringBuilder buffer = new StringBuilder(); // build the first string for (int i = 0; i < size; i++) { buffer.append(formatMZ(mzValues[i])); buffer.append(":"); buffer.append(formatIntensity(intValues[i])); // add our separator if (i < size - 1) { buffer.append(ION_SEPERATOR); } } // notify observers in case they want to know about progress of the // hashing String block = buffer.toString(); String hash = DigestUtils.sha256Hex(block).substring(0, maxCharactersForSpectrumBlockTruncation); return hash; }
From source file:com.livgrhm.kansas.resources.AuthResource.java
@GET @Timed//from www. j a va 2 s .c o m public AuthenticationResult doAuth(@QueryParam("email") String email, @QueryParam("hash") String hash, @Context HttpServletRequest req) { User user = this.dao.getUserByEmail(email); System.out.println("USER!!!! " + user.getEmail()); if (user == null) { LOGGER.info(" auth notFound " + email); return new AuthenticationResult("F"); } if (user.getUserStatus().equals("D")) { LOGGER.info(" auth isDisabled " + email); return new AuthenticationResult("F"); } if (user.getUserStatus().equals("N")) { if (DigestUtils.sha256Hex((email.toUpperCase() + user.getUserPasswordHash())).equals(hash)) { LOGGER.info(" auth new " + email); return new AuthenticationResult("N"); } else { LOGGER.info(" auth badPassword " + email); return new AuthenticationResult("F"); } } if (user.getUserStatus().equals("V")) { LOGGER.info(" auth notVerified " + email); return new AuthenticationResult("V"); } if (user.getUserPasswordHash().equals(hash)) { LOGGER.info(" auth successful " + email); // create new hash based on the password and a timestamp, and update the user table accordingly. // future data requests will then be tested against this authorisation hash (i.e. an authorisation credential). // the timestamp is to ensure existing credentials expire after (CURRENTLY) 24 hrs java.sql.Date now = new java.sql.Date((new java.util.Date()).getTime()); String timestampHash = DigestUtils.sha256Hex(user.getUserPasswordHash() + now.getTime()); this.dao.setUserAuthHash(user.getUserId(), timestampHash, now, req.getRemoteAddr()); addToAuthList(user.getEmail(), timestampHash, now, req.getRemoteAddr()); return new AuthenticationResult("Y", user.getUserId(), timestampHash, user.getUserStatus()); } else { LOGGER.info(" auth badPassword " + email); if (user.getUserFailedLogons() > 3) { // already 3 failed attempts, so disable the account user.setUserStatus("L"); this.dao.updateUserLockAccount(user.getUserId()); } this.dao.updateFailedLogonCount(user.getUserId()); return new AuthenticationResult("F"); } }
From source file:eu.dime.userresolver.service.basicauth.BasicAuthenticationInterceptor.java
/** * org.apache.cxf.message.Message.PROTOCOL_HEADERS -- * {Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp, *;q=0.8], * accept-encoding=[gzip,deflate,sdch], * accept-language=[de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4], * Authorization=[Basic Og==], /*from w w w . j a v a 2 s . c om*/ * cache-control=[max-age=0], * connection=[keep-alive], * Content-Type=[null], * dnt=[1], * host=[141.99.159.223], * user-agent=[...]} */ @Override public void handleMessage(Message message) throws Fault { AuthorizationPolicy policy = message.get(AuthorizationPolicy.class); Set<Entry<String, Object>> set = message.entrySet(); if (policy == null) { sendErrorResponse(message, HttpURLConnection.HTTP_UNAUTHORIZED); return; } String address; if (message != null && message.get(Message.ENDPOINT_ADDRESS) != null) { address = message.get(Message.ENDPOINT_ADDRESS).toString(); } else { address = ""; } if (!address.endsWith("register")) { User user = userProvider.getBySaid(policy.getUserName()); String key = DigestUtils.sha256Hex(policy.getPassword()); if (!user.getKey().equals(key)) { log.warn("Invalid username or password for user: " + policy.getUserName()); sendErrorResponse(message, HttpURLConnection.HTTP_FORBIDDEN); return; } } }
From source file:controllers.ClaController.java
public static String getToken(String uuid, String email) { StringBuilder builder = new StringBuilder(); builder.append(uuid);/*from w w w . ja v a2s .c om*/ builder.append(email); builder.append(Play.application().configuration().getString("application.secret")); return DigestUtils.sha256Hex(builder.toString()); }
From source file:com.ejisto.modules.conf.ObjectFactoryLoader.java
private void processFile(File file) throws IOException, NotFoundException, CannotCompileException, IllegalAccessException, InstantiationException { CustomObjectFactory factory = customObjectFactoryDao.load(file.getName()); String checksum = DigestUtils.sha256Hex(new FileInputStream(file)); if (factory != null && factory.getChecksum().equals(checksum)) { return;//from w w w . j a va 2 s . c om } log.info("processing file: " + file.getAbsolutePath()); cp.appendClassPath(file.getAbsolutePath()); CtClass clazz; Collection<String> clazzNames = findAllClassesInJarFile(file); ObjectFactory<?> factoryInstance; for (String clazzName : clazzNames) { clazz = cp.get(clazzName); if (clazz.subtypeOf(bazeClazz)) { factoryInstance = (ObjectFactory<?>) clazz.toClass().newInstance(); objectFactoryRepository.registerObjectFactory(clazz.getName(), factoryInstance.getTargetClassName()); } clazz.detach(); } saveCustomObjectFactory(factory, file, checksum); }
From source file:hu.holdinarms.resource.AdminResource.java
/** * Login for admin.//from ww w .j a va2 s . c om * * @param username The admin's username. * @param password The admin's password. * @return The token. */ @GET @UnitOfWork @Path("/login/{username}/{password}") public String login(@PathParam("username") String username, @PathParam("password") String password) { return adminDao.authenticate(username, DigestUtils.sha256Hex(password)); }
From source file:com.tilab.fiware.metaware.service.UserService.java
/** * Create a new user// ww w .j a va 2s. c om * * @param user the new user to be saved. * @return the Id of the new user. */ public String createUser(User user) { log.debug(MSG_SRV_CREATE); user.setPassword(DigestUtils.sha256Hex(user.getPassword())); //user.setSalt(Util.getSalt()); return INSTANCE.getUserDao().createUser(user); }