/** * Returns if a UsernameToken should be sent. (Web Services binding only.) */ protected boolean getSendUsernameToken() { return getSession().get(SessionParameter.AUTH_SOAP_USERNAMETOKEN, false); }
/** * Returns if a HTTP Basic Authentication header should be sent. (All * bindings.) */ protected boolean getSendBasicAuth() { return getSession().get(SessionParameter.AUTH_HTTP_BASIC, false); }
/** * Returns if an OAuth Bearer token header should be sent. (All bindings.) */ protected boolean getSendBearerToken() { return getSession().get(SessionParameter.AUTH_OAUTH_BEARER, false); }
/** * Returns if a HTTP Basic Authentication header should be sent. (All * bindings.) */ protected boolean getSendBasicAuth() { return getSession().get(SessionParameter.AUTH_HTTP_BASIC, false); }
/** * Returns if an OAuth Bearer token header should be sent. (All bindings.) */ protected boolean getSendBearerToken() { return getSession().get(SessionParameter.AUTH_OAUTH_BEARER, false); }
/** * Returns if a UsernameToken should be sent. (Web Services binding only.) */ protected boolean getSendUsernameToken() { return getSession().get(SessionParameter.AUTH_SOAP_USERNAMETOKEN, false); }
/** * Adds the {@link SessionParameter#HEADER} to the fixed headers. This * method should only be called from the {@link #setSession(BindingSession)} * method to avoid threading issues. */ protected void addSessionParameterHeadersToFixedHeaders() { int x = 0; Object headerParam; while ((headerParam = getSession().get(SessionParameter.HEADER + "." + x)) != null) { String header = headerParam.toString(); int colon = header.indexOf(':'); if (colon > -1) { String key = header.substring(0, colon).trim(); if (key.length() > 0) { String value = header.substring(colon + 1).trim(); List<String> values = fixedHeaders.get(key); if (values == null) { fixedHeaders.put(key, Collections.singletonList(value)); } else { List<String> newValues = new ArrayList<String>(values); newValues.add(value); fixedHeaders.put(key, newValues); } } } x++; } }
/** * Adds the {@link SessionParameter#HEADER} to the fixed headers. This * method should only be called from the {@link #setSession(BindingSession)} * method to avoid threading issues. */ protected void addSessionParameterHeadersToFixedHeaders() { int x = 0; Object headerParam; while ((headerParam = getSession().get(SessionParameter.HEADER + "." + x)) != null) { String header = headerParam.toString(); int colon = header.indexOf(':'); if (colon > -1) { String key = header.substring(0, colon).trim(); if (key.length() > 0) { String value = header.substring(colon + 1).trim(); List<String> values = fixedHeaders.get(key); if (values == null) { fixedHeaders.put(key, Collections.singletonList(value)); } else { List<String> newValues = new ArrayList<String>(values); newValues.add(value); fixedHeaders.put(key, newValues); } } } x++; } }
/** * Returns if the authentication provider should handle cookies. */ protected boolean getHandleCookies() { Object value = getSession().get(SessionParameter.COOKIES); if (value instanceof Boolean) { return ((Boolean) value).booleanValue(); } else if (value instanceof String) { return Boolean.parseBoolean((String) value); } else if (value == null) { return getCsrfHeader() != null; } return false; } }
/** * Returns if the authentication provider should handle cookies. */ protected boolean getHandleCookies() { Object value = getSession().get(SessionParameter.COOKIES); if (value instanceof Boolean) { return ((Boolean) value).booleanValue(); } else if (value instanceof String) { return Boolean.parseBoolean((String) value); } else if (value == null) { return getCsrfHeader() != null; } return false; } }
/** * Creates a basic authentication header value from a username and a * password. */ protected List<String> createBasicAuthHeaderValue(String username, String password) { if (password == null) { password = ""; } Object charset = getSession().get(SessionParameter.AUTH_HTTP_BASIC_CHARSET); if (charset instanceof String) { charset = ((String) charset).trim(); } else { charset = IOUtils.UTF8; } byte[] usernamePassword; try { usernamePassword = (username + ":" + password).getBytes((String) charset); } catch (UnsupportedEncodingException e) { throw new CmisRuntimeException("Unsupported encoding '" + charset + "'!", e); } return Collections.singletonList("Basic " + Base64.encodeBytes(usernamePassword)); }
/** * Creates a basic authentication header value from a username and a * password. */ protected List<String> createBasicAuthHeaderValue(String username, String password) { if (password == null) { password = ""; } Object charset = getSession().get(SessionParameter.AUTH_HTTP_BASIC_CHARSET); if (charset instanceof String) { charset = ((String) charset).trim(); } else { charset = IOUtils.UTF8; } byte[] usernamePassword; try { usernamePassword = (username + ":" + password).getBytes((String) charset); } catch (UnsupportedEncodingException e) { throw new CmisRuntimeException("Unsupported encoding '" + charset + "'!", e); } return Collections.singletonList("Basic " + Base64.encodeBytes(usernamePassword)); }