public static Header parseHeader(final String jwt) throws Exception {
        try {
            val signedJWT = SignedJWT.parse(jwt);
            return signedJWT.getHeader();
        } catch (final Exception e) {
            val encryptedJWT = EncryptedJWT.parse(jwt);
            return encryptedJWT.getHeader();
        }
    }
Parse header from signed jwt.

@param jwt the jwt
@return the jws header
@throws Exception the exception
support/cas-server-support-token-core-api/src/main/java/org/apereo/cas/token/JwtBuilder.java