Package com.sun.enterprise.security

Examples of com.sun.enterprise.security.SecurityContext


                    mappedPrincipals[0].getName(), ap);
            Principal p = (Principal) AppservAccessController.doPrivileged(new PrivilegedAction() {
                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");
                    }
                }
            });
            if(p != null){
                return p;
            }
        }
        AppservAccessController.doPrivileged(new PrivilegedAction() {
            public java.lang.Object run() {
                AssertedPrincipalInfo ap = new AssertedPrincipalInfo(mappedPrincipals[0].getName(), pAssrtValues, id, false);
                Subject sub = new Subject();
                SecurityContext securityContext = new SecurityContext(sub);
                SecurityContext.setCurrent(securityContext);               
                sub.getPrivateCredentials().add(ap);
                return null;
            }
        });
View Full Code Here


    }

    public void verifyMessage(SipServletRequest req, String remoteAddrss) {
        ListIterator passertedHeader = req.getHeaders(P_ASSERTED_IDENTITY);
        String id = req.getHeader(PRIVACY);
        SecurityContext sc = SecurityContext.getCurrent();
        Subject subject = sc.getSubject();
        if (sc != null && subject != null) {
            Set<Object> creds = subject.getPrivateCredentials();
            Iterator<Object> iterator = creds.iterator();
            AssertedPrincipalInfo authInfo = null;
            while (iterator.hasNext()) {
View Full Code Here

                nextNonce = "00000001";
            }


            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);
View Full Code Here

            throw cause;
        }
    }

    public static Subject getCurrentSubject() {
        SecurityContext secCtx = SecurityContext.getCurrent();
        Subject subject = secCtx.getSubject();
        return subject;
    }
View Full Code Here

            return;
        }
        if (obj instanceof SecurityContext) {
            SecurityContext.setCurrent((SecurityContext) obj);
        } else if (obj instanceof WebPrincipal) {
            SecurityContext sc = ((WebPrincipal) obj).getSecurityContext();
            SecurityContext.setCurrent(sc);
        }


    }
View Full Code Here

    }

    public static Object getSecurityContext(Principal pc) {
        if (pc instanceof WebPrincipal) {
            SecurityContext sc = ((WebPrincipal) pc).getSecurityContext();
            return sc;
        }
        return null;
    }
View Full Code Here

    public static Object getSecurityContext() {
        return SecurityContext.getCurrent();
    }

    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) {
            secContext = SecurityContext.getDefaultSecurityContext();
        }
        return secContext.getSubject();
    }
View Full Code Here

              }
            }

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

       } catch (Exception le) {
           if (_logger.isLoggable(Level.WARNING)) {
               _logger.warning("Web login failed: " + le.getMessage());
View Full Code Here

        if (_logger.isLoggable(Level.FINE)){
            _logger.fine( "Tomcat callback for authenticate user/password");
            _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.SecurityContext

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.