title

fire chief's random developer tidbits

Thursday, July 25, 2013

Spring security default https port 8443 and Glassfish

Glassfish and Spring Security have different default ports for https traffic 8181 vs 8443.  To get that working right in a development environment I did the following:

pom.xml:
    <properties>
        <http.port>8080</http.port>
        <http.port>8181</http.port>
    </properties>

    <build>
        <resources>
             <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </reources>
...

       <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webResources>
                        <resource>
                            <filtering>true</filtering>
                            <directory>src/main/resources/WEB-INF/context</directory>
                            <targetPath>WEB-INF/context</targetPath>
                            <includes>
                                <include>applicationContext.xml</include>
                                <include>applicationContext-security.xml</include>
                                <include>datasourceContext.xml</include>
                            </includes>
                        </resource>
...
                


    <profiles>
        <profile>
            <id>production</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <http.port>80</http.port>
                <https.port>443</https.port>
            </properties>
        </profile>


applicationContext-security.xml:
    <http>
        <intercept-url pattern="/" access="permitAll" requires-channel="https"/>
        <intercept-url pattern="/**" access="hasRole('USER')" requires-channel="https" />
        <port-mappings>
            <port-mapping http="${http.port}" https="${https.port}"/>
        </port-mappings>
    </http>

Part of the answer came from here about moving context files to resources though I am using Netbeans, so I didn't have to worry about m2e problems he had.

No comments:

Post a Comment