List of usage examples for com.liferay.portal.kernel.security.auth PrincipalThreadLocal getPassword
public static String getPassword()
From source file:com.liferay.document.library.repository.cmis.internal.CMISAtomPubRepository.java
License:Open Source License
@Override public Session getSession() throws PortalException { Map<String, String> parameters = new HashMap<>(); parameters.put(SessionParameter.ATOMPUB_URL, getTypeSettingsValue(CMISRepositoryConstants.CMIS_ATOMPUB_URL_PARAMETER)); parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); parameters.put(SessionParameter.COMPRESSION, Boolean.TRUE.toString()); Locale locale = LocaleUtil.getSiteDefault(); parameters.put(SessionParameter.LOCALE_ISO3166_COUNTRY, locale.getCountry()); parameters.put(SessionParameter.LOCALE_ISO639_LANGUAGE, locale.getLanguage()); String login = getLogin();//from www.j av a 2 s. co m String password = null; if (Validator.isNotNull(login)) { password = PrincipalThreadLocal.getPassword(); } else { login = _DL_REPOSITORY_GUEST_USERNAME; password = _DL_REPOSITORY_GUEST_PASSWORD; } parameters.put(SessionParameter.PASSWORD, password); parameters.put(SessionParameter.USER, login); Thread thread = Thread.currentThread(); ClassLoader contextClassLoader = thread.getContextClassLoader(); Class<?> clazz = getClass(); ClassLoader classLoader = clazz.getClassLoader(); thread.setContextClassLoader(classLoader); try { CMISRepositoryUtil.checkRepository(getRepositoryId(), parameters, getTypeSettingsProperties(), CMISRepositoryConstants.CMIS_ATOMPUB_REPOSITORY_ID_PARAMETER); return CMISRepositoryUtil.createSession(parameters); } finally { thread.setContextClassLoader(contextClassLoader); } }
From source file:com.liferay.document.library.repository.cmis.internal.CMISWebServicesRepository.java
License:Open Source License
@Override public Session getSession() throws PortalException { Map<String, String> parameters = new HashMap<>(); parameters.put(SessionParameter.BINDING_TYPE, BindingType.WEBSERVICES.value()); parameters.put(SessionParameter.COMPRESSION, Boolean.TRUE.toString()); Locale locale = LocaleUtil.getSiteDefault(); parameters.put(SessionParameter.LOCALE_ISO3166_COUNTRY, locale.getCountry()); parameters.put(SessionParameter.LOCALE_ISO639_LANGUAGE, locale.getLanguage()); String password = PrincipalThreadLocal.getPassword(); parameters.put(SessionParameter.PASSWORD, password); String login = getLogin();/* w w w . j a va 2s . c o m*/ parameters.put(SessionParameter.USER, login); parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, getTypeSettingsValue(CMISRepositoryConstants.CMIS_WEBSERVICES_ACL_SERVICE_PARAMETER)); parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, getTypeSettingsValue(CMISRepositoryConstants.CMIS_WEBSERVICES_DISCOVERY_SERVICE_PARAMETER)); parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, getTypeSettingsValue(CMISRepositoryConstants.CMIS_WEBSERVICES_MULTIFILING_SERVICE_PARAMETER)); parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, getTypeSettingsValue(CMISRepositoryConstants.CMIS_WEBSERVICES_NAVIGATION_SERVICE_PARAMETER)); parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, getTypeSettingsValue(CMISRepositoryConstants.CMIS_WEBSERVICES_OBJECT_SERVICE_PARAMETER)); parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, getTypeSettingsValue(CMISRepositoryConstants.CMIS_WEBSERVICES_POLICY_SERVICE_PARAMETER)); parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, getTypeSettingsValue(CMISRepositoryConstants.CMIS_WEBSERVICES_RELATIONSHIP_SERVICE_PARAMETER)); parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, getTypeSettingsValue(CMISRepositoryConstants.CMIS_WEBSERVICES_REPOSITORY_SERVICE_PARAMETER)); parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, getTypeSettingsValue(CMISRepositoryConstants.CMIS_WEBSERVICES_VERSIONING_SERVICE_PARAMETER)); CMISRepositoryUtil.checkRepository(getRepositoryId(), parameters, getTypeSettingsProperties(), CMISRepositoryConstants.CMIS_WEBSERVICES_REPOSITORY_ID_PARAMETER); return CMISRepositoryUtil.createSession(parameters); }
From source file:com.liferay.document.library.repository.external.ExtRepositoryAdapter.java
License:Open Source License
private String _getPassword() { String login = PrincipalThreadLocal.getName(); if (Validator.isNull(login) || _isDefaultUser(login)) { return PropsUtil.get(PropsKeys.DL_REPOSITORY_GUEST_PASSWORD); }/*ww w.j a v a 2 s . c o m*/ return PrincipalThreadLocal.getPassword(); }