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 String calculateAuthentication(HttpAuthenticationFilter.Credentials credentials) { String username = credentials.getUsername(); byte[] password = credentials.getPassword(); if (username == null) { username = ""; } if (password == null) { password = new byte[0]; } final byte[] prefix = (username + ":").getBytes(HttpAuthenticationFilter.CHARACTER_SET); final byte[] usernamePassword = new byte[prefix.length + password.length]; System.arraycopy(prefix, 0, usernamePassword, 0, prefix.length); System.arraycopy(password, 0, usernamePassword, prefix.length, password.length); return "Basic " + Base64.encodeAsString(usernamePassword); }
final StringBuilder sb = new StringBuilder(100); sb.append("Digest "); append(sb, "username", credentials.getUsername()); append(sb, "realm", ds.getRealm()); append(sb, "nonce", ds.getNonce()); ha1 = md5(md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())))); } else { ha1 = md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())));
final StringBuilder sb = new StringBuilder(100); sb.append("Digest "); append(sb, "username", credentials.getUsername()); append(sb, "realm", ds.getRealm()); append(sb, "nonce", ds.getNonce()); ha1 = md5(md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())))); } else { ha1 = md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())));
final StringBuilder sb = new StringBuilder(100); sb.append("Digest "); append(sb, "username", credentials.getUsername()); append(sb, "realm", ds.getRealm()); append(sb, "nonce", ds.getNonce()); ha1 = md5(md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())))); } else { ha1 = md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())));
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; }
final StringBuilder sb = new StringBuilder(100); sb.append("Digest "); append(sb, "username", credentials.getUsername()); append(sb, "realm", ds.getRealm()); append(sb, "nonce", ds.getNonce()); ha1 = md5(md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())))); } else { ha1 = md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())));
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; }
private String calculateAuthentication(HttpAuthenticationFilter.Credentials credentials) { String username = credentials.getUsername(); byte[] password = credentials.getPassword(); if (username == null) { username = ""; } if (password == null) { password = new byte[0]; } final byte[] prefix = (username + ":").getBytes(HttpAuthenticationFilter.CHARACTER_SET); final byte[] usernamePassword = new byte[prefix.length + password.length]; System.arraycopy(prefix, 0, usernamePassword, 0, prefix.length); System.arraycopy(password, 0, usernamePassword, prefix.length, password.length); return "Basic " + Base64.encodeAsString(usernamePassword); }
private String calculateAuthentication(HttpAuthenticationFilter.Credentials credentials) { String username = credentials.getUsername(); byte[] password = credentials.getPassword(); if (username == null) { username = ""; } if (password == null) { password = new byte[0]; } final byte[] prefix = (username + ":").getBytes(HttpAuthenticationFilter.CHARACTER_SET); final byte[] usernamePassword = new byte[prefix.length + password.length]; System.arraycopy(prefix, 0, usernamePassword, 0, prefix.length); System.arraycopy(password, 0, usernamePassword, prefix.length, password.length); return "Basic " + Base64.encodeAsString(usernamePassword); }
private String calculateAuthentication(HttpAuthenticationFilter.Credentials credentials) { String username = credentials.getUsername(); byte[] password = credentials.getPassword(); if (username == null) { username = ""; } if (password == null) { password = new byte[0]; } final byte[] prefix = (username + ":").getBytes(HttpAuthenticationFilter.CHARACTER_SET); final byte[] usernamePassword = new byte[prefix.length + password.length]; System.arraycopy(prefix, 0, usernamePassword, 0, prefix.length); System.arraycopy(password, 0, usernamePassword, prefix.length, password.length); return "Basic " + Base64.encodeAsString(usernamePassword); }
private String calculateAuthentication(HttpAuthenticationFilter.Credentials credentials) { String username = credentials.getUsername(); byte[] password = credentials.getPassword(); if (username == null) { username = ""; } if (password == null) { password = new byte[0]; } final byte[] prefix = (username + ":").getBytes(HttpAuthenticationFilter.CHARACTER_SET); final byte[] usernamePassword = new byte[prefix.length + password.length]; System.arraycopy(prefix, 0, usernamePassword, 0, prefix.length); System.arraycopy(password, 0, usernamePassword, prefix.length, password.length); return "Basic " + Base64.encodeAsString(usernamePassword); }
@Override public HttpAuthenticationFeature build() { return new HttpAuthenticationFeature(mode, usernameBasic == null ? null : new HttpAuthenticationFilter.Credentials(usernameBasic, passwordBasic), usernameDigest == null ? null : new HttpAuthenticationFilter.Credentials(usernameDigest, passwordDigest)); }
@Override public HttpAuthenticationFeature build() { return new HttpAuthenticationFeature(mode, usernameBasic == null ? null : new HttpAuthenticationFilter.Credentials(usernameBasic, passwordBasic), usernameDigest == null ? null : new HttpAuthenticationFilter.Credentials(usernameDigest, passwordDigest)); }
@Override public HttpAuthenticationFeature build() { return new HttpAuthenticationFeature(mode, usernameBasic == null ? null : new HttpAuthenticationFilter.Credentials(usernameBasic, passwordBasic), usernameDigest == null ? null : new HttpAuthenticationFilter.Credentials(usernameDigest, passwordDigest)); }
@Override public HttpAuthenticationFeature build() { return new HttpAuthenticationFeature(mode, usernameBasic == null ? null : new HttpAuthenticationFilter.Credentials(usernameBasic, passwordBasic), usernameDigest == null ? null : new HttpAuthenticationFilter.Credentials(usernameDigest, passwordDigest)); }
final StringBuilder sb = new StringBuilder(100); sb.append("Digest "); append(sb, "username", credentials.getUsername()); append(sb, "realm", ds.getRealm()); append(sb, "nonce", ds.getNonce()); ha1 = md5(md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())))); } else { ha1 = md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())));
final StringBuilder sb = new StringBuilder(100); sb.append("Digest "); append(sb, "username", credentials.getUsername()); append(sb, "realm", ds.getRealm()); append(sb, "nonce", ds.getNonce()); ha1 = md5(md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())))); } else { ha1 = md5(credentials.getUsername(), ds.getRealm(), new String(credentials.getPassword(), MessageUtils.getCharset(requestContext.getMediaType())));