Package javax.jcr

Examples of javax.jcr.Credentials


     */
    public void handle(Callback[] callbacks) throws IOException,
            UnsupportedCallbackException {
        for (Callback cb : callbacks) {
            if (cb instanceof NameCallback) {
                Credentials creds = getCredentials();
                NameCallback nameCallback = (NameCallback) cb;
                if (creds instanceof TrustedCredentials) {
                    nameCallback.setName(((TrustedCredentials) creds)
                            .getPrincipal().getName());
                    return;
                }
            } else if (cb instanceof ImpersonationCallback) {
                Credentials creds = getCredentials();
                ImpersonationCallback impersonationCallback = (ImpersonationCallback) cb;
                if (creds instanceof TrustedCredentials) {
                    impersonationCallback
                            .setImpersonator(((TrustedCredentials) creds)
                                    .getImpersonator());
View Full Code Here


    /**
     * Since the AbstractLoginModule getCredentials does not know anything about TrustedCredentials we have to re-try here.
     */
    @Override
    protected Credentials getCredentials() {
        Credentials creds = super.getCredentials();
        if ( creds == null ) {
            CredentialsCallback callback = new CredentialsCallback();
            try {
                pluggableCallackHander.handle(new Callback[]{callback});
                Credentials callbackCreds = callback.getCredentials();
                if ( callbackCreds instanceof TrustedCredentials ) {
                    creds = callbackCreds;
                }
            } catch (UnsupportedCallbackException e) {
                log.warn("Credentials-Callback not supported try Name-Callback");
View Full Code Here

                    } else {

                        // requested non-admin session to any workspace (or
                        // default)
                        final Credentials credentials = getCredentials(authenticationInfo);
                        session = repository.login(credentials, workspace);

                    }

                } else if (workspace != null) {
View Full Code Here

     * @param authenticationInfo Optional authentication info
     * @return A credentials object or <code>null</code>
     */
    private Credentials getCredentials(final Map<String, Object> authenticationInfo) {

        Credentials creds = null;
        if (authenticationInfo != null) {

            final Object credentialsObject = authenticationInfo.get(JcrResourceConstants.AUTHENTICATION_INFO_CREDENTIALS);

            if (credentialsObject instanceof Credentials) {
View Full Code Here

        s.logout();
    }

    @Test
    public void testExplicitAdminLogin() throws RepositoryException {
        final Credentials creds = new SimpleCredentials("admin", "admin".toCharArray());
        repository.login(creds).logout();
    }
View Full Code Here

        repository.login(creds).logout();
    }

    @Test(expected=RepositoryException.class)
    public void testWrongLogin() throws RepositoryException {
        final Credentials creds = new SimpleCredentials("badName", "badPAssword".toCharArray());
        repository.login(creds);
    }
View Full Code Here

            return "default";
        }

        public Session loginAdministrative(String workspaceName)
                throws RepositoryException {
            final Credentials credentials = new SimpleCredentials(ADMIN_NAME,
                ADMIN_PASSWORD.toCharArray());
            return this.login(credentials, (workspaceName == null ? getDefaultWorkspace() : workspaceName));
        }
View Full Code Here

     *            {@link #getDefaultWorkspace() default workspace}.
     * @return The administrative session
     * @throws RepositoryException if an error occurrs.
     */
    protected Session loginAdministrativeInternal(String workspace) throws RepositoryException {
        Credentials sc = getAdministrativeCredentials(this.adminUser);
        return this.login(sc, workspace);
    }
View Full Code Here

        this.log(LogService.LOG_INFO, "createWorkspace: Requested workspace "
            + workspace + " does not exist, trying to create");

        Session tmpSession = null;
        try {
            Credentials sc = getAdministrativeCredentials(this.adminUser);
            tmpSession = this.getRepository().login(sc);
            Workspace defaultWs = tmpSession.getWorkspace();
            defaultWs.createWorkspace(workspace);
            return true;
        } catch (Throwable t) {
View Full Code Here

    private Repository getRepository() {
      return repository;
    }
   
    private Session createSession() throws RepositoryException {
        final Credentials credentials = new SimpleCredentials("admin",
                "admin".toCharArray());
        return repository.login(credentials, "default");
    }
View Full Code Here

TOP

Related Classes of javax.jcr.Credentials

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.