Search in sources :

Example 1 with AuthServerException

use of org.openecard.binding.tctoken.ex.AuthServerException in project open-ecard by ecsec.

the class TCTokenContext method generateTCToken.

private static TCTokenContext generateTCToken(String data, ResourceContext base) throws InvalidTCTokenException, AuthServerException, InvalidRedirectUrlException, InvalidTCTokenElement, InvalidTCTokenUrlException, SecurityViolationException, UserCancellationException {
    // correct common TCToken shortcomings
    data = TCTokenHacks.fixPathSecurityParameters(data);
    LOG.debug("Cleaned up TCToken:\n{}", data);
    // Parse the TCToken
    TCTokenParser parser = new TCTokenParser();
    List<TCToken> tokens = parser.parse(data);
    if (tokens.isEmpty()) {
        throw new InvalidTCTokenException(NO_TCTOKEN_IN_DATA);
    }
    // Verify the TCToken
    TCToken token = tokens.get(0);
    TCTokenVerifier ver = new TCTokenVerifier(token, base);
    if (ver.isErrorToken()) {
        String minor = ResultMinor.CLIENT_ERROR;
        throw new AuthServerException(token.getComErrorAddressWithParams(minor), ESERVICE_ERROR);
    }
    DynamicContext dynCtx = DynamicContext.getInstance(TR03112Keys.INSTANCE_KEY);
    List<Pair<URL, TlsServerCertificate>> resultPoints = base.getCerts();
    // probably just for tests
    if (!resultPoints.isEmpty()) {
        Pair<URL, TlsServerCertificate> last = resultPoints.get(0);
        dynCtx.put(TR03112Keys.TCTOKEN_URL, last.p1);
    }
    ver.verifyUrlToken();
    return new TCTokenContext(token, base);
}
Also used : URL(java.net.URL) TlsServerCertificate(org.openecard.bouncycastle.tls.TlsServerCertificate) InvalidTCTokenException(org.openecard.binding.tctoken.ex.InvalidTCTokenException) AuthServerException(org.openecard.binding.tctoken.ex.AuthServerException) DynamicContext(org.openecard.common.DynamicContext) Pair(org.openecard.common.util.Pair)

Aggregations

URL (java.net.URL)1 AuthServerException (org.openecard.binding.tctoken.ex.AuthServerException)1 InvalidTCTokenException (org.openecard.binding.tctoken.ex.InvalidTCTokenException)1 TlsServerCertificate (org.openecard.bouncycastle.tls.TlsServerCertificate)1 DynamicContext (org.openecard.common.DynamicContext)1 Pair (org.openecard.common.util.Pair)1