Since today morning at about 7 AM ET we started getting FirebaseAuthException for many requests we made in the morning till about 8 AM ET. It stopped for a while but continued again for an hour or so. The error message says Error while verifying signature. However, I am certain of one thing not everybody had a bad token. It has stopped for an hour and half for now. But I wanted to know what caused this.
Here is a top level stack trace if that helps:
Error while verifying signature. at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184):184 at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172):172 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392):392 at java.net.Socket.connect(Socket.java:589):589 at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:673):673 at sun.net.NetworkClient.doConnect(NetworkClient.java:175):175 at sun.net.www.http.HttpClient.openServer(HttpClient.java:463):463 at sun.net.www.http.HttpClient.openServer(HttpClient.java:558):558 at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264):264 at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367):367 at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191):191 at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156):1156 at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050):1050 at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177):177 at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:162):162 at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:104):104 at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:981):981 at com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager.refresh(GooglePublicKeysManager.java:172):172 at com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager.getPublicKeys(GooglePublicKeysManager.java:140):140 at com.google.firebase.auth.internal.FirebaseTokenVerifier.verifySignature(FirebaseTokenVerifier.java:193):193 at com.google.firebase.auth.internal.FirebaseTokenVerifier.verifyTokenAndSignature(FirebaseTokenVerifier.java:161):161 at com.google.firebase.auth.FirebaseAuth$4.execute(FirebaseAuth.java:489):489 at com.google.firebase.auth.FirebaseAuth$4.execute(FirebaseAuth.java:476):476 at com.google.firebase.internal.CallableOperation.call(CallableOperation.java:36):36 at com.google.firebase.auth.FirebaseAuth.verifyIdToken(FirebaseAuth.java:440):440 at com.google.firebase.auth.FirebaseAuth.verifyIdToken(FirebaseAuth.java:414):414 at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source):-1 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43):43 at java.lang.reflect.Method.invoke(Method.java:498):498 at railo.runtime.reflection.pairs.MethodInstance.invoke(MethodInstance.java:37):37 at railo.runtime.reflection.Reflector.callMethod(Reflector.java:699):699 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:742):742 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1480):1480 at cfcs.vendor.firebase.firebaseadminutil_cfc$cf.udfCall(C:\websites\tools\cfcs\vendor\Firebase\FirebaseAdminUtil.cfc:66):66 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215 at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:377):377 at railo.runtime.ComponentImpl._call(ComponentImpl.java:616):616 at railo.runtime.ComponentImpl._call(ComponentImpl.java:502):502 at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1834):1834 at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:769):769 at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1495):1495 at cfcs.axs.borrowersecurity_cfc$cf.udfCall(C:\websites\tools\cfcs\axs\BorrowerSecurity.cfc:441):441 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215 at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434 at railo.runtime.type.UDFImpl.call(UDFImpl.java:384):384 at railo.runtime.ComponentImpl._call(ComponentImpl.java:615):615 at railo.runtime.ComponentImpl._call(ComponentImpl.java:502):502 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1815):1815 at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:733):733 at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1480):1480 at components.application.atlasapplicationhelper_cfc$cf._1(C:\websites\shared\components\application\AtlasApplicationHelper.cfc:84):84 at components.application.atlasapplicationhelper_cfc$cf.udfCall(C:\websites\shared\components\application\AtlasApplicationHelper.cfc):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215 at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:377):377 at railo.runtime.ComponentImpl._call(ComponentImpl.java:616):616 at railo.runtime.ComponentImpl._call(ComponentImpl.java:502):502 at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1834):1834 at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:769):769 at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1495):1495 at application_cfc$cf.udfCall(C:\websites\amcwidgets\application.cfc:25):25 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215 at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434 at railo.runtime.type.UDFImpl.call(UDFImpl.java:384):384 at railo.runtime.ComponentImpl._call(ComponentImpl.java:615):615 at railo.runtime.ComponentImpl._call(ComponentImpl.java:502):502 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1815):1815 at railo.runtime.listener.ModernAppListener.call(ModernAppListener.java:349):349 at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:106):106 at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:23):23 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2035):2035 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2002):2002 at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:297):297 at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:32):32 at javax.servlet.http.HttpServlet.service(HttpServlet.java:820):820 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511):511 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390):390 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216):216 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182):182 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765):765 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440):440 at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:199):199 at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114):114 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152):152 at org.mortbay.jetty.Server.handle(Server.java:326):326 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542):542 at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926):926 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549):549 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212):212 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404):404 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410):410 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582):582
Below is the code that caused this exception. As I am exclusively catching the Invalid Credential error, I have a feeling it has got to be something else.
cffunction name="getDecodedTokenDataFromFirebase" returntype="struct" access="public">
<cfargument name="authToken" type="string" required="true">
<cfscript>
local.return = {};
local.return.bSuccessfulLookup = false;
local.firebaseJavaLoader = request.cfcCache.get('shared.components.util.JavaloaderUtil')
.getFirebaseAdmin660Javaloader();
try {
local.decodedToken = local.firebaseJavaLoader.create('com.google.firebase.auth.FirebaseAuth')
.getInstance()
.verifyIdToken(arguments.authToken);
local.return.uid = local.decodedToken.getUid();
local.return.email = local.decodedToken.getEmail();
local.return.isEmailVerified = local.decodedToken.isEmailVerified().toString();
local.return.additionalData = {};
local.return.additionalData.putAll(local.decodedToken.getClaims());
local.return.bSuccessfulLookup = true;
}
catch(any e) {
if(structKeyExists(e, 'ErrorCode') and e.ErrorCode eq 'ERROR_INVALID_CREDENTIAL'){
local.return.bSuccessfulLookup = false; // just setting it to be doubly sure
}
else {
request.applicationCfc.sendErrorEmail(exception=e);
}
}
return local.return;
</cfscript>
It's a network error. The SDK failed to establish a connection with Google public key servers:
sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264):264 at
sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367):367 at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191):191 at
sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156):1156 at
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050):1050 at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegatHttpsURLConnection.java:177):177 at
sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:162):162 at
com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:104):104 at
com.google.api.client.http.HttpRequest.execute(HttpRequest.java:981):981 at
com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager.refresh(GooglePublicKeysManager.java:172):172 at
com.google.api.client.googleapis.auth.oauth2.GooglePublicKeysManager.getPublicKeys(GooglePublicKeysManager.java:140):140 at
com.google.firebase.auth.internal.FirebaseTokenVerifier.verifySignature(FirebaseTokenVerifier.java:193):193 at
com.google.firebase.auth.internal.FirebaseTokenVerifier.verifyTokenAndSignature(FirebaseTokenVerifier.java:161):161 at
Notice how the GooglePublicKeyManager.refresh() method has encountered a socket connection error.
Related
thanks for taking the time to read this. I'm fairly new to JavaFX and have a weird error in my compiler that I would like some insight on.
Here's the error:
2018-09-13 19:09:36.387 java[8040:660455] unrecognized type is 4294967295
2018-09-13 19:09:36.387 java[8040:660455] *** Assertion failure in -[NSEvent _initWithCGEvent:eventRef:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1652/AppKit.subproj/NSEvent.m:1969
Here is the code I am working with:
This is in a .java file named applicationSettings
public static double lookupUser(String name, String password) throws IOException {
InputStream inputStream = applicationSettings.class.getResourceAsStream("/files/users.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
XSSFSheet sheet = workbook.getSheetAt(0);
Integer lastRow = sheet.getPhysicalNumberOfRows();
int currentRow = 1;
while(currentRow < lastRow) {
if(sheet.getRow(currentRow).getCell(0).getStringCellValue().toLowerCase().equals(name.toLowerCase())) {
if(sheet.getRow(currentRow).getCell(1).getStringCellValue().toLowerCase().equals(password.toLowerCase())) {
double accessLevel = sheet.getRow(currentRow).getCell(2).getNumericCellValue();
System.out.println(accessLevel);
return accessLevel;
}
}
currentRow++;
}
return 4.0;
}
}
This is in a .java file named loginScreen
EventHandler<ActionEvent> loginClicked = new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
double userFound = 0.0;
try {
userFound = applicationSettings.lookupUser(usernameField.getText(), passwordField.getText());
} catch (IOException e) {
e.printStackTrace();
}//END of Try/Catch
if(userFound == 1.0) { //1 is Admin Access
//TODO: Implement Login
System.out.println("Admin Login");
errorLabel.setVisible(false);
}else if(userFound == 2.0){ //2 is Elevated Access
//TODO: Elevated Access
System.out.println("Elevated Login");
errorLabel.setVisible(false);
}else if(userFound == 3.0){
//TODO: Basic Access
System.out.println("Basic Login");
errorLabel.setVisible(false);
}else{//Show Error
errorLabel.setVisible(true);
//TODO: Show Error
}//End If Statement
}
};
My Excel File is basically structured like this:
NAME PASSWORD ACCESS LEVEL
So for my login it would be like:
Trey Carey March3199; 1
This isn't going anywhere besides by church where it's not really doing anything besides automating some tedious tasks, so security isn't an issue.
Also, if there's anyway I can clean up some of these if statements and my code in general I would appreciate any tips or help!
Edit 2 13.11.2018:
This bug has been officially fixed now in JavaFX 12, was backported to JDK8 and approved to be backported to JFX 11. You can have a look at the bug report to find more information about it.JDK-8211304 Here is a link to the changes they've made. openjfx I'm personally not sure about the current license situation of JDK8 so I would advise to switch to the newest OpenJDK and OpenJFX if possible.
Hey there I'm experiencing the same issue you have and I can constantly reproduce it. The issue appears for me on JavaFX on macOS 10.14. You can simply create an application with a button that opens a second stage. If you invoke stage.showAndWait() (could be related to anything that holds the thread) on the second stage and then switch focus between different applications (I just alt-tab between my JavaFX app and Safari), the JavaFX Application crashes. Also reproducible in any IDE.
I actually found a bug report on the OpenJDK/OpenJFX bug tracker but there isn't much going on at the moment. JDK-8211137 Mac: JVM Crash due to uncaught exception
I don't have a solution yet as I'm having troubles pinning down the exact problem but I found a workaround that works in my specific case.
Edit:
If I'm using "stage.show()" I'm only getting the error but when using stage.showAndWait() or anything that does some kind of waiting loop, the application completely crashes.
I am currently attempting to read/write to memory through the use of JNA for Java. For the past week I have tried a multitude of solutions, mostly from [similar projects][1] I have found online, but nothing has resolved my problem.
I know I am receiving the correct process ID of the program, then I create a Pointer using the openProcess method. Then I call getBaseAddress using the newly created Pointer. The problem I believe lies within the EnumProcessModules/Psapi method/class.
Truthfully I am slightly in over my head but this is one of the last issues I am having with this program. My overall goal is to find the base address of the program, use various offsets to access the information I am trying to modify, and then modify it appropriately. The program is 32-bit, which I have seen other people say you need to use a EnumProcessModulesEx method for? but truthfully I am unsure of how/where to implement that.
Any help would be appreciated!
You're getting an Access Denied error because Windows requires you to enable Debug privilege on your current process before accessing the memory of another process. So you will need to both run your program as Administrator, and before you call your OpenProcess code, enable debug privilege.
Here's the JNA code in my application that does this. It's a static method as I only call it once for the entire application:
/**
* Enables debug privileges for this process, required for OpenProcess() to get
* processes other than the current user
*
* #return {#code true} if debug privileges were successfully enabled.
*/
private static boolean enableDebugPrivilege() {
HANDLEByReference hToken = new HANDLEByReference();
boolean success = Advapi32.INSTANCE.OpenProcessToken(Kernel32.INSTANCE.GetCurrentProcess(),
WinNT.TOKEN_QUERY | WinNT.TOKEN_ADJUST_PRIVILEGES, hToken);
if (!success) {
LOG.error("OpenProcessToken failed. Error: {}", Native.getLastError());
return false;
}
try {
WinNT.LUID luid = new WinNT.LUID();
success = Advapi32.INSTANCE.LookupPrivilegeValue(null, WinNT.SE_DEBUG_NAME, luid);
if (!success) {
LOG.error("LookupPrivilegeValue failed. Error: {}", Native.getLastError());
return false;
}
WinNT.TOKEN_PRIVILEGES tkp = new WinNT.TOKEN_PRIVILEGES(1);
tkp.Privileges[0] = new WinNT.LUID_AND_ATTRIBUTES(luid, new DWORD(WinNT.SE_PRIVILEGE_ENABLED));
success = Advapi32.INSTANCE.AdjustTokenPrivileges(hToken.getValue(), false, tkp, 0, null, null);
int err = Native.getLastError();
if (!success) {
LOG.error("AdjustTokenPrivileges failed. Error: {}", err);
return false;
} else if (err == WinError.ERROR_NOT_ALL_ASSIGNED) {
LOG.debug("Debug privileges not enabled.");
return false;
}
} finally {
Kernel32.INSTANCE.CloseHandle(hToken.getValue());
}
return true;
}
I'm not sure from looking at your code whether you also have the right permissions for OpenProcess. Be sure you have the VM_READ permission. Here's what I use, your mileage may vary (I assume you'll need writing permissions as well).
final HANDLE pHandle = Kernel32.INSTANCE.OpenProcess(
WinNT.PROCESS_QUERY_INFORMATION | WinNT.PROCESS_VM_READ,
false, processID);
We're having some trouble trying to implement a Pool of SftpConnections for our application.
We're currently using SSHJ (Schmizz) as the transport library, and facing an issue we simply cannot simulate in our development environment (but the error keeps showing randomly in production, sometimes after three days, sometimes after just 10 minutes).
The problem is, when trying to send a file via SFTP, the thread gets locked in the init method from schmizz' TransportImpl class:
#Override
public void init(String remoteHost, int remotePort, InputStream in, OutputStream out)
throws TransportException {
connInfo = new ConnInfo(remoteHost, remotePort, in, out);
try {
if (config.isWaitForServerIdentBeforeSendingClientIdent()) {
receiveServerIdent();
sendClientIdent();
} else {
sendClientIdent();
receiveServerIdent();
}
log.info("Server identity string: {}", serverID);
} catch (IOException e) {
throw new TransportException(e);
}
reader.start();
}
isWaitForServerIdentBeforeSendingClientIdent is FALSE for us, so first of all the client (we) send our identification, as appears in logs:
"Client identity String: blabla"
Then it's turn for the receiveServerIdent:
private void receiveServerIdent() throws IOException
{
final Buffer.PlainBuffer buf = new Buffer.PlainBuffer();
while ((serverID = readIdentification(buf)).isEmpty()) {
int b = connInfo.in.read();
if (b == -1)
throw new TransportException("Server closed connection during identification exchange");
buf.putByte((byte) b);
}
}
The thread never gets the control back, as the server never replies with its identity. Seems like the code is stuck in this While loop. No timeouts, or SSH exceptions are thrown, my client just keeps waiting forever, and the thread gets deadlocked.
This is the readIdentification method's impl:
private String readIdentification(Buffer.PlainBuffer buffer)
throws IOException {
String ident = new IdentificationStringParser(buffer, loggerFactory).parseIdentificationString();
if (ident.isEmpty()) {
return ident;
}
if (!ident.startsWith("SSH-2.0-") && !ident.startsWith("SSH-1.99-"))
throw new TransportException(DisconnectReason.PROTOCOL_VERSION_NOT_SUPPORTED,
"Server does not support SSHv2, identified as: " + ident);
return ident;
}
Seems like ConnectionInfo's inputstream never gets data to read, as if the server closed the connection (even if, as said earlier, no exception is thrown).
I've tried to simulate this error by saturating the negotiation, closing sockets while connecting, using conntrack to kill established connections while the handshake is being made, but with no luck at all, so any help would be HIGHLY appreciated.
: )
I bet following code creates a problem:
String ident = new IdentificationStringParser(buffer, loggerFactory).parseIdentificationString();
if (ident.isEmpty()) {
return ident;
}
If the IdentificationStringParser.parseIdentificationString() returns empty string, it will be returned to the caller method. The caller method will keep calling the while ((serverID = readIdentification(buf)).isEmpty()) since the string is always empty. The only way to break the loop would be if call to int b = connInfo.in.read(); returns -1... but if server keeps sending the data (or resending the data) this condition is never met.
If this is the case I would add some kind of artificial way to detect this like:
private String readIdentification(Buffer.PlainBuffer buffer, AtomicInteger numberOfAttempts)
throws IOException {
String ident = new IdentificationStringParser(buffer, loggerFactory).parseIdentificationString();
numberOfAttempts.incrementAndGet();
if (ident.isEmpty() && numberOfAttempts.intValue() < 1000) { // 1000
return ident;
} else if (numberOfAttempts.intValue() >= 1000) {
throw new TransportException("To many attempts to read the server ident").
}
if (!ident.startsWith("SSH-2.0-") && !ident.startsWith("SSH-1.99-"))
throw new TransportException(DisconnectReason.PROTOCOL_VERSION_NOT_SUPPORTED,
"Server does not support SSHv2, identified as: " + ident);
return ident;
}
This way you would at least confirm that this is the case and can dig further why .parseIdentificationString() returns empty string.
Faced a similar issue where we would see:
INFO [net.schmizz.sshj.transport.TransportImpl : pool-6-thread-2] - Client identity string: blablabla
INFO [net.schmizz.sshj.transport.TransportImpl : pool-6-thread-2] - Server identity string: blablabla
But on some occasions, there were no server response.
Our service would typically wake up and transfer several files simultaneously, one file per connection / thread.
The issue was in the sshd server config, we increased maxStartups from default value 10
(we noticed the problems started shortly after batch sizes increased to above 10)
Default in /etc/ssh/sshd_config:
MaxStartups 10:30:100
Changed to:
MaxStartups 30:30:100
MaxStartups
Specifies the maximum number of concurrent unauthenticated connections to the SSH daemon. Additional connections will be dropped until authentication succeeds or the LoginGraceTime expires for a connection. The default is 10:30:100. Alternatively, random early drop can be enabled by specifying the three colon separated values start:rate:full (e.g. "10:30:60"). sshd will refuse connection attempts with a probability of rate/100 (30%) if there are currently start (10) unauthenticated connections. The probability increases linearly and all connection attempts are refused if the number of unauthenticated connections reaches full (60).
If you cannot control the server, you might have to find a way to limit your concurrent connection attempts in your client code instead.
Currently I have code that is used to change a password that is stored on an LDAP server. I am using a boolean variable to store the result if the update was successful or not, thereafter I check if the update failed via an if statement and I display an error message.
The issue I'm facing is how can I display more specific errors in the UI if the password change fails?
For example:
The existing password is invalid
The username is incorrect
The account has been locked
If someone could please advise on what could be a nice and tidy solution to my problem. Below is a snippet of the reset password method:
boolean passwordReset = this.userManagement.update(this.username, this.resetPassword, this.resetOldPassword);
if(!passwordReset){
super.addMessage(FacesMessage.SEVERITY_ERROR,super.getResource("password.error"), super.getResource("user.password.change.error"));
} else {
super.addMessage(FacesMessage.SEVERITY_INFO,super.getResource("change.password.head"), super.getResource("password.changed.success"));
}
I think you should modify the userManagement.update method to raise an exception in case of error. So depending on the error it could throw InvalidPasswordException, UsernameException, BlockedAccoutException, etc. or just throw an only exception with a custom message.
In any case, first you need to collect this information from the ldap operation.
Example code:
try {
this.userManagement.update(this.username, this.resetPassword, this.resetOldPassword);
} catch(InvalidPasswordException e) {
super.addMessage(FacesMessage.SEVERITY_ERROR, super.getResource("password.error"), super.getResource("user.password.change.error"));
} catch(UsernameException e) {
super.addMessage(FacesMessage.SEVERITY_ERROR, super.getResource("username.error"), super.getResource("user.name.error"));
} catch(BlockedAccoutException e) {
super.addMessage(FacesMessage.SEVERITY_ERROR, super.getResource("blockaccount.error"), super.getResource(blockaccount.error"));
}
Or:
try {
this.userManagement.update(this.username, this.resetPassword, this.resetOldPassword);
} catch(UpdateUserException e) {
super.addMessage(FacesMessage.SEVERITY_ERROR, super.getResource(e.getErrorCode()));
}
The problem with the first approach is that you have to create several (or a lot) of classes.
This doesn't happen with the second option, but you need a way to get the proper error message. You may add an error type/code to the exception.
Busy trying to Call RPG function from Java and got this example from JamesA. But now I am having trouble, here is my code:
AS400 system = new AS400("MachineName");
ProgramCall program = new ProgramCall(system);
try
{
// Initialise the name of the program to run.
String programName = "/QSYS.LIB/LIBNAME.LIB/FUNNAME.PGM";
// Set up the 3 parameters.
ProgramParameter[] parameterList = new ProgramParameter[2];
// First parameter is to input a name.
AS400Text OperationsItemId = new AS400Text(20);
parameterList[0] = new ProgramParameter(OperationsItemId.toBytes("TestID"));
AS400Text CaseMarkingValue = new AS400Text(20);
parameterList[1] = new ProgramParameter(CaseMarkingValue.toBytes("TestData"));
// Set the program name and parameter list.
program.setProgram(programName, parameterList);
// Run the program.
if (program.run() != true)
{
// Report failure.
System.out.println("Program failed!");
// Show the messages.
AS400Message[] messagelist = program.getMessageList();
for (int i = 0; i < messagelist.length; ++i)
{
// Show each message.
System.out.println(messagelist[i]);
}
}
// Else no error, get output data.
else
{
AS400Text text = new AS400Text(50);
System.out.println(text.toObject(parameterList[1].getOutputData()));
System.out.println(text.toObject(parameterList[2].getOutputData()));
}
}
catch (Exception e)
{
//System.out.println("Program " + program.getProgram() + " issued an exception!");
e.printStackTrace();
}
// Done with the system.
system.disconnectAllServices();
The application Hangs at this lineif (program.run() != true), and I wait for about 10 minutes and then I terminate the application.
Any idea what I am doing wrong?
Edit
Here is the message on the job log:
Client request - run program QSYS/QWCRTVCA.
Client request - run program LIBNAME/FUNNAME.
File P6CASEL2 in library *LIBL not found or inline data file missing.
Error message CPF4101 appeared during OPEN.
Cannot resolve to object YOBPSSR. Type and Subtype X'0201' Authority
FUNNAME insert a row into table P6CASEPF through a view called P6CASEL2. P6CASEL2 is in a different library lets say LIBNAME2. Is there away to maybe set the JobDescription?
Are you sure FUNNAME.PGM is terminating and not hung with a MSGW? Check QSYSOPR for any messages.
Class ProgramCall:
NOTE: When the program runs within the host server job, the library list will be the initial library list specified in the job description in the user profile.
So I saw that my problem is that my library list is not setup, and for some reason, the user we are using, does not have a Job Description. So to over come this I added the following code before calling the program.run()
CommandCall command = new CommandCall(system);
command.run("ADDLIBLE LIB(LIBNAME)");
command.run("ADDLIBLE LIB(LIBNAME2)");
This simply add this LIBNAME, and LIBNAME2 to the user's library list.
Oh yes, the problem is Library list not set ... take a look at this discussion on Midrange.com, there are different work-around ...
http://archive.midrange.com/java400-l/200909/msg00032.html
...
Depe