public Session login() throws RepositoryException {
        assertStateAfterOrEqual(State.CREATED);
        final Session session;
        if (username != null && password != null) {
            session = getRepository().login(new SimpleCredentials(username, password.toCharArray()));
            userSessions.put(username, session);
        } else if (anonSession == null) {
            anonSession = getRepository().login();
            session = anonSession;
        } else {
            session = anonSession;
        }
        return session;
    }
public Session login ( ) throws RepositoryException { assertStateAfterOrEqual ( State . CREATED ) ; final Session session ; if ( username != null && password != null ) { session = getRepository ( ) . login ( new SimpleCredentials ( username , password . toCharArray ( ) ) ) ; userSessions . put ( username , session ) ; } else if ( anonSession == null ) { anonSession = getRepository ( ) . login ( ) ; session = anonSession ; } else { session = anonSession ; } return session ; }
Logs into the repository. If a username and password has been specified, is is used for the login, otherwise an
anonymous login is done.

@return the session for the login
@throws RepositoryException
@throws LoginException