public boolean hasExpired(String nonceValue, long maxValue) { nonceValue = new String(Base64.decode(nonceValue)); int colonIndex = nonceValue.indexOf(":"); if (colonIndex < 0) return true; String timeValue = nonceValue.substring(0, colonIndex); long parsedTimeValue = Long.parseLong(timeValue); long ms = System.currentTimeMillis() - parsedTimeValue; if (ms > maxValue) { return true; } return false; }
public boolean hasExpired(String nonceValue, long maxValue) { nonceValue = new String(Base64.decode(nonceValue)); int colonIndex = nonceValue.indexOf(":"); if (colonIndex < 0) return true; String timeValue = nonceValue.substring(0, colonIndex); long parsedTimeValue = Long.parseLong(timeValue); long ms = System.currentTimeMillis() - parsedTimeValue; if (ms > maxValue) { return true; } return false; }
public boolean hasExpired(String nonceValue, long maxValue) { nonceValue = new String(Base64.decode(nonceValue)); int colonIndex = nonceValue.indexOf(":"); if (colonIndex < 0) return true; String timeValue = nonceValue.substring(0, colonIndex); long parsedTimeValue = Long.parseLong(timeValue); long ms = System.currentTimeMillis() - parsedTimeValue; if (ms > maxValue) { return true; } return false; }
/** * Apply base64 decoding on the message and return the byte array * * @param encodedString * * @return */ public static byte[] base64Decode(String encodedString) { if (encodedString == null) throw logger.nullArgumentError("encodedString"); //$NON-NLS-1$ return Base64.decode(encodedString); }
public static String decode64(String secret, String cipherAlgorithm, SecretKey cipherKey, PBEParameterSpec cipherSpec) throws GeneralSecurityException, UnsupportedEncodingException { byte[] encoding = Base64.decode(secret); byte[] decode = decode(encoding, cipherAlgorithm, cipherKey, cipherSpec); return new String(decode, "UTF-8"); }
/** * Apply base64 decoding on the message and return the byte array * * @param encodedString * * @return */ public static byte[] base64Decode(String encodedString) { if (encodedString == null) throw logger.nullArgumentError("encodedString"); return Base64.decode(encodedString); }
/** * Base64 decode followed by Deflate decoding * * @param encodedString * * @return */ public static InputStream base64DeflateDecode(String encodedString) { byte[] base64decodedMsg = Base64.decode(encodedString); return DeflateUtil.decode(base64decodedMsg); }
public static String decode64(String secret, String cipherAlgorithm, SecretKey cipherKey, PBEParameterSpec cipherSpec) throws GeneralSecurityException, UnsupportedEncodingException { byte[] encoding = Base64.decode(secret); byte[] decode = decode(encoding, cipherAlgorithm, cipherKey, cipherSpec); return new String(decode, "UTF-8"); }
/** * Base64 decode followed by Deflate decoding * * @param encodedString * * @return */ public static InputStream base64DeflateDecode(String encodedString) { byte[] base64decodedMsg = Base64.decode(encodedString); return DeflateUtil.decode(base64decodedMsg); }
/** * Apply base64 decoding on the message and return the byte array * * @param encodedString * * @return */ public static byte[] base64Decode(String encodedString) { if (encodedString == null) throw logger.nullArgumentError("encodedString"); return Base64.decode(encodedString); }
public static String decode64(String secret, String cipherAlgorithm, SecretKey cipherKey, PBEParameterSpec cipherSpec) throws GeneralSecurityException, UnsupportedEncodingException { byte[] encoding = Base64.decode(secret); byte[] decode = decode(encoding, cipherAlgorithm, cipherKey, cipherSpec); return new String(decode, "UTF-8"); }
/** * On the byte array, apply URL decoding followed by base64 decoding * * @param encodedString * * @return * * @throws IOException */ public static byte[] urlBase64Decode(String encodedString) throws IOException { String decodedString = urlDecode(encodedString); return Base64.decode(decodedString); }
/** * On the byte array, apply URL decoding followed by base64 decoding * * @param encodedString * * @return * * @throws IOException */ public static byte[] urlBase64Decode(String encodedString) throws IOException { String decodedString = urlDecode(encodedString); return Base64.decode(decodedString); }
public String[] extractUsernameAndPassword(HttpServletRequest request) { String authorizationHeader = getAuthorizationHeader(request); String base64Token = authorizationHeader.substring(6); String token = new String(Base64.decode(base64Token)); String username = ""; String password = ""; int delim = token.indexOf(":"); if (delim != -1) { username = token.substring(0, delim); password = token.substring(delim + 1); } return new String[]{username, password}; } }
public String[] extractUsernameAndPassword(HttpServletRequest request) { String authorizationHeader = getAuthorizationHeader(request); String base64Token = authorizationHeader.substring(6); String token = new String(Base64.decode(base64Token)); String username = ""; String password = ""; int delim = token.indexOf(":"); if (delim != -1) { username = token.substring(0, delim); password = token.substring(delim + 1); } return new String[]{username, password}; } }
public String[] extractUsernameAndPassword(HttpServletRequest request) { String authorizationHeader = getAuthorizationHeader(request); String base64Token = authorizationHeader.substring(6); String token = new String(Base64.decode(base64Token)); String username = ""; String password = ""; int delim = token.indexOf(":"); if (delim != -1) { username = token.substring(0, delim); password = token.substring(delim + 1); } return new String[]{username, password}; } }
/** * Convert to the JDK representation of a RSA Public Key * * @return * * @throws ProcessingException */ public RSAPublicKey convertToPublicKey() throws ProcessingException { BigInteger bigModulus = new BigInteger(1, massage(Base64.decode(new String(modulus)))); BigInteger bigEx = new BigInteger(1, massage(Base64.decode(new String(exponent)))); try { KeyFactory rsaKeyFactory = KeyFactory.getInstance("rsa"); RSAPublicKeySpec kspec = new RSAPublicKeySpec(bigModulus, bigEx); return (RSAPublicKey) rsaKeyFactory.generatePublic(kspec); } catch (Exception e) { throw new ProcessingException(e); } }
/** * Convert to the JDK representation of a RSA Private Key * * @return * * @throws ProcessingException */ public RSAPrivateKey convertToPrivateKey() throws ProcessingException { BigInteger bigModulus = new BigInteger(1, massage(Base64.decode(new String(modulus)))); BigInteger bigEx = new BigInteger(1, massage(Base64.decode(new String(exponent)))); try { KeyFactory rsaKeyFactory = KeyFactory.getInstance("rsa"); RSAPrivateKeySpec kspec = new RSAPrivateKeySpec(bigModulus, bigEx); return (RSAPrivateKey) rsaKeyFactory.generatePrivate(kspec); } catch (Exception e) { throw new ProcessingException(e); } }
@Override protected boolean validateCredential(IdentityContext context, final CredentialStorage storage, final X509CertificateCredentials credentials, CredentialStore<?> store) { X509CertificateStorage certificateStorage = (X509CertificateStorage) storage; if (!credentials.isTrusted()) { try { byte[] certBytes = Base64.decode(certificateStorage.getBase64Cert()); CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); X509Certificate storedCert = (X509Certificate) certFactory .generateCertificate(new ByteArrayInputStream(certBytes)); X509Certificate providedCert = credentials.getCertificate(); return storedCert.equals(providedCert); } catch (Exception e) { throw new IdentityManagementException("Error while checking user's certificate.", e); } } return true; }
@Override protected boolean validateCredential(IdentityContext context, final CredentialStorage storage, final X509CertificateCredentials credentials, CredentialStore<?> store) { X509CertificateStorage certificateStorage = (X509CertificateStorage) storage; if (!credentials.isTrusted()) { try { byte[] certBytes = Base64.decode(certificateStorage.getBase64Cert()); CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); X509Certificate storedCert = (X509Certificate) certFactory .generateCertificate(new ByteArrayInputStream(certBytes)); X509Certificate providedCert = credentials.getCertificate(); return storedCert.equals(providedCert); } catch (Exception e) { throw new IdentityManagementException("Error while checking user's certificate.", e); } } return true; }