Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement basic authentication with Glassfish?
    primarykey
    data
    text
    <p>I'm tried this configuration but it didn't work for me. <a href="https://stackoverflow.com/questions/3892870/basic-authentication-in-glassfish">Basic Authentication in Glassfish</a> I also tried this guide <a href="http://maksim.sorokin.dk/it/2010/10/13/basic-authentication-in-glassfish-3/" rel="nofollow noreferrer">http://maksim.sorokin.dk/it/2010/10/13/basic-authentication-in-glassfish-3/</a> but I couldn't get user-pass asking with it too.</p> <p>These are steps I've taken:<br> 1. Login as admin to Admin interface.<br> 2. Go to Security->Realms->File<br> 3. Add a group name (Users) to Assign Groups field.<br> 4. Open manage users at the top of the page.<br> 5. Click New and add an user (testuser) and give a password.<br> 6. Add (Users) to Group List.<br> 7. put this lines to web.xml</p> <pre class="lang-xml prettyprint-override"><code>&lt;security-constraint&gt; &lt;web-resource-collection&gt; &lt;web-resource-name&gt;Secure Application&lt;/web-resource-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;http-method&gt;GET&lt;/http-method&gt; &lt;http-method&gt;POST&lt;/http-method&gt; &lt;/web-resource-collection&gt; &lt;auth-constraint&gt; &lt;role-name&gt;User&lt;/role-name&gt; &lt;/auth-constraint&gt; &lt;/security-constraint&gt; &lt;login-config&gt; &lt;auth-method&gt;BASIC&lt;/auth-method&gt; &lt;realm-name&gt;file&lt;/realm-name&gt; &lt;/login-config&gt; &lt;security-role&gt; &lt;role-name&gt;User&lt;/role-name&gt; &lt;/security-role&gt; </code></pre> <p>8. and put this lines to sun-web.xml</p> <pre class="lang-xml prettyprint-override"><code>&lt;sun-web-app error-url=""&gt; &lt;security-role-mapping&gt; &lt;role-name&gt;User&lt;/role-name&gt; &lt;group-name&gt;Users&lt;/group-name&gt; &lt;/security-role-mapping&gt; &lt;/sun-web-app&gt; </code></pre> <p>9. After all I enabled Configurations->server-config->Security->Security Manager </p> <p>My configuration is Glassfish 3.1, sun java6 jdk, Debian lenny and a simple "Hello World" page for testing.</p> <p>What is missing here?</p> <p>UPDATE:</p> <p>I figured out it needs xml headers. After I've added them it started to work. My final configuration is below:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt; &lt;security-constraint&gt; &lt;web-resource-collection&gt; &lt;web-resource-name&gt;Secure Application&lt;/web-resource-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;http-method&gt;GET&lt;/http-method&gt; &lt;http-method&gt;POST&lt;/http-method&gt; &lt;/web-resource-collection&gt; &lt;auth-constraint&gt; &lt;role-name&gt;Users&lt;/role-name&gt; &lt;/auth-constraint&gt; &lt;/security-constraint&gt; &lt;login-config&gt; &lt;auth-method&gt;BASIC&lt;/auth-method&gt; &lt;realm-name&gt;file&lt;/realm-name&gt; &lt;/login-config&gt; &lt;security-role&gt; &lt;role-name&gt;Users&lt;/role-name&gt; &lt;/security-role&gt; &lt;/web-app&gt; </code></pre> <p>and </p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd"&gt; &lt;sun-web-app error-url=""&gt; &lt;security-role-mapping&gt; &lt;role-name&gt;Users&lt;/role-name&gt; &lt;group-name&gt;Users&lt;/group-name&gt; &lt;/security-role-mapping&gt; &lt;/sun-web-app&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload