Package org.acegisecurity

Examples of org.acegisecurity.Authentication


        @Override
        public SystemGroovy newInstance(StaplerRequest req, JSONObject data) throws FormException {

            // don't allow unauthorized users to modify scripts
            Authentication a = Hudson.getAuthentication();
            if (Hudson.getInstance().getACL().hasPermission(a, Hudson.RUN_SCRIPTS)) {
                return (SystemGroovy) super.newInstance(req, data);
            } else {
                String secret = data.getString("secret");
                return (SystemGroovy) XSTREAM.fromXML(Secret.decrypt(secret).getPlainText());
View Full Code Here


    public String getMessage() {
        return message;
    }

    public boolean canSubmit() {
        Authentication a = Jenkins.getAuthentication();
        return canSettle(a);
    }
View Full Code Here

    CpsFlowExecution(String script, boolean sandbox, FlowExecutionOwner owner) throws IOException {
        this.owner = owner;
        this.script = script;
        this.sandbox = sandbox;
        this.storage = createStorage();
        Authentication auth = Jenkins.getAuthentication();
        this.user = auth.equals(ACL.SYSTEM) ? null : auth.getName();
    }
View Full Code Here

                logger.debug("Request is to process authentication");
            }

            onPreAuthentication(httpRequest, httpResponse);

            Authentication authResult;

            try {
                authResult = attemptAuthentication(httpRequest);
            } catch (AuthenticationException failed) {
                // Authentication failed
View Full Code Here

        HttpServletRequest httpRequest = (HttpServletRequest) request;
        HttpServletResponse httpResponse = (HttpServletResponse) response;

        if (SecurityContextHolder.getContext().getAuthentication() == null) {
            Authentication rememberMeAuth = rememberMeServices.autoLogin(httpRequest,
                    httpResponse);

            if (rememberMeAuth != null) {
                // Attempt authenticaton via AuthenticationManager
                try {
View Full Code Here

                username = token.substring(0, delim);
                password = token.substring(delim + 1);
            }

            // 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.getName().equals(username)
                || !existingAuth.isAuthenticated()) {
                UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username,
                        password);
                authRequest.setDetails(new WebAuthenticationDetails(
                        httpRequest, false));

                Authentication authResult;

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

                    SecurityContextHolder.getContext().setAuthentication(null);

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

                    return;
                }

                // Authentication success
                if (logger.isDebugEnabled()) {
                    logger.debug("Authentication success: "
                        + authResult.toString());
                }

                SecurityContextHolder.getContext().setAuthentication(authResult);
            }
        }
View Full Code Here

     */
    protected void prepareConnection(HttpURLConnection con, int contentLength)
        throws IOException, AuthenticationCredentialsNotFoundException {
        super.prepareConnection(con, contentLength);

        Authentication auth = SecurityContextHolder.getContext()
                                                   .getAuthentication();

        if ((auth != null) && (auth.getName() != null)
            && (auth.getCredentials() != null)) {
            String base64 = auth.getName() + ":"
                + auth.getCredentials().toString();
            con.setRequestProperty("authorization",
                "Basic " + new String(Base64.encodeBase64(base64.getBytes())));

            if (logger.isDebugEnabled()) {
                logger.debug(
                    "HttpInvocation now presenting via BASIC authentication SecurityContextHolder-derived: "
                    + auth.toString());
            }
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug(
                    "Unable to set BASIC authentication header as SecurityContext did not provide valid Authentication: "
View Full Code Here

            if (provider.supports(toTest)) {
                logger.debug("Authentication attempt using "
                    + provider.getClass().getName());

                Authentication result = null;

                try {
                    result = provider.authenticate(authentication);
                    sessionController.checkAuthenticationAllowed(result);
                } catch (AuthenticationException ae) {
View Full Code Here

     * principals.
     *
     * @return the username or <code>null</code> if unavailable
     */
    public String getRemoteUser() {
        Authentication auth = getAuthentication();

        if ((auth == null) || (auth.getPrincipal() == null)) {
            return null;
        }

        if (auth.getPrincipal() instanceof UserDetails) {
            return ((UserDetails) auth.getPrincipal()).getUsername();
        }

        return auth.getPrincipal().toString();
    }
View Full Code Here

     * <code>Principal</code>), or <code>null</code> if unavailable.
     *
     * @return the <code>Authentication</code>, or <code>null</code>
     */
    public Principal getUserPrincipal() {
        Authentication auth = getAuthentication();

        if ((auth == null) || (auth.getPrincipal() == null)) {
            return null;
        }

        return auth;
    }
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.