У меня есть веб-приложение, которое развернуто в tomcat и из этого веб-приложения, я должен использовать службу SOAP, которая развернута в Websphere. Чтобы получить доступ к этой услуге, мне нужно передать токен LTPA. Я очень новичок в websphere, не знаю, как я могу получить токен LTPA в своем веб-приложении? Я не могу изменить реализацию приложения, которое развертывается в веб-сфере.Доступ к токенам LTPA вне контекста WebSphere
0
A
ответ
0
Я мог бы добиться этого, используя HttpBasicAuthentication. Ниже представлен фрагмент кода -
public class TokenHelper {
private static Logger logger = LoggerFactory.getLogger(TokenHelper.class);
private static final int HTTP_TIMEOUT_MILISEC = 100000;
private static String lineSeparator = System.getProperty("line.separator");
@Value("#{'${hostname}'}")
private String hostName;
@Value("#{'${port}'}")
private int port;
@Value("#{'${contextpath}'}")
private String contextPath;
@Value("#{'${isbasicauthentication}'}")
private boolean isBasicAuthentication;
@Value("#{'${username}'}")
private String basicAuthenticationUserName;
@Value("#{'${userpassword}'}")
private String basicAuthenticationPassword;
public Map<String, String> getLtpaToken() throws Exception {
Cookie[] cookies = null;
Protocol protocol = null;
Map<String, String> cookiesMap = new HashMap<String, String>();
GetMethod method = new GetMethod();
HttpClient client = new HttpClient();
method.getParams().setSoTimeout(HTTP_TIMEOUT_MILISEC);
protocol = new Protocol("http", new DefaultProtocolSocketFactory(), getPort());
if (isBasicAuthentication) {
client.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new UsernamePasswordCredentials(getBasicAuthenticationUserName(), getBasicAuthenticationPassword());
client.getState().setCredentials(new AuthScope(getHostName(), getPort(), AuthScope.ANY_REALM), defaultcreds);
}
// Execute request
try {
client.getHostConfiguration().setHost(getHostName(), getPort(), protocol);
method = new GetMethod(getContextPath());
method.setFollowRedirects(true);
logger.info(methodName, "URL to get:" + getContextPath());
// Execute the GET method
int statusCode = client.executeMethod(method);
if (statusCode != -1) {
cookies = client.getState().getCookies();
StringBuffer sb = new StringBuffer();
for (int j = 0; j < cookies.length; j++) {
cookiesMap.put(cookies[j].getName(), cookies[j].getValue());
sb.append("CookieName=" + cookies[j].getName() + lineSeparator);
sb.append("Value=" + cookies[j].getValue() + lineSeparator);
sb.append("Domain=" + cookies[j].getDomain() + lineSeparator);
}
sb.append("Status Text>>>" + HttpStatus.getStatusText(statusCode));
logger.debug("Cookies are: {}" + sb.toString());
method.releaseConnection();
}
} catch (Exception e) {
logger.error("Error while getting LTPA token using HttpBasicAuthentication for URL {}" +e);
throw new RuntimeException("Error while getting LTPA token using HttpBasicAuthentication for URL:" + contextPath, e);
} finally {
// Release current connection to the connection pool once you
// are done
method.releaseConnection();
}
return cookiesMap;
}
Смежные вопросы
- 1. Доступ к токенам?
- 2. Невозможно получить доступ к переменной - Вне контекста
- 3. Недействительный токен LTPA на Websphere
- 4. Как поймать исключение LTPA WebSphere
- 5. Доступ к токенам в OAuth2?
- 6. Использование SPNEGO и LTPA в WebSphere
- 7. Генерация маркера IBM Websphere и LTPA
- 8. Worklight LTPA Аутентификация с использованием WebSphere
- 9. Доступ к сырым токенам JSon в C#?
- 10. Facebook Доступ к токенам безопасности Token Security
- 11. Доступ к токенам - Как их получить?
- 12. Доступ к токенам и данным ответа
- 13. Получите доступ к токенам API-схемы instagram
- 14. Доступ к токенам Oauth, возвращаемым Keycloak
- 15. Worklight LTPA SSO
- 16. доступ приложение парусов вне контекста LOCALHOST
- 17. IBM DataPower LTPA
- 18. Доступ к токенам доступа к Quickbooks API signature_invalid
- 19. Ток LTPA не изменяется
- 20. Доступ к переменным Websphere 6.1
- 21. JavaScript «Это» вне контекста, относится к окну
- 22. Создать токен LTPA?
- 23. Доступ к SharedPreferences без контекста
- 24. Доступ к текущей Нокаут связывания контекста
- 25. Как создать токен LTPA для профиля WebSphere Liberty
- 26. WebSphere Application Server 7 - httpOnly & secure flag для LTPA
- 27. C# Вне контекста метод
- 28. Объект вне контекста
- 29. Использования строки из контекста вне контекста
- 30. Как использовать информацию в LTPA лексем