A teenager tried to shoot and kill the Queen during a visit to New Zealand in 1981, classified documents from the country's security services have confirmed.