Characterizations of UFD and Euclidean domain by ideal-theoretic conditions
Dear Arturo,
The exercise in question is actually a theorem of Kaplansky. It appears as Theorem 5 on page 4 of his Commutative Rings. [I was not able to tell easily whether the result appears for the first time in this book.] The proof is reproduced in Section 10 of an expository article I have written [but probably not yet finished] on factorization in integral domains:
http://math.uga.edu/~pete/factorization.pdf
Regarding your second question, there has been some work on understanding Euclidean domains from more intrinsic perspectives. Two fundamental articles are:
Motzkin, Th. The Euclidean algorithm. Bull. Amer. Math. Soc. 55, (1949). 1142--1146.
http://math.uga.edu/~pete/Motzkin49.pdf
Samuel, Pierre About Euclidean rings. J. Algebra 19 1971 282--301.
http://math.uga.edu/~pete/Samuel-Euclidean.pdf
I have not had the chance to digest these papers, so I'm not sure if they directly answer your question (maybe not, but I think they will be helpful).
Although Pete Clark's answer is great, I thought I'd post a partial answer that addresses the UFD question in a different direction. My favorite ideal-theoretic characterization of UFDs is that a domain $R$ is a UFD if and only if every $t$-closed ideal of $R$ is principal. The $t$-closure operation on the fractional ideals of a domain $R$ is given by $$t: I \longmapsto I^t = \bigcup\{(J^{-1})^{-1}: J \subseteq I \mbox{ is a finitely generated ideal of } R\},$$ where $J^{-1} = (R :_{Q(R)} J)$ and $Q(R)$ is the quotient field of $R$. The $t$-closure operation is a useful closure operation on the fractional ideals of a domain $R$. Krull introduced such $'$-Operations in the 1930s in his book Idealtheorie and some subsequent papers. Today we call them star operations.
A UFD is equivalently a Krull domain with trivial divisor class group. A Krull domain is equivalently an integral domain $R$ such that $(II^{-1})^t = R$ for every nonzero ideal $I$ of $R$. It follows from these two well known results of multiplicative ideal theory that a UFD is equivalently a domain in which every ideal $I$ such that $I^t = I$ is principal. I like this characterization because it doesn't mention anything about principal prime ideals or even prime ideals. After all, it is easy to see that a domain $R$ is a UFD if and only if every nonzero principal ideal is a product of principal prime ideals. If you're allowed to mention principal prime ideals in the characterization, then such characterizations are easy to come by.
I would note that the notion of a principal ideal doesn't have a "purely" ideal-theoretic description, since they can't be recovered from the ideal lattice alone. In particular, in my view even the notion of a PID does not have a purely ideal-theoretic description. However, the notion of a Dedekind domain does: a domain $R$ is a Dedekind domain if and only if $II^{-1} = R$ for every nonzero ideal $I$ of $R$. This all hinges on what you mean by ``ideal-theoretic.'' To me it means, can the notion be defined in terms of the ordered monoid of all ideals, or fractional ideals, of the ring. For example, the finitely generated ideals of a commutative ring $R$ have a purely ideal-theoretic description, namely, as the compact elements of the poset of all ideals of $R$.
By the way, a PID is a equivalently a Dedekind domain with trivial ideal class group, and this is generalized by the fact mentioned earlier that a UFD is equivalently a Krull domain with trivial divisor class group.