diff options
author | Endi S. Dewata <edewata@redhat.com> | 2016-02-04 03:09:45 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2016-02-05 16:06:19 +0100 |
commit | 4c1f6b632fe5493ba3bfe106257192d3fc088f15 (patch) | |
tree | 419e418a17be085532db6eea6d8c4b7fd09c3e0a /base/tps | |
parent | b1adc600c4ab63f6069d165b42880ae4f7cc40fc (diff) | |
download | pki-4c1f6b632fe5493ba3bfe106257192d3fc088f15.tar.gz pki-4c1f6b632fe5493ba3bfe106257192d3fc088f15.tar.xz pki-4c1f6b632fe5493ba3bfe106257192d3fc088f15.zip |
Fixed LDAP error handling in TokenService.
The DBSSession has been modified to attach the LDAPException
to the EDBException. The TokenService will catch the EDBException
and obtain the orignal LDAPException. This way the TokenService
can obtain the LDAP error code and throw the proper exception
the client.
https://fedorahosted.org/pki/ticket/1646
Diffstat (limited to 'base/tps')
-rw-r--r-- | base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java index 92ca882fd..1a3a4e96a 100644 --- a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java +++ b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java @@ -45,12 +45,16 @@ import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.BadRequestException; import com.netscape.certsrv.base.IConfigStore; import com.netscape.certsrv.base.PKIException; +import com.netscape.certsrv.dbs.EDBException; +import com.netscape.certsrv.ldap.LDAPExceptionConverter; import com.netscape.certsrv.tps.token.TokenCollection; import com.netscape.certsrv.tps.token.TokenData; import com.netscape.certsrv.tps.token.TokenResource; import com.netscape.certsrv.tps.token.TokenStatus; import com.netscape.cms.servlet.base.PKIService; +import netscape.ldap.LDAPException; + /** * @author Endi S. Dewata */ @@ -280,6 +284,13 @@ public class TokenService extends PKIService implements TokenResource { return createOKResponse(response); + } catch (EDBException e) { + Throwable t = e.getCause(); + if (t != null && t instanceof LDAPException) { + throw LDAPExceptionConverter.toPKIException((LDAPException)t); + } + throw new PKIException(e); + } catch (PKIException e) { throw e; @@ -302,6 +313,13 @@ public class TokenService extends PKIService implements TokenResource { return createOKResponse(createTokenData(database.getRecord(tokenID))); + } catch (EDBException e) { + Throwable t = e.getCause(); + if (t != null && t instanceof LDAPException) { + throw LDAPExceptionConverter.toPKIException((LDAPException)t); + } + throw new PKIException(e); + } catch (PKIException e) { throw e; @@ -348,6 +366,13 @@ public class TokenService extends PKIService implements TokenResource { subsystem.tdb.tdbActivity(ActivityDatabase.OP_ADD, tokenRecord, ipAddress, msg, "failure", remoteUser); + if (e instanceof EDBException) { + Throwable t = e.getCause(); + if (t != null && t instanceof LDAPException) { + throw LDAPExceptionConverter.toPKIException((LDAPException)t); + } + } + if (e instanceof PKIException) { throw (PKIException)e; } @@ -395,6 +420,13 @@ public class TokenService extends PKIService implements TokenResource { ipAddress, msg, "failure", remoteUser); + if (e instanceof EDBException) { + Throwable t = e.getCause(); + if (t != null && t instanceof LDAPException) { + throw LDAPExceptionConverter.toPKIException((LDAPException)t); + } + } + if (e instanceof PKIException) { throw (PKIException)e; } @@ -489,6 +521,13 @@ public class TokenService extends PKIService implements TokenResource { ipAddress, msg, "failure", remoteUser); + if (e instanceof EDBException) { + Throwable t = e.getCause(); + if (t != null && t instanceof LDAPException) { + throw LDAPExceptionConverter.toPKIException((LDAPException)t); + } + } + if (e instanceof PKIException) { throw (PKIException)e; } @@ -546,6 +585,13 @@ public class TokenService extends PKIService implements TokenResource { ipAddress, msg, "failure", remoteUser); + if (e instanceof EDBException) { + Throwable t = e.getCause(); + if (t != null && t instanceof LDAPException) { + throw LDAPExceptionConverter.toPKIException((LDAPException)t); + } + } + if (e instanceof PKIException) { throw (PKIException)e; } @@ -589,6 +635,13 @@ public class TokenService extends PKIService implements TokenResource { ipAddress, msg, "failure", remoteUser); + if (e instanceof EDBException) { + Throwable t = e.getCause(); + if (t != null && t instanceof LDAPException) { + throw LDAPExceptionConverter.toPKIException((LDAPException)t); + } + } + if (e instanceof PKIException) { throw (PKIException)e; } |