/** * Create a new instance initialized from credentials and configuration. * * @param credentials Credentials. Can be {@code null} if there are no default credentials. * @param limit Maximum number of URIs that should be kept in the cache containing URIs and their * {@link org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme}. */ DigestAuthenticator(final HttpAuthenticationFilter.Credentials credentials, final int limit) { this.credentials = credentials; digestCache = Collections.synchronizedMap(new LinkedHashMap<URI, DigestScheme>(limit) { // use id as it is an anonymous inner class with changed behaviour private static final long serialVersionUID = 2546245625L; @Override protected boolean removeEldestEntry(final Map.Entry eldest) { return size() > limit; } }); try { randomGenerator = SecureRandom.getInstance("SHA1PRNG"); } catch (final NoSuchAlgorithmException e) { throw new RequestAuthenticationException(LocalizationMessages.ERROR_DIGEST_FILTER_GENERATOR(), e); } }
/** * Create a new instance initialized from credentials and configuration. * * @param credentials Credentials. Can be {@code null} if there are no default credentials. * @param limit Maximum number of URIs that should be kept in the cache containing URIs and their * {@link org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme}. */ DigestAuthenticator(final HttpAuthenticationFilter.Credentials credentials, final int limit) { this.credentials = credentials; digestCache = Collections.synchronizedMap(new LinkedHashMap<URI, DigestScheme>(limit) { // use id as it is an anonymous inner class with changed behaviour private static final long serialVersionUID = 2546245625L; @Override protected boolean removeEldestEntry(final Map.Entry eldest) { return size() > limit; } }); try { randomGenerator = SecureRandom.getInstance("SHA1PRNG"); } catch (final NoSuchAlgorithmException e) { throw new RequestAuthenticationException(LocalizationMessages.ERROR_DIGEST_FILTER_GENERATOR(), e); } }
/** * Create a new instance initialized from credentials and configuration. * * @param credentials Credentials. Can be {@code null} if there are no default credentials. * @param limit Maximum number of URIs that should be kept in the cache containing URIs and their * {@link org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme}. */ DigestAuthenticator(final HttpAuthenticationFilter.Credentials credentials, final int limit) { this.credentials = credentials; digestCache = Collections.synchronizedMap(new LinkedHashMap<URI, DigestScheme>(limit) { // use id as it is an anonymous inner class with changed behaviour private static final long serialVersionUID = 2546245625L; @Override protected boolean removeEldestEntry(final Map.Entry eldest) { return size() > limit; } }); try { randomGenerator = SecureRandom.getInstance("SHA1PRNG"); } catch (final NoSuchAlgorithmException e) { throw new RequestAuthenticationException(LocalizationMessages.ERROR_DIGEST_FILTER_GENERATOR(), e); } }
/** * Adds authentication information to the request. * * @param request Request context. * @throws RequestAuthenticationException in case that basic credentials missing or are in invalid format */ public void filterRequest(ClientRequestContext request) throws RequestAuthenticationException { HttpAuthenticationFilter.Credentials credentials = HttpAuthenticationFilter.getCredentials(request, defaultCredentials, HttpAuthenticationFilter.Type.BASIC); if (credentials == null) { throw new RequestAuthenticationException(LocalizationMessages.AUTHENTICATION_CREDENTIALS_MISSING_BASIC()); } request.getHeaders().add(HttpHeaders.AUTHORIZATION, calculateAuthentication(credentials)); }
/** * Adds authentication information to the request. * * @param request Request context. * @throws RequestAuthenticationException in case that basic credentials missing or are in invalid format */ public void filterRequest(ClientRequestContext request) throws RequestAuthenticationException { HttpAuthenticationFilter.Credentials credentials = HttpAuthenticationFilter.getCredentials(request, defaultCredentials, HttpAuthenticationFilter.Type.BASIC); if (credentials == null) { throw new RequestAuthenticationException(LocalizationMessages.AUTHENTICATION_CREDENTIALS_MISSING_BASIC()); } request.getHeaders().add(HttpHeaders.AUTHORIZATION, calculateAuthentication(credentials)); }
/** * Adds authentication information to the request. * * @param request Request context. * @throws RequestAuthenticationException in case that basic credentials missing or are in invalid format */ public void filterRequest(ClientRequestContext request) throws RequestAuthenticationException { HttpAuthenticationFilter.Credentials credentials = HttpAuthenticationFilter.getCredentials(request, defaultCredentials, HttpAuthenticationFilter.Type.BASIC); if (credentials == null) { throw new RequestAuthenticationException(LocalizationMessages.AUTHENTICATION_CREDENTIALS_MISSING_BASIC()); } request.getHeaders().add(HttpHeaders.AUTHORIZATION, calculateAuthentication(credentials)); }
private static Credentials extractCredentials(ClientRequestContext request, Type type) { String usernameKey = null; String passwordKey = null; if (type == null) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_PASSWORD; } else if (type == Type.BASIC) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD; } else if (type == Type.DIGEST) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_PASSWORD; } String userName = (String) request.getProperty(usernameKey); if (userName != null && !userName.equals("")) { byte[] pwdBytes; Object password = request.getProperty(passwordKey); if (password instanceof byte[]) { pwdBytes = ((byte[]) password); } else if (password instanceof String) { pwdBytes = ((String) password).getBytes(CHARACTER_SET); } else { throw new RequestAuthenticationException( LocalizationMessages.AUTHENTICATION_CREDENTIALS_REQUEST_PASSWORD_UNSUPPORTED()); } return new Credentials(userName, pwdBytes); } return null; }
private static Credentials extractCredentials(ClientRequestContext request, Type type) { String usernameKey = null; String passwordKey = null; if (type == null) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_PASSWORD; } else if (type == Type.BASIC) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD; } else if (type == Type.DIGEST) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_PASSWORD; } String userName = (String) request.getProperty(usernameKey); if (userName != null && !userName.equals("")) { byte[] pwdBytes; Object password = request.getProperty(passwordKey); if (password instanceof byte[]) { pwdBytes = ((byte[]) password); } else if (password instanceof String) { pwdBytes = ((String) password).getBytes(CHARACTER_SET); } else { throw new RequestAuthenticationException( LocalizationMessages.AUTHENTICATION_CREDENTIALS_REQUEST_PASSWORD_UNSUPPORTED()); } return new Credentials(userName, pwdBytes); } return null; }
private static Credentials extractCredentials(ClientRequestContext request, Type type) { String usernameKey = null; String passwordKey = null; if (type == null) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_PASSWORD; } else if (type == Type.BASIC) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD; } else if (type == Type.DIGEST) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_PASSWORD; } String userName = (String) request.getProperty(usernameKey); if (userName != null && !userName.equals("")) { byte[] pwdBytes; Object password = request.getProperty(passwordKey); if (password instanceof byte[]) { pwdBytes = ((byte[]) password); } else if (password instanceof String) { pwdBytes = ((String) password).getBytes(CHARACTER_SET); } else { throw new RequestAuthenticationException( LocalizationMessages.AUTHENTICATION_CREDENTIALS_REQUEST_PASSWORD_UNSUPPORTED()); } return new Credentials(userName, pwdBytes); } return null; }
/** * Create a new instance initialized from credentials and configuration. * * @param credentials Credentials. Can be {@code null} if there are no default credentials. * @param limit Maximum number of URIs that should be kept in the cache containing URIs and their * {@link org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme}. */ DigestAuthenticator(final HttpAuthenticationFilter.Credentials credentials, final int limit) { this.credentials = credentials; digestCache = Collections.synchronizedMap(new LinkedHashMap<URI, DigestScheme>(limit) { // use id as it is an anonymous inner class with changed behaviour private static final long serialVersionUID = 2546245625L; @Override protected boolean removeEldestEntry(final Map.Entry eldest) { return size() > limit; } }); try { randomGenerator = SecureRandom.getInstance("SHA1PRNG"); } catch (final NoSuchAlgorithmException e) { throw new RequestAuthenticationException(LocalizationMessages.ERROR_DIGEST_FILTER_GENERATOR(), e); } }
/** * Create a new instance initialized from credentials and configuration. * * @param credentials Credentials. Can be {@code null} if there are no default credentials. * @param limit Maximum number of URIs that should be kept in the cache containing URIs and their * {@link org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme}. */ DigestAuthenticator(final HttpAuthenticationFilter.Credentials credentials, final int limit) { this.credentials = credentials; digestCache = Collections.synchronizedMap(new LinkedHashMap<URI, DigestScheme>(limit) { // use id as it is an anonymous inner class with changed behaviour private static final long serialVersionUID = 2546245625L; @Override protected boolean removeEldestEntry(final Map.Entry eldest) { return size() > limit; } }); try { randomGenerator = SecureRandom.getInstance("SHA1PRNG"); } catch (final NoSuchAlgorithmException e) { throw new RequestAuthenticationException(LocalizationMessages.ERROR_DIGEST_FILTER_GENERATOR(), e); } }
/** * Create a new instance initialized from credentials and configuration. * * @param credentials Credentials. Can be {@code null} if there are no default credentials. * @param limit Maximum number of URIs that should be kept in the cache containing URIs and their * {@link org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme}. */ DigestAuthenticator(final HttpAuthenticationFilter.Credentials credentials, final int limit) { this.credentials = credentials; digestCache = Collections.synchronizedMap(new LinkedHashMap<URI, DigestScheme>(limit) { // use id as it is an anonymous inner class with changed behaviour private static final long serialVersionUID = 2546245625L; @Override protected boolean removeEldestEntry(final Map.Entry eldest) { return size() > limit; } }); try { randomGenerator = SecureRandom.getInstance("SHA1PRNG"); } catch (final NoSuchAlgorithmException e) { throw new RequestAuthenticationException(LocalizationMessages.ERROR_DIGEST_FILTER_GENERATOR(), e); } }
/** * Create a new instance initialized from credentials and configuration. * * @param credentials Credentials. Can be {@code null} if there are no default credentials. * @param limit Maximum number of URIs that should be kept in the cache containing URIs and their * {@link org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme}. */ DigestAuthenticator(final HttpAuthenticationFilter.Credentials credentials, final int limit) { this.credentials = credentials; digestCache = Collections.synchronizedMap(new LinkedHashMap<URI, DigestScheme>(limit) { // use id as it is an anonymous inner class with changed behaviour private static final long serialVersionUID = 2546245625L; @Override protected boolean removeEldestEntry(final Map.Entry eldest) { return size() > limit; } }); try { randomGenerator = SecureRandom.getInstance("SHA1PRNG"); } catch (final NoSuchAlgorithmException e) { throw new RequestAuthenticationException(LocalizationMessages.ERROR_DIGEST_FILTER_GENERATOR(), e); } }
/** * Adds authentication information to the request. * * @param request Request context. * @throws RequestAuthenticationException in case that basic credentials missing or are in invalid format */ public void filterRequest(ClientRequestContext request) throws RequestAuthenticationException { HttpAuthenticationFilter.Credentials credentials = HttpAuthenticationFilter.getCredentials(request, defaultCredentials, HttpAuthenticationFilter.Type.BASIC); if (credentials == null) { throw new RequestAuthenticationException(LocalizationMessages.AUTHENTICATION_CREDENTIALS_MISSING_BASIC()); } request.getHeaders().add(HttpHeaders.AUTHORIZATION, calculateAuthentication(credentials)); }
/** * Adds authentication information to the request. * * @param request Request context. * @throws RequestAuthenticationException in case that basic credentials missing or are in invalid format */ public void filterRequest(ClientRequestContext request) throws RequestAuthenticationException { HttpAuthenticationFilter.Credentials credentials = HttpAuthenticationFilter.getCredentials(request, defaultCredentials, HttpAuthenticationFilter.Type.BASIC); if (credentials == null) { throw new RequestAuthenticationException(LocalizationMessages.AUTHENTICATION_CREDENTIALS_MISSING_BASIC()); } request.getHeaders().add(HttpHeaders.AUTHORIZATION, calculateAuthentication(credentials)); }
/** * Adds authentication information to the request. * * @param request Request context. * @throws RequestAuthenticationException in case that basic credentials missing or are in invalid format */ public void filterRequest(ClientRequestContext request) throws RequestAuthenticationException { HttpAuthenticationFilter.Credentials credentials = HttpAuthenticationFilter.getCredentials(request, defaultCredentials, HttpAuthenticationFilter.Type.BASIC); if (credentials == null) { throw new RequestAuthenticationException(LocalizationMessages.AUTHENTICATION_CREDENTIALS_MISSING_BASIC()); } request.getHeaders().add(HttpHeaders.AUTHORIZATION, calculateAuthentication(credentials)); }
/** * Adds authentication information to the request. * * @param request Request context. * @throws RequestAuthenticationException in case that basic credentials missing or are in invalid format */ public void filterRequest(ClientRequestContext request) throws RequestAuthenticationException { HttpAuthenticationFilter.Credentials credentials = HttpAuthenticationFilter.getCredentials(request, defaultCredentials, HttpAuthenticationFilter.Type.BASIC); if (credentials == null) { throw new RequestAuthenticationException(LocalizationMessages.AUTHENTICATION_CREDENTIALS_MISSING_BASIC()); } request.getHeaders().add(HttpHeaders.AUTHORIZATION, calculateAuthentication(credentials)); }
private static Credentials extractCredentials(ClientRequestContext request, Type type) { String usernameKey = null; String passwordKey = null; if (type == null) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_PASSWORD; } else if (type == Type.BASIC) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD; } else if (type == Type.DIGEST) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_PASSWORD; } String userName = (String) request.getProperty(usernameKey); if (userName != null && !userName.equals("")) { byte[] pwdBytes; Object password = request.getProperty(passwordKey); if (password instanceof byte[]) { pwdBytes = ((byte[]) password); } else if (password instanceof String) { pwdBytes = ((String) password).getBytes(CHARACTER_SET); } else { throw new RequestAuthenticationException( LocalizationMessages.AUTHENTICATION_CREDENTIALS_REQUEST_PASSWORD_UNSUPPORTED()); } return new Credentials(userName, pwdBytes); } return null; }
private static Credentials extractCredentials(ClientRequestContext request, Type type) { String usernameKey = null; String passwordKey = null; if (type == null) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_PASSWORD; } else if (type == Type.BASIC) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD; } else if (type == Type.DIGEST) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_PASSWORD; } String userName = (String) request.getProperty(usernameKey); if (userName != null && !userName.equals("")) { byte[] pwdBytes; Object password = request.getProperty(passwordKey); if (password instanceof byte[]) { pwdBytes = ((byte[]) password); } else if (password instanceof String) { pwdBytes = ((String) password).getBytes(CHARACTER_SET); } else { throw new RequestAuthenticationException( LocalizationMessages.AUTHENTICATION_CREDENTIALS_REQUEST_PASSWORD_UNSUPPORTED()); } return new Credentials(userName, pwdBytes); } return null; }
private static Credentials extractCredentials(ClientRequestContext request, Type type) { String usernameKey = null; String passwordKey = null; if (type == null) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_PASSWORD; } else if (type == Type.BASIC) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD; } else if (type == Type.DIGEST) { usernameKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_USERNAME; passwordKey = HttpAuthenticationFeature.HTTP_AUTHENTICATION_DIGEST_PASSWORD; } String userName = (String) request.getProperty(usernameKey); if (userName != null && !userName.equals("")) { byte[] pwdBytes; Object password = request.getProperty(passwordKey); if (password instanceof byte[]) { pwdBytes = ((byte[]) password); } else if (password instanceof String) { pwdBytes = ((String) password).getBytes(CHARACTER_SET); } else { throw new RequestAuthenticationException( LocalizationMessages.AUTHENTICATION_CREDENTIALS_REQUEST_PASSWORD_UNSUPPORTED()); } return new Credentials(userName, pwdBytes); } return null; }