Package org.uberfire.security

Examples of org.uberfire.security.Subject


    @Override
    public Subject authenticate( final SecurityContext context ) throws AuthenticationException {
        final HttpSecurityContext httpContext = checkInstanceOf( "context", context, HttpSecurityContext.class );

        try {
            final Subject subject = authManager.authenticate( httpContext );
            httpContext.setCurrentSubject( subject );
            return subject;
        } catch ( Exception ex ) {
            throw new AuthenticationException( "Validation fails.", ex );
        }
View Full Code Here


            throws AuthenticationException {
        if ( httpResponse.isCommitted() ) {
            return;
        }

        final Subject subject = securityManager.authenticate( context );
        SecurityFactory.setSubject( subject );
    }
View Full Code Here

    @Test
    public void testAuthorizeWithCacheRefreshOnRemoveAllRoles() {
        RuntimeAuthorizationManager authorizationManager = new RuntimeAuthorizationManager();

        RuntimeResource resource = new TestRuntimeResource("test1234", "author");
        Subject john = new TestIdentity("john", "admin");
        Subject mary = new TestIdentity("mary", "author");

        assertTrue(resource instanceof Cacheable);
        assertTrue(((Cacheable) resource).requiresRefresh());

        boolean authorized = authorizationManager.authorize(resource, john);
View Full Code Here

    @Test
    public void testAuthorizeWithCacheRefreshOnAddedRole() {
        RuntimeAuthorizationManager authorizationManager = new RuntimeAuthorizationManager();

        RuntimeResource resource = new TestRuntimeResource("test1234", "author");
        Subject john = new TestIdentity("john", "admin");
        Subject mary = new TestIdentity("mary", "author");

        assertTrue(resource instanceof Cacheable);
        assertTrue(((Cacheable) resource).requiresRefresh());

        boolean authorized = authorizationManager.authorize(resource, john);
View Full Code Here

    @Test
    public void testAuthorizeWithCacheRefreshOnRemovedRole() {
        RuntimeAuthorizationManager authorizationManager = new RuntimeAuthorizationManager();

        RuntimeResource resource = new TestRuntimeResource("test1234", "admin", "author");
        Subject john = new TestIdentity("john", "admin");
        Subject mary = new TestIdentity("mary", "author");

        assertTrue(resource instanceof Cacheable);
        assertTrue(((Cacheable) resource).requiresRefresh());

        boolean authorized = authorizationManager.authorize(resource, john);
View Full Code Here

        for ( final SubjectPropertiesProvider propertiesProvider : subjectPropertiesProviders ) {
            properties.putAll( propertiesProvider.loadProperties( principal ) );
        }

        final String name = principal.getName();
        final Subject result = new IdentityImpl( name, roles, properties );

        for ( final AuthenticatedStorageProvider storeProvider : authStorageProviders ) {
            storeProvider.store( httpContext, result );
        }
View Full Code Here

        doGet( req, resp );
    }

    private void loadApp( PrintWriter writer,
                          Locale locale ) {
        final Subject subject = SecurityFactory.getIdentity();
        final String localeTag = locale.getLanguage() + "_" + locale.getCountry();

        final Map<String, String> map = new HashMap<String, String>() {{
            put( "name", subject.getName() );
            put( "roles", collectionAsString( subject.getRoles() ) );
            put( "properties", mapAsString( subject.getProperties() ) );
            put( "locale", localeTag );
        }};

        final String content = TemplateRuntime.execute( appTemplate, map ).toString();
View Full Code Here

        final String content = (String) TemplateRuntime.execute( footerTemplate );
        writer.append( content );
    }

    private void loadUserInfo( PrintWriter writer ) {
        final Subject subject = SecurityFactory.getIdentity();

        final Map<String, String> map = new HashMap<String, String>() {{
            put( "name", subject.getName() );
            put( "roles", collectionAsString( subject.getRoles() ) );
            put( "properties", mapAsString( subject.getProperties() ) );
        }};

        final String content = TemplateRuntime.execute( userDataTemplate, map ).toString();

        writer.append( content );
View Full Code Here

TOP

Related Classes of org.uberfire.security.Subject

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.