Well, I'm trying to get all users from Openfire server using Smack, unfortunately I don't know how - I'm using Smack 4.2.2.
UserSearchManager usm= new UserSearchManager(connection);
DomainBareJid domainJid =
JidCreate.domainBareFrom(connection.getServiceName());
Form searchForm = usm.getSearchForm(domainJid);
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
answerForm.setAnswer("search", "*");
ReportedData data = usm.getSearchResults(answerForm, domainJid);
if (data.getRows() != null) {
for (ReportedData.Row row: data.getRows()) {
for (String jid:row.getValues("jid")) {
System.out.println(jid);
}
}
}
This code doesn't work because of:
java.lang.IllegalArgumentException: Must have a local (user) JID set. Either you didn't configure one or you where not connected at least once
You can't get all users through XEP-0055: Jabber Search, just can be used with a filter you sure that the users don't have it (like a special character). Only way I know is to use Rest API Plugin of openfire. You can read more about this plugin from the link. Good luck.
Error is obvious. Either you did not connect at least once (or got disconnected and did not reconnect) or your username is wrong.
Maybe you are trying to connect without local jid. Please check this explanation of XMPP address formats:
https://xmpp.org/rfcs/rfc6122.html#addressing-localpart
hope you have solved the problem. I got my code working with this little change
DomainBareJid domainJid =
JidCreate.domainBareFrom("search." + connection.getServiceName());
in your openfire go to Plugins and select available-plugins > then choose rest Api > then you can use following url to Get All users in Group:
http://localhost:9090/plugins/restapi/v1/users
Note: All Rest EndPoints you can find in following link:
https://www.igniterealtime.org/projects/openfire/plugins/1.2.1/restAPI/readme.html
Related
I'm trying to implement a custom keycloack Authenticator SPI for authentication purposes against an external Identity provider. The users already exist on the keycloak store, I only need connection to the custom SPI to authenticate them.
I'm following section 8.3 of the official guide https://www.keycloak.org/docs/latest/server_development/index.html#_auth_spi_walkthrough, which is very similar to what I need.
The problem I'm running into is that after the authentication flow runs into the "action" method of the custom Authenticator, an exception is thrown from the AuthenticationProcessor Class, which after inspection, comes from following check:
// org.keycloak.authentication.AuthenticationProcessor - line 876
if (authenticationSession.getAuthenticatedUser() == null) {
throw new AuthenticationFlowException(AuthenticationFlowError.UNKNOWN_USER);
}
after seeing this problem, my idea for trying solving it, was getting the user (already verified against the externl Identity Provider) from the keycloak store, and pushing it into the AuthenticationSession, like this:
// Connect against external Service Provider
// and asume "USER_ID" represents an already validated User
// AuthenticationFlowContext = afc is given as parameter
UserFederationManager ufm = afc.getSession().users(); // <-- PROBLEM
UserModel userFound = ufm.getUserById("USER_ID", afc.getRealm());
if (userFound != null) {
// get reference to the authSession
AuthenticationSessionModel asm = afc.getAuthenticationSession();
// set authenticated user on the session
asm.setAuthenticatedUser(userFound );
return true;
}
return false;
The problem with the above code, is that a Java NoSuchMethodExceptionError is thrown regarding the users() method of the org.keaycloak.models.KeycloackSession class. Like this:
11:26:32,628 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-14) Uncaught server error: java.lang.NoSuchMethodError: org.keycloak.models.KeycloakSession.users()Lorg/keycloak/models/UserFederationManager;
Any suggestion that you could make to help me solve this would be greatly appreciated!
It seems the problem was that I was using an org.keycloak.models.UserFederationManager instance, instead of an org.keycloak.models.UserProvider instance. The UserFederationManager implements the UserProvider, and it seems the more general type works better than the more specific type under the injection mechanism this keycloak is using
// UserFederationManager ufm = afc.getSession().users(); // <-- PROBLEM
// UserProvider ufm = afc.getSession().users(); // <-- WORKS
Even though it works now, both of your suggestions are valid because my build version is indeed diferent that the one on the runtime, I'll solve that to avoid further Bugs.
Thanks your input Guys!
As Henry stated, it's likely to be a version conflict. I had a similar problem which was solved with this thread's help. It suggests you downgrade some dependencies version, but in my case, we solved it changing back our server to Tomcat.
I want to retrieve google app engine textsearch data from local machine by setting the namespace and application id to search API. But my code is pulling the local machine data instead of pulling production data. Below is my code. Can anyone please suggest, any mistake in my code.
NamespaceManager.set("my_name_space");
SearchServiceConfig config = SearchServiceConfig.newBuilder().setNamespace("my_name_space").build();
AdminSearchServiceFactory searchServiceFactory = new AdminSearchServiceFactory();
final SearchService searchService = searchServiceFactory.getSearchService("my_app_id", config);
GetResponse<Index> response2 = searchService.getIndexes(GetIndexesRequest.newBuilder());
for (Index index : response2)
{
System.out.println("index name---" + index.getName());
System.out.println("namespace---" + index.getNamespace());
}
From above code I am expecting the existed indexes from production environment, but my code is giving local machine indexes.
I would suggest you to try the Remote Client Api or Google Cloud Endpoints, as seems to be useful for the issue you are facing.
Hope this helps.
[1] https://cloud.google.com/appengine/docs/standard/java/tools/remoteapi
[2] https://cloud.google.com/endpoints/docs/
I'm (new at this) developing a macro plugin that builds on data that an existing plugin provides via its REST API. They would run on the same instance of Confluence, version 5.9.
I cannot use the Java API of the plugin, since it only provides access to a very limited amount of classes, so I decided on using Rest.
Given that the user has already authenticated with Confluence, is there any way to communicate my current user credentials from my plugins Java Rest client to the other one, preferably not using Basic Authentication?
So far, I've tried:
Shared Access Layer - this apparently used to work with the method Request#addTrustedTokenAuthentication() but is deprecated in SAL 3.0.5,
see SAL Documentation (outdated?), and SAL Version Matrix
ApplicationLink - would allow me to link to another application, but apparently it's not possible to link back to the same Confluence instance
SAL TrustedRequestFactory- comments on this atlassian answer indicate there might be a way using this, but I can't seem to figure it out (yet).
I've also tried reading up on atlassian documentation and posted a similar question on atlassian answers here. I don't mean to double post, but unfortunately, looking at other questions on that platform, few seem to get answered in a timely fashion so I thought I'd try my luck here.
Seems like this isn't a very common problem, but I thought I'd post how we eventually solved this, just in case it's needed again:
#Component
public class RestClient {
#ComponentImport
private TrustedTokenFactory tokenFactory;
// [...]
public String doRequest(HttpClient client, String url) throws Exception {
TrustedTokenAuthenticator auth =
new TrustedTokenAuthenticator(tokenFactory);
HttpMethod method = auth.makeMethod(client, url);
try {
// add request headers, etc...
int statusCode = client.executeMethod(method);
// be sure to use response data here, catch exceptions...
} finally {
method.releaseConnection();
}
}
}
I am developing an Java application using Netbeans which will fetch reports from the BI server on OBIEE 10G and display it to the client using the Java application. Can anyone suggest me appropriate steps to do this and also how to begin with it.
First of all, you will fetch the report from Presentation Services and not from BI server. BI server is a database with only SELECT statement whereas Presentation Service uses this SELECT to create and format reports.
To integrate report from BI Presentation service within a other application, you can use:
the web services: http://docs.oracle.com/cd/E23943_01/bi.1111/e16364/methods.htm#i1008939
or the GO Url: http://docs.oracle.com/cd/E23943_01/bi.1111/e16364/apiwebintegrate.htm#CACCHBHC
The links goes to the same documentation (Integrator's Guide). This is written for 11g but it will also works in 10g.
Cheers
Nico
Your question is not clear; Are you trying to invoke a Java method from OBIEE?
If yes:
You can do this by creating an Agent which is linked to an Action. The Action can invoke a java method(in an EJB). By hooking the Agent to the Action, you can schedule it as a job.
While it is possible to use the webservices and the GO url to create your web app, it is a very hard way to do so. If you have a choice, use the latest JDeveloper 11g and then, use these steps to drag and drop your Answers Reports or Dashboards to the .jspx page. It's simple, can be done in minutes rather than days provided you are familiar with JDeveloper.
EDIT: If you still want to use Netbeans, here's a snippet of code to get you started. Remember to read and understand the HtmlViewService SOAP API in the OBIEE integration doc before taking it to production.
import oracle.bi.services.soap.*
SAWSessionParameters sessionParams = new SAWSessionParameters();
sessionParams.setUserAgent("Mozilla/...."); //Copy the exact agent from your Firefox menu Help > About
javax.xml.rpc.ServiceFactory factory = ServiceFactory.newInstance();
SAWSessionServiceSoap sessionService = ((SAWSessionService) factory.loadService(SAWSessionService.class)).getSAWSessionServiceSoap();
HtmlViewServiceSoap htmlService = ((HtmlViewService) factory.loadService(HtmlViewService.class)).getHtmlViewService();
AuthResult authResult = sessionService.logonex("replace_with_your_username", "replace_with_your_password", sessionParams); //You should reuse the session for multiple HTTP Requests from the same user
String sessionID = authResult.getSessionID();
StartPageParams pageParams = new StartPageParams();
pageParams.setIdsPrefix("replace_with_your_prefix");
String pageID = htmlService.startPage(pageParams, sessionID);
ReportRef report = new ReportRef();
report.setReportPath("replace_with_full_path_to_your_report");
htmlService.addReportToPage(pageID, "replace_with_your_report_name", report, null, null, null, sessionID);
String reportHTML = htmlService.getHtmlForReport(pageID, "replace_with_your_report_name", sessionID);
System.out.println(reportHTML); //Here's the report that you are looking for
htmlService.endPage(pageID, sessionID);
Greetings,
I am creating a Java based server to create push notifications for Apple's iOS APNs service. I have found Javapns on google code which seems to provide a simple basic framework to communicate with APNs, and which seems to be fairly wide used.
http://code.google.com/p/javapns/
However, reading Apple's docs, there is an "enhanced format" for notifications which supports "expiry" i.e. setting a time (well, in seconds) for a notification to expire if it hasn't yet been delivered. I do not see any way to set this using Javapns, and I am unsure how the APNs service handles expiry of notifications if you do not explicitly set it. So,
Does anyone know how to support the enhanced notification format of APNs specifically how to set the expiry?
Does anyone know how Apple handles notification expiry if it isn't explicitly set?
Does anyone have any suggestions that don't require me to start from scratch, as the server is currently functional as is?
Thanks in advance.
Andrew
I have recently made substantial contributions to the JavaPNS project, which lead to the release of JavaPNS 2.0 a few days ago. That version provides full support for the enhanced notification format, including the ability to set your own expiry.
Sylvain
Nice that you found the java library... to bad you didn't read the docs there.
I'll post some of the highlights below:
The existing code uses the 'Simple notification format' which does not return an error EVER.
See docs at:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html
I've tried updating to the 'Enhanced notification format' which is supposed to return an error, but I'm unable to get any errors back from the APNS. (also in the link above)
With the Enhanced format, the connection isn't being dropped immediately after sending data, but I'm not getting anything back from my socket.getInputSocket.read() call.
This issue will have to be tabled until I have more time to troubleshoot.
(Someone else commented)
Thanks a lot for looking into it.
I got the same result as yours. Maybe it has something to do with Apple Gateway.
So... you could:
1) Build your own
2) Help improve the existing library
3) Try another library like: https://github.com/notnoop/java-apns
4) Do nothing
Enhanced ios push here.
To send a notification, you can do it in three steps:
Setup the connection
ApnsService service =
APNS.newService()
.withCert("/path/to/certificate.p12", "MyCertPassword")
.withSandboxDestination()
.build();
Create and send the message
String payload = APNS.newPayload().alertBody("Can't be simpler than this!").build();
String token = "fedfbcfb....";
service.push(token, payload);
To query the feedback service for inactive devices:
Map<String, Date> inactiveDevices = service.getInactiveDevices();
for (String deviceToken : inactiveDevices.keySet()) {
Date inactiveAsOf = inactiveDevices.get(deviceToken);
...
}