Glassfish V3.1.1のカスタムレルムを作成しようとしていますが、BASICメソッドでログインするとLoginExceptionが発生します。
[#| 2012-10-11T22:57:21.625 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.authenticator.AuthenticatorBase | _ThreadID = 35; _ThreadName = Thread-2; ClassName = org.apache.catalina.authenticator .AuthenticatorBase; MethodName =invoke;|セキュリティチェックリクエストGET/testForMySimRealm / S1 |#]
[#| 2012-10-11T22:57:21.625 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.authenticator.AuthenticatorBase | _ThreadID = 35; _ThreadName = Thread-2; ClassName = org.apache.catalina.authenticator .AuthenticatorBase; MethodName = invoke; | hasUserDataPermission()|#]の呼び出し
[#| 2012-10-11T22:57:21.625 + 0200 | FINE | glassfish3.1.2 | javax.enterprise.system.container.web.com.sun.web.security | _ThreadID = 35; _ThreadName = Thread-2; ClassName = com.sun.web.security.RealmAdapter; MethodName = hasUserDataPermission; | [Web-Security] [hasUserDataPermission]プリンシパル:null ContextPath:/ testForMySimRealm |#]
[#| 2012-10-11T22:57:21.625 + 0200 | FINE | glassfish3.1.2 | javax.enterprise.system.container.web.com.sun.web.security | _ThreadID = 35; _ThreadName = Thread-2; ClassName = com.sun.web.security.RealmAdapter; MethodName = invokeWebSecurityManager; | [Web-Security] [hasResourcePermission]プリンシパル:null ContextPath:/ testForMySimRealm |#]
[#| 2012-10-11T22:57:21.625 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.authenticator.AuthenticatorBase | _ThreadID = 35; _ThreadName = Thread-2; ClassName = org.apache.catalina.authenticator .AuthenticatorBase; MethodName = invoke; | authenticate()|#]の呼び出し
[#| 2012-10-11T22:57:21.640 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.authenticator.AuthenticatorBase | _ThreadID = 35; _ThreadName = Thread-2; ClassName = org.apache.catalina.authenticator .AuthenticatorBase; MethodName = invoke; | authenticate()テストに失敗しました|#]
[#| 2012-10-11T22:57:21.640 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.connector.OutputBuffer | _ThreadID = 35; _ThreadName = Thread-2; ClassName = org.apache.catalina.connector .OutputBuffer; MethodName = setConverter; |エンコードを取得:ISO-8859-1 |#]
[#| 2012-10-11T22:57:21.640 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.connector.OutputBuffer | _ThreadID = 35; _ThreadName = Thread-2; ClassName = org.apache.catalina.connector .OutputBuffer; MethodName = realWriteBytes; | realWrite(b、0、1073)com.sun.grizzly.tcp.Response@192d307 |#]
[#| 2012-10-11T22:57:21.640 + 0200 | FINEST | glassfish3.1.2 | org.apache.catalina.connector.InputBuffer | _ThreadID = 35; _ThreadName = Thread-2; ClassName = org.apache.catalina.connector .InputBuffer; MethodName = recycle; | recycle()|#]
[#| 2012-10-11T22:57:21.640 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.connector.OutputBuffer | _ThreadID = 35; _ThreadName = Thread-2; ClassName = org.apache.catalina.connector .OutputBuffer; MethodName = recycle; | recycle()|#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.authenticator.AuthenticatorBase | _ThreadID = 36; _ThreadName = Thread-2; ClassName = org.apache.catalina.authenticator .AuthenticatorBase; MethodName =invoke;|セキュリティチェックリクエストGET/testForMySimRealm / S1 |#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.authenticator.AuthenticatorBase | _ThreadID = 36; _ThreadName = Thread-2; ClassName = org.apache.catalina.authenticator .AuthenticatorBase; MethodName = invoke; | hasUserDataPermission()|#]の呼び出し
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | javax.enterprise.system.container.web.com.sun.web.security | _ThreadID = 36; _ThreadName = Thread-2; ClassName = com.sun.web.security.RealmAdapter; MethodName = hasUserDataPermission; | [Web-Security] [hasUserDataPermission]プリンシパル:null ContextPath:/ testForMySimRealm |#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | javax.enterprise.system.container.web.com.sun.web.security | _ThreadID = 36; _ThreadName = Thread-2; ClassName = com.sun.web.security.RealmAdapter; MethodName = invokeWebSecurityManager; | [Web-Security] [hasResourcePermission]プリンシパル:null ContextPath:/ testForMySimRealm |#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.authenticator.AuthenticatorBase | _ThreadID = 36; _ThreadName = Thread-2; ClassName = org.apache.catalina.authenticator .AuthenticatorBase; MethodName = invoke; | authenticate()|#]の呼び出し
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | javax.enterprise.system.container.web.com.sun.web.security | _ThreadID = 36; _ThreadName = Thread-2; ClassName = com.sun.web.security.RealmAdapter; MethodName = authenticate; |ユーザー/パスワードを認証するためのTomcatコールバック|#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | javax.enterprise.system.container.web.com.sun.web.security | _ThreadID = 36; _ThreadName = Thread-2; ClassName = com.sun.web.security.RealmAdapter; MethodName = authenticate; | usename = j |#]
[#| 2012-10-11T22:57:24.625 +0200|警告|glassfish3.1.2| javax.enterprise.system.container.web.com.sun.web.security | _ThreadID = 36; _ThreadName = Thread-2; | WEB9102:Webログインに失敗しました:com.sun.enterprise.security.auth.login.common.LoginException:ログインに失敗しました:EntréeNULLnon valide:nom |#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | javax.enterprise.system.container.web.com.sun.web.security | _ThreadID = 36; _ThreadName = Thread-2; ClassName = com.sun.web.security.RealmAdapter; MethodName = authenticate; |例外com.sun.enterprise.security.auth.login.common.LoginException:ログインに失敗しました:EntréeNULLnon valide:nom at com.sun.enterprise.security .auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:394)at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:240)at com.sun.enterprise.security.auth.login .LoginContextDriver.login(LoginContextDriver.java:153)at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:514)at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:455)at org.apache.catalina.authenticator。BasicAuthenticator.authenticate(BasicAuthenticator.java:169)at com.sun.web.security.RealmAdapter.invokeAuthenticateDelegate(RealmAdapter.java:1333)at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:551)at org .apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:623)at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve .java:161)org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)atcom.sun.enterprise。 v3.services.impl.ContainerMapper $ AdapterCallable.call(ContainerMapper.java:317)(com.sun.enterprise.v3.services.impl.ContainerMapper)。service(ContainerMapper.java:195)at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)at com.sun .grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) )com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain。 java:79)com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)atcom.sun.grizzly.SelectionKeyContextTask。call(SelectionKeyContextTask.java:59)at com.sun.grizzly.ContextTask.run(ContextTask.java:71)at com.sun.grizzly.util.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:532)at com.sun .grizzly.util.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:513)at java.lang.Thread.run(Thread.java:722)原因:javax.security.auth.login.LoginException:EntréeNULLnon valide: nom at javax.security.auth.login.LoginContext.init(LoginContext.java:246)at javax.security.auth.login.LoginContext。(LoginContext.java:382)at javax.security.auth.login.LoginContext。( LoginContext.java:459)at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:381)... 28 more |#]71)com.sun.grizzly.util.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:532)at com.sun.grizzly.util.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:513)at java.lang.Thread .run(Thread.java:722)原因:javax.security.auth.login.LoginException:EntréeNULLnon valide:nom at javax.security.auth.login.LoginContext.init(LoginContext.java:246)atjavax。 security.auth.login.LoginContext。(LoginContext.java:382)at javax.security.auth.login.LoginContext。(LoginContext.java:459)at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin( LoginContextDriver.java:381)... 28 more |#]71)com.sun.grizzly.util.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:532)at com.sun.grizzly.util.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:513)at java.lang.Thread .run(Thread.java:722)原因:javax.security.auth.login.LoginException:EntréeNULLnon valide:nom at javax.security.auth.login.LoginContext.init(LoginContext.java:246)atjavax。 security.auth.login.LoginContext。(LoginContext.java:382)at javax.security.auth.login.LoginContext。(LoginContext.java:459)at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin( LoginContextDriver.java:381)... 28 more |#]run(Thread.java:722)原因:javax.security.auth.login.LoginException:EntréeNULLnon valide:nom at javax.security.auth.login.LoginContext.init(LoginContext.java:246)at javax.security .auth.login.LoginContext。(LoginContext.java:382)at javax.security.auth.login.LoginContext。(LoginContext.java:459)at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver .java:381)... 28 more |#]run(Thread.java:722)原因:javax.security.auth.login.LoginException:EntréeNULLnon valide:nom at javax.security.auth.login.LoginContext.init(LoginContext.java:246)at javax.security .auth.login.LoginContext。(LoginContext.java:382)at javax.security.auth.login.LoginContext。(LoginContext.java:459)at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver .java:381)... 28 more |#]doPasswordLogin(LoginContextDriver.java:381)... 28 more |#]doPasswordLogin(LoginContextDriver.java:381)... 28 more |#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.authenticator.AuthenticatorBase | _ThreadID = 36; _ThreadName = Thread-2; ClassName = org.apache.catalina.authenticator .AuthenticatorBase; MethodName = invoke; | authenticate()テストに失敗しました|#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.connector.OutputBuffer | _ThreadID = 36; _ThreadName = Thread-2; ClassName = org.apache.catalina.connector .OutputBuffer; MethodName = setConverter; |エンコードを取得:ISO-8859-1 |#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.connector.OutputBuffer | _ThreadID = 36; _ThreadName = Thread-2; ClassName = org.apache.catalina.connector .OutputBuffer; MethodName = realWriteBytes; | realWrite(b、0、1073)com.sun.grizzly.tcp.Response@7e592c |#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINEST | glassfish3.1.2 | org.apache.catalina.connector.InputBuffer | _ThreadID = 36; _ThreadName = Thread-2; ClassName = org.apache.catalina.connector .InputBuffer; MethodName = recycle; | recycle()|#]
[#| 2012-10-11T22:57:24.625 + 0200 | FINE | glassfish3.1.2 | org.apache.catalina.connector.OutputBuffer | _ThreadID = 36; _ThreadName = Thread-2; ClassName = org.apache.catalina.connector .OutputBuffer; MethodName = recycle; | recycle()|#]
これが私のレルムクラスです:
CustomSimLoginModuleはAppservPasswordLoginModuleを拡張します:
package com.sim;
import javax.security.auth.login.LoginException;
import com.sun.appserv.security.AppservPasswordLoginModule;
public class CustomSimLoginModule extends AppservPasswordLoginModule {
@Override
protected void authenticateUser() throws LoginException {
// TODO Auto-generated method stub
System.out.println("AUTHENTIFICATION !!");
String[] grpList = {"ADMIN"};
commitUserAuthentication(grpList);
}
}
CustomSimRealmはAppservRealmを拡張します:
package com.sim;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Vector;
import com.sun.appserv.security.AppservRealm;
import com.sun.enterprise.security.auth.realm.BadRealmException;
import com.sun.enterprise.security.auth.realm.InvalidOperationException;
import com.sun.enterprise.security.auth.realm.NoSuchRealmException;
import com.sun.enterprise.security.auth.realm.NoSuchUserException;
public class CustomSimRealm extends AppservRealm {
@Override
public void init(Properties properties) throws BadRealmException, NoSuchRealmException {
System.out.println("CustomSimRealm->init");
Enumeration<?> names = properties.propertyNames();
String name = null;
while(names.hasMoreElements()){
name = (String)names.nextElement();
System.out.println("name->" + name + " value->" + properties.getProperty(name));
}
}
@Override
public String getAuthType() {
return "BASIC";
}
@Override
public Enumeration<String> getGroupNames(String username)
throws InvalidOperationException, NoSuchUserException {
Vector<String> v = new Vector<String>();
v.add("ADMIN");
return v.elements();
}
}
これらの2つのクラスは、Mavenと次の依存関係を持つJARファイルにパッケージ化されています。
<dependency>
<groupId>org.glassfish.main.security</groupId>
<artifactId>security</artifactId>
<version>3.1.2</version>
</dependency>
JARファイルが${GLASSFISH}/ glassfish / domains / domain1 / libディレクトリにコピーされ、login.confを次のように変更しました。
simRealm {
com.sim.CustomSimLoginModule required;
};
およびdomain.xmlwih:
<auth-realm name="sim-realm" classname="com.sim.CustomSimRealm">
<property name="prop1" value="test propriete 1"></property>
<property name="prop2" value="test propriete 2"></property>
<property description="null" name="jaas-context" value="simRealm"></property>
</auth-realm>
Glassfishの開始時に例外はスローされませんが、ユーザーが資格情報を入力すると上記の例外がスローされます。
私は何を間違っているのですか?
PS:Glassfish create-auth-realmコマンドを使用しませんでした。login.confとdomain.xmlを手動で変更しました。これが問題になる可能性がありますか?
アイデアをありがとう
オリヴィエ