EX-5.1 2 a2208155zex-5_1.htm EX-5.1
QuickLinks -- Click here to rapidly navigate through this document


Exhibit 5.1

JOHN F. STUART
KENNETH E. MOORE
RYAN J. BARNCASTLE

OF COUNSEL
BARNET REITNER

ASSOCIATE
ALAN P. SMITH

March 19, 2012

VIA OVERNIGHT DELIVERY

Board of Directors
Heritage Oaks Bancorp
545 12th Street
Paso Robles, California 93446

    Re:    Registration Statement on Form S-1

Ladies and Gentlemen:

        At your request, we have examined the Fourth Amendment to Registration Statement on Form S-1 (the "Registration Statement") being filed by Heritage Oaks Bancorp (the "Company") with the Securities & Exchange Commission in connection with the registration under the Securities Act of 1933 of (a) shares of Common Stock, no par value (the "Common Stock"), issued upon the conversion of shares of the Company's Mandatorily Convertible Cumulative Adjustable Rate Perpetual Preferred Stock, Series B, no par value; (b) shares of Convertible Perpetual Preferred Stock, Series C, no par value (the "Series C Preferred Stock") and the shares of Common Stock underlying such shares; and (c) any additional shares of Common Stock or Series C Preferred Stock that become issuable in connection with anti-dilution adjustments as set forth in the terms of the Series C Preferred Stock (collectively, the "Securities").

        In rendering this opinion, we have examined such documents and records as we have deemed relevant. We have assumed the genuineness of all signatures, the authenticity of all documents submitted to us as originals and the conformity to originals of all documents submitted to us as certified or reproduced copies. In addition, we have assumed that (i) the Registration Statement, and any amendments thereto (including post-effective amendments), will have become effective under the Act; (ii) a prospectus supplement will have been prepared and filed with the Securities and Exchange Commission describing the Securities offered thereby; (iii) all Securities will be issued and sold in compliance with applicable federal and state securities laws and in the manner stated in the Registration Statement and the applicable prospectus supplement; and (iv) a definitive purchase, underwriting or similar agreement with respect to any Securities offered will have been duly authorized and validly executed and delivered by the Company and the other parties thereto.

        Based upon the foregoing and such other further review of fact and law as we have deemed necessary or appropriate under the circumstances, we are of the opinion that any Securities consisting of Common Stock or Series C Preferred Stock, when issued and delivered against payment therefore, will be duly and validly issued, fully paid and non-assessable.

        This opinion is issued to you solely for use in connection with the Registration Statement and is not to be quoted or otherwise referred to in any financial statements of the Company or related documents, nor is it to be filed with or furnished to any government agency or other person, without the prior written consent of this firm in each instance.

        This firm hereby consents to the filing of this opinion as an exhibit to the Registration Statement and to the reference to the undersigned under the heading "Legal Matters" therein and in the related


prospectus. In giving such consent, we do not hereby admit that we are in the category of persons whose consent is required under Section 7 of the Securities Act or the rules and regulations of the Commission.

    Very truly yours,

 

 

/s/ STUART -- MOORE

STUART -- MOORE

2




QuickLinks