jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From connuser1 connuser1 <connus...@gmail.com>
Subject Re: No session returned on repository.login
Date Wed, 26 Sep 2012 09:06:35 GMT
Also below is the complete stack to the point where canAccess returns false:

DefaultAccessManager$WorkspaceAccess.canAccess(String) line: 542
DefaultAccessManager$WorkspaceAccess.access$100(DefaultAccessManager$WorkspaceAccess,
String) line: 512
DefaultAccessManager.canAccess(String) line: 260
DefaultAccessManager.init(AMContext, AccessControlProvider,
WorkspaceAccessManager) line: 154
DefaultSecurityManager.getAccessManager(Session, AMContext) line: 277
XASessionImpl(SessionImpl).createAccessManager(Subject) line: 350
XASessionImpl(SessionImpl).<init>(RepositoryContext, Subject,
WorkspaceConfig) line: 268
XASessionImpl(SessionImpl).<init>(RepositoryContext, AuthContext,
WorkspaceConfig) line: 234
XASessionImpl.<init>(RepositoryContext, AuthContext, WorkspaceConfig) line:
99
RepositoryImpl.createSessionInstance(AuthContext, WorkspaceConfig) line:
1578
RepositoryImpl.createSession(AuthContext, String) line: 947
RepositoryImpl.login(Credentials, String) line: 1477
TransientRepository.login(Credentials, String) line: 381
TransientRepository(AbstractRepository).login(Credentials) line: 123
App.main(String[]) line: 28

On Wed, Sep 26, 2012 at 2:16 PM, connuser1 connuser1 <connuser1@gmail.com>wrote:

> Hi
>
> Thanks for responding to my email! I am copy pasting my login module's
> code below:
>
> package org.sdm.jackrabbitdemo;
>
> import java.security.Principal;
> import java.util.Map;
>
> import javax.jcr.SimpleCredentials;
> import javax.security.auth.Subject;
> import javax.security.auth.callback.Callback;
> import javax.security.auth.callback.CallbackHandler;
> import javax.security.auth.login.LoginException;
> import javax.security.auth.spi.LoginModule;
>
> import org.apache.jackrabbit.api.JackrabbitSession;
> import org.apache.jackrabbit.api.security.user.Authorizable;
> import org.apache.jackrabbit.api.security.user.UserManager;
> import
> org.apache.jackrabbit.core.security.authentication.CredentialsCallback;
> import
> org.apache.jackrabbit.core.security.authentication.RepositoryCallback;
>
> public class DemoLoginModule implements LoginModule {
>
> CallbackHandler callbackHandler;
> Principal myPrincipal;
>  Subject subject;
>
> public boolean abort() throws LoginException {
>  System.out.println("abort called for DemoLoginModule");
> subject.getPrincipals().remove(myPrincipal);
>  return true;
> }
>
> public boolean commit() throws LoginException {
>  System.out.println("commit called for DemoLoginModule");
> if (myPrincipal != null) {
>  subject.getPrincipals().add(myPrincipal);
> myPrincipal = null;
> return true;
>  }
> return true;
> }
>
> public void initialize(Subject subject, CallbackHandler callbackHandler,
> Map<String, ?> sharedState, Map<String, ?> options) {
>  this.callbackHandler = callbackHandler;
> this.subject = subject;
> System.out.println("initialize called for DemoLoginModule");
>  }
>
> public boolean login() throws LoginException {
> System.out.println("login called for DemoLoginModule");
>  // Setup default callback handlers.
> RepositoryCallback repositoryCb = new RepositoryCallback();
>  CredentialsCallback credentialsCb = new CredentialsCallback();
> try {
> callbackHandler
>  .handle(new Callback[] { repositoryCb, credentialsCb });
> SimpleCredentials simpleCredentials = (SimpleCredentials) credentialsCb
>  .getCredentials();
> JackrabbitSession jcrSession = (JackrabbitSession) repositoryCb
>  .getSession();
> UserManager jcrUserManager = jcrSession.getUserManager();
>  Authorizable authorizable = jcrUserManager
> .getAuthorizable(simpleCredentials.getUserID());
>  if (authorizable != null)
> myPrincipal = authorizable.getPrincipal();
>  else {
> System.out.println("User not found, creating a new one");
>  myPrincipal = jcrUserManager.createUser(
> simpleCredentials.getUserID(),
>  new String(simpleCredentials.getPassword()))
> .getPrincipal();
> jcrSession.save();
>  }
> return true;
> } catch (Exception e) {
>  e.printStackTrace();
> throw new LoginException(e.getMessage());
> }
>
> }
>
> public boolean logout() throws LoginException {
>  subject.getPrincipals().remove(myPrincipal);
> System.out.println("logout called for DemoLoginModule");
>  return true;
> }
>
> }
>
>
> On Tue, Sep 25, 2012 at 7:26 PM, Chetan Mehrotra <
> chetan.mehrotra@gmail.com> wrote:
>
>> Looks like you missed attaching the source code of the LoginModule.
>> Can you attach that also?
>> Chetan Mehrotra
>>
>>
>> On Mon, Sep 24, 2012 at 7:02 PM, connuser1 connuser1
>> <connuser1@gmail.com> wrote:
>> > Hi
>> >
>> > I am facing a problem wherein when I login to the repository, I get null
>> > returned as jcrSession. For a background, I have written a Custom JAAS
>> Login
>> > Module for authentication. When a user is trying to login and not found
>> in
>> > the repository, I create the user then and there as follows:
>> >
>> > jcrUserManager.createUser(simpleCredentials.getUserID(),new
>> > String(simpleCredentials.getPassword())) and then add the created users
>> > principal to the subject. This is all happening fine. But when I try to
>> > login using this user, I do not get a session.
>> >
>> > While trying to dig into the jackrabbit source code, I see that
>> > org.apache.jackrabbit.core.RepositoryImpl throws
>> LoginException("Workspace
>> > access denied", ade); on calling SessionImpl session =
>> > createSession(authCtx, workspaceName);
>> >
>> > Attaching my login module and application's soure code.
>> >
>> > Regards
>> > connuser
>>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message