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);
}
Aggregations