Package com.sun.enterprise.security.web.integration

Examples of com.sun.enterprise.security.web.integration.WebPrincipal


           if (key != null) {
               DigestCredentials creds = new DigestCredentials(_realmName,key.getUsername(), params);    
               LoginContextDriver.login(creds);
               SecurityContext secCtx = SecurityContext.getCurrent();
               return new WebPrincipal(creds.getUserName(),(char[])null, secCtx);
           } else {
               throw new RuntimeException("No key found in parameters");
           }

       } catch (Exception le) {
View Full Code Here


            _logger.fine("usename = " + username);
        }
        if (authenticate(username, password, null)) {
            SecurityContext secCtx = SecurityContext.getCurrent();
            assert (secCtx != null); // or auth should've failed
            return new WebPrincipal(username, password, secCtx);
           
        } else {
            return null;
        }
    }
View Full Code Here

    public Principal authenticate(X509Certificate certs[]) {
        if (authenticate(null, null, certs)) {
            SecurityContext secCtx = SecurityContext.getCurrent();
            assert (secCtx != null); // or auth should've failed
            return new WebPrincipal(certs, secCtx);
        } else {
            return null;
        }
    }
View Full Code Here

        //set the appropriate security context
        loginForRunAs(username);
        SecurityContext secCtx = SecurityContext.getCurrent();
        _logger.log(Level.FINE, "Security context is " + secCtx);
        assert (secCtx != null);
        Principal principal = new WebPrincipal(username, (char[])null, secCtx);
        _logger.log(Level.INFO, "Principal created for FailOvered user " + principal);
        return principal;
    }
View Full Code Here

                !principalSetContainsOnlyAnonymousPrincipal(principalSet)) {

                SecurityContext ctx = new SecurityContext(subject);
                //XXX assuming no null principal here
                Principal p = ctx.getCallerPrincipal();
                WebPrincipal wp = new WebPrincipal(p, ctx);
                try {
                    //XXX Keep it for reference
                    /*
                    if (this.sAC.managesSessions(sharedState)) {
                    // registration (via proxy) does not occur
View Full Code Here

            //if (method.equals("GET") || rawAuthInfo == null) {
                authenticated = true;
                return true;
            }

            WebPrincipal webPrincipal = null;
            String endpointName = endpoint.getEndpointName();
            if (endpoint.hasBasicAuth() || rawAuthInfo != null) {
                //String rawAuthInfo = hreq.getHeader(AUTHORIZATION_HEADER);
                if (rawAuthInfo == null) {
                    sendAuthenticationEvents(false, hreq.getRequestURI(), null);
                    authenticated = false;
                    return false;
                }

                List<Object> usernamePassword =
                        parseUsernameAndPassword(rawAuthInfo);
                if (usernamePassword != null) {
                    webPrincipal = new WebPrincipal((String)usernamePassword.get(0), (char[])usernamePassword.get(1), SecurityContext.init());
                } else {
                    _logger.log(Level.WARNING, "BASIC AUTH username/password " + "http header parsing error for " + endpointName);
                }
            } else {
                //org.apache.coyote.request.X509Certificate
                X509Certificate certs[] = (X509Certificate[]) hreq.getAttribute(Globals.CERTIFICATES_ATTR);
                if ((certs == null) || (certs.length < 1)) {
                    certs = (X509Certificate[]) hreq.getAttribute(Globals.SSL_CERTIFICATE_ATTR);
                }

                if (certs != null) {
                    webPrincipal = new WebPrincipal(certs, SecurityContext.init());
                } else {
                    _logger.log(Level.WARNING, "CLIENT CERT authentication error for " + endpointName);
                }

            }
View Full Code Here

        final Subject fs = cpCallback.getSubject();
        Principal principal = cpCallback.getPrincipal();
        boolean useName = true;

        if (principal instanceof WebPrincipal) {
            WebPrincipal wp = (WebPrincipal) principal;
            /**
             * Check if the WebPrincipal satisfies the criteria for reuse. If
             * it does, the CBH will have already copied its contents into the
             * Subject, and established the caller principal.
             */
            if (reuseWebPrincipal(fs,wp)) {
                return;
            }
            /**
             * Otherwise the webPrincipal must be distinguished as the
             * callerPrincipal, but the contents of its internal SecurityContext
             * will not be copied.
             * For the special case where the WebPrincipal represents
             * the defaultCallerPrincipal, the argument principal is set to
             * null to cause the handler to assign its representation of the
             * unauthenticated caller in the Subject.
             */
            Principal dp = SecurityContext.getDefaultCallerPrincipal();
            SecurityContext sc = wp.getSecurityContext();
            Principal cp = sc != null ? sc.getCallerPrincipal() : null;

            if (wp.getName() == null || wp.equals(dp) || cp == null || cp.equals(dp)) {
                principal = null;
                useName = false;
            }
        }
       
View Full Code Here

            }

           DigestCredentials creds = new DigestCredentials(_realmName,key.getUsername(), params);    
           LoginContextDriver.login(creds);
           SecurityContext secCtx = SecurityContext.getCurrent();
           return new WebPrincipal(creds.getUserName(),(char[])null, secCtx);

       } catch (Exception le) {
           if (_logger.isLoggable(Level.WARNING)) {
               _logger.log(Level.WARNING,"web.login.failed", le.toString());
            }
View Full Code Here

            _logger.fine("usename = " + username);
        }
        if (authenticate(username, password, null)) {
            SecurityContext secCtx = SecurityContext.getCurrent();
            assert (secCtx != null); // or auth should've failed
            return new WebPrincipal(username, password, secCtx);
           
        } else {
            return null;
        }
    }
View Full Code Here

    public Principal authenticate(X509Certificate certs[]) {
        if (authenticate(null, null, certs)) {
            SecurityContext secCtx = SecurityContext.getCurrent();
            assert (secCtx != null); // or auth should've failed
            return new WebPrincipal(certs, secCtx);
        } else {
            return null;
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.security.web.integration.WebPrincipal

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.