Package com.sun.web.security

Examples of com.sun.web.security.WebPrincipal


        // This could be an EJB endpoint; check the threadlocal variable
        Switch sw = Switch.getSwitch();
        InvocationManager mgr = sw.getInvocationManager();
        Object o = mgr.getCurrentInvocation().getContainerContext();
        if (o instanceof StatelessSessionContainer) {
            WebPrincipal p = (WebPrincipal) principal.get();
            if (p != null) {
                return p;
            }
        }
        //This is a servlet endpoint
View Full Code Here


        String method = hreq.getMethod();
        if( method.equals("GET") || !endpoint.hasAuthMethod() ) {
            return true;
        }
       
        WebPrincipal webPrincipal = null;
        String endpointName = endpoint.getEndpointName();
       
        if( endpoint.hasBasicAuth() ) {
            String rawAuthInfo = hreq.getHeader(AUTHORIZATION_HEADER);
            if (rawAuthInfo==null) {
                sendAuthenticationEvents(false, hreq.getRequestURI(), null);
                return false;
            }
           
            String[] usernamePassword =
                    parseUsernameAndPassword(rawAuthInfo);
            if( usernamePassword != null ) {
                webPrincipal = new WebPrincipal
                        (usernamePassword[0], usernamePassword[1], SecurityContext.init());
            } else {
                logger.log(Level.WARNING, "BASIC AUTH username/password " +
                           "http header parsing error for " + endpointName);
            }
        } else {

            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

    public Subject getSubject(Principal principal) {
        SecurityContext secContext = null;
        if (principal != null) {
            if (principal instanceof WebPrincipal) {
                WebPrincipal wp = (WebPrincipal) principal;
                secContext = wp.getSecurityContext();
            } else {
                secContext = new SecurityContext(principal.getName(), null);
            }
        }
        if (secContext == null) {
View Full Code Here

            LoginContextDriver.login(creds);
            if(!rp.validateAndCacheNonce(new StringNonce(request.getCallId()))){
                throw new SecurityException("Identity Authentication failed");
            }
            SecurityContext secCtx = SecurityContext.getCurrent();
            return new WebPrincipal(creds.getUserName(), null, secCtx);          
        } catch (LoginException le) {

            securityLogger.log(Level.SEVERE, "Identity Authentication failed", le);
            throw new SecurityException("Identity Authentication failed");
View Full Code Here

                public java.lang.Object run() {
                    try {
                        LoginContextDriver.login(creds);
                        SecurityContext secCtx = SecurityContext.getCurrent();
                        secCtx.getSubject().getPrivateCredentials().add(ap);
                        return new WebPrincipal(creds.getUserName(), null, secCtx);
                    } catch (LoginException ex) {
                        securityLogger.log(Level.SEVERE, "P-Asserted Authentication failed", ex);
                        throw new SecurityException("P-Asserted Authentication failed");
                    }
                }
View Full Code Here


            authInfoHeader = createAuthInfoHeader(request, nextNonce);
            SecurityContext secCtx = SecurityContext.getCurrent();

            return new WebPrincipal(creds.getUserName(), null, secCtx);
        } catch (Exception le) {
            logger.log(Level.SEVERE, "Digest Authentication failed", le);

        //TODO: Log
        }
View Full Code Here

    public static Subject getSubject(Principal principal) {
        SecurityContext secContext = null;
        if (principal != null) {
            if (principal instanceof WebPrincipal) {
                WebPrincipal wp = (WebPrincipal) principal;
                secContext = wp.getSecurityContext();
            } else {
                secContext = new SecurityContext(principal.getName(), null);
            }
        }
        if (secContext == null) {
View Full Code Here

        // to work as expected.

        SecurityContext secCtx = SecurityContext.getCurrent();
        assert (secCtx != null); // since login succeeded above

        WebPrincipal principal = new WebPrincipal(user, password, secCtx);
        req.setUserPrincipal(principal);
        req.setAuthType(WEBAUTH_PROGRAMMATIC);

        if(logger.isLoggable(Level.FINE)){
            logger.log(Level.FINE, "Programmatic login set principal in http request to: "+
View Full Code Here

TOP

Related Classes of com.sun.web.security.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.