Package org.uberfire.security.impl.auth

Examples of org.uberfire.security.impl.auth.UserNameCredential


                    return null;
                }
            };
        }

        final UserNameCredential realCredential = UserNameCredential.class.cast( credential );

        if ( !authenticationSource.authenticate( realCredential, securityContext ) ) {
            return new AuthenticationResult() {
                @Override
                public List<String> getMessages() {
                    return new ArrayList<String>( 1 ) {{
                        add( "Invalid credentials." );
                    }};
                }

                @Override
                public AuthenticationStatus getStatus() {
                    return AuthenticationStatus.FAILED;
                }

                @Override
                public Principal getPrincipal() {
                    return null;
                }
            };
        }

        return new AuthenticationResult() {
            @Override
            public List<String> getMessages() {
                return emptyList();
            }

            @Override
            public AuthenticationStatus getStatus() {
                return AuthenticationStatus.SUCCESS;
            }

            @Override
            public Principal getPrincipal() {
                return new PrincipalImpl( realCredential.getUserName() );
            }
        };
    }
View Full Code Here


    public Credential buildCredential( SecurityContext context) {

        final HttpSecurityContext httpSecurityContext = checkInstanceOf("context", context, HttpSecurityContext.class);

        final String userName = httpSecurityContext.getRequest().getUserPrincipal().getName();
        return new UserNameCredential(userName);
    }
View Full Code Here

    }

    @Override
    public boolean authenticate( final Credential credential,
                                 final SecurityContext securityContext ) {
        final UserNameCredential userNameCredential = checkInstanceOf( "credential", credential, UserNameCredential.class );
        try {
            Subject subject = (Subject) PolicyContext.getContext( "javax.security.auth.Subject.container" );

            if ( subject != null ) {
                Set<java.security.Principal> principals = subject.getPrincipals();

                if ( principals != null ) {
                    for ( java.security.Principal p : principals ) {
                        if ( p.getName().equals( userNameCredential.getUserName() ) ) {
                            return true;
                        }
                    }
                }
            }
View Full Code Here

    @Override
    public boolean authenticate( final Credential credential,
                                 final SecurityContext securityContext ) {
        try {
            final UserNameCredential userNameCredential = checkInstanceOf( "credential", credential, UserNameCredential.class );
            final HttpServletRequest request = ( (HttpSecurityContext) securityContext ).getRequest();

            if ( request.getUserPrincipal() != null ) {
                return true;
            }
            Subject subject = getSubjectFromContainer();
            if ( subject != null ) {
                return super.authenticate( credential, securityContext );
            }

            if ( userNameCredential instanceof UsernamePasswordCredential ) {

                try {
                    request.login( userNameCredential.getUserName(), ( (UsernamePasswordCredential) userNameCredential ).getPassword().toString() );
                    if ( subject == null ) {
                        return true;
                    }
                } catch ( final ServletException ex ) {
                    return false;
View Full Code Here

TOP

Related Classes of org.uberfire.security.impl.auth.UserNameCredential

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.