Package org.acegisecurity

Examples of org.acegisecurity.Authentication


import org.acegisecurity.context.SecurityContextHolder;

public class AuthenticationMixin {

    public void authenticate() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Jenkins.getInstance().getSecurityRealm().createSecurityComponents().manager.authenticate(authentication);
    }
View Full Code Here


import org.acegisecurity.context.SecurityContextHolder;

public class AuthenticationService {

    public static void authenticate() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Jenkins.getInstance().getSecurityRealm().createSecurityComponents().manager.authenticate(authentication);
    }
View Full Code Here

        this.orgName = orgName;

    }

    private String getGravatarUrl() {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth instanceof GithubAuthenticationToken) {
            GitHub gh = ((GithubAuthenticationToken) auth).getGitHub();
            try {
                return gh.getOrganization(orgName).getAvatarUrl();
            } catch (IOException e) {
View Full Code Here

        throws org.codehaus.plexus.security.authentication.AuthenticationException
    {
        AcegiAuthenticationDataSource authsource = (AcegiAuthenticationDataSource) source;

        Map tokens = authsource.getTokenMap();
        Authentication authenticationToken = tokenFactory.getAuthenticationToken( tokens );

        try
        {
            Authentication response = manager.doAuthentication( authenticationToken );

            AuthenticationResult authResult = new AuthenticationResult( response.isAuthenticated(), response
                .getPrincipal().toString(), null );

            return authResult;
        }
        catch ( org.acegisecurity.AuthenticationException e )
View Full Code Here

     */
    public void doLogout(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
        HttpSession session = req.getSession(false);
        if(session!=null)
            session.invalidate();
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        SecurityContextHolder.clearContext();

        // reset remember-me cookie
        Cookie cookie = new Cookie(ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY,"");
        cookie.setPath(req.getContextPath().length()>0 ? req.getContextPath() : "/");
View Full Code Here

    protected synchronized String issueCrumb(ServletRequest request, String salt) {
        if (request instanceof HttpServletRequest) {
            if (md != null) {
                HttpServletRequest req = (HttpServletRequest) request;
                StringBuilder buffer = new StringBuilder();
                Authentication a = Jenkins.getAuthentication();
                if (a != null) {
                    buffer.append(a.getName());
                }
                buffer.append(';');
                if (!isExcludeClientIPFromCrumb()) {
                    buffer.append(getClientIP(req));
                }
View Full Code Here

        getXACMLLogger().info(buff.toString());
    }

    private static String authenticationAsString() {

        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth == null)
            return "anonymous";
        String userName = auth.getCredentials() instanceof UserDetails ? ((UserDetails) auth
                .getPrincipal()).getUsername() : auth.getCredentials().toString();
        StringBuffer buff = new StringBuffer(userName);
        buff.append(" [ ");
        for (GrantedAuthority ga : auth.getAuthorities()) {
            buff.append(ga.getAuthority()).append(",");
        }
        if (auth.getAuthorities().length > 0)
            buff.setLength(buff.length() - 1);
        buff.append(" ] ");
        return buff.toString();
    }
View Full Code Here

        poly.setUserData("EPSG:4326");
        readerDetails.setGeometryRestriction(poly);

        GeoXACMLConfig.getXACMLRoleAuthority().transformUserDetails(readerDetails);

        Authentication reader = new TestingAuthenticationToken(readerDetails, "pwreader",
                readerDetails.getAuthorities());
        SecurityContextHolder.getContext().setAuthentication(reader);
        // ///////
        GeoXACMLConfig.getXACMLRoleAuthority().prepareRoles(reader);

        // //////
        XACMLRole readerRole = (XACMLRole) reader.getAuthorities()[0];

        RequestCtx request = GeoXACMLConfig.getRequestCtxBuilderFactory()
                .getResourceInfoRequestCtxBuilder(readerRole, europe, AccessMode.READ)
                .createRequestCtx();
View Full Code Here

            if (authenticationIsRequired(username)) {
                UsernamePasswordAuthenticationToken authRequest =
                        new UsernamePasswordAuthenticationToken(username, password);
                authRequest.setDetails(authenticationDetailsSource.buildDetails((HttpServletRequest) request));

                Authentication authResult;

                try {
                    authResult = authenticationManager.authenticate(authRequest);
                } catch (AuthenticationException failed) {
                    // Authentication failed
                        LOGGER.info("Authentication request for user: " + username + " failed: " + failed.toString());

                    SecurityContextHolder.getContext().setAuthentication(null);

                    if (rememberMeServices != null) {
                        rememberMeServices.loginFail(httpRequest, httpResponse);
                    }

                    if (ignoreFailure) {
                        chain.doFilter(request, response);
                    } else {
                        authenticationEntryPoint.commence(request, response, failed);
                    }

                    return;
                }

                // Authentication success
                    LOGGER.info("Authentication success: " + authResult.toString());

                SecurityContextHolder.getContext().setAuthentication(authResult);
//                System.out.println(
//                    ((UserDetails)SecurityContextHolder.getContext().getAuthentication().getPrincipal())
//                    .getUsername());
View Full Code Here

    }

    private boolean authenticationIsRequired(String username) {
        // Only reauthenticate if username doesn't match SecurityContextHolder and user isn't authenticated
        // (see SEC-53)
        Authentication existingAuth = SecurityContextHolder.getContext().getAuthentication();

        if(existingAuth == null || !existingAuth.isAuthenticated()) {
            return true;
        }

        // Limit username comparison to providers which use usernames (ie UsernamePasswordAuthenticationToken)
        // (see SEC-348)

        if (existingAuth instanceof UsernamePasswordAuthenticationToken && !existingAuth.getName().equals(username)) {
            return true;
        }

        return false;
    }
View Full Code Here

TOP

Related Classes of org.acegisecurity.Authentication

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.