Package com.sun.enterprise.security

Examples of com.sun.enterprise.security.SecurityContext


            if (p != null) {
                return p;
            }
        }
        //This is a servlet endpoint
        SecurityContext ctx = SecurityContext.getCurrent();
        if (ctx == null) {
            return null;
        }
        if (ctx.didServerGenerateCredentials()) {
            if (o instanceof WebModule) {
                return null;
            }
        }
        return ctx.getCallerPrincipal();
    }
View Full Code Here


      return (SecurityContext)
    AccessController.doPrivileged(new PrivilegedAction() {
        public Object run() {
      Subject s = new Subject();
      s.getPrincipals().add(p);
      return new SecurityContext(p.getName(),s);
        }
    });
  }
    }
View Full Code Here

            "Container Auth: ServerAuthContext.validateRequest");
        }
 
  Subject subject = null;
  boolean firstAuthentication = true;
  SecurityContext sc = SecurityContext.getCurrent();
  if (sc == null || sc.didServerGenerateCredentials()) {
      subject = new Subject();
  } else {
      subject = sc.getSubject();
      firstAuthentication = false;
  }

  sAC.validateRequest((AuthParam)param, subject, sharedState);

  if (rvalue && firstAuthentication) {
      Set principalSet = subject.getPrincipals();
      // must be at least one new principal to establish
      // non-default security contex
      if (principalSet != null && !principalSet.isEmpty()) {
    // define and add initiator to Subject - note that this may add
    // a second principal (of type PrincipalImpl) for initiator.
    String initiator = ((Principal)principalSet.iterator().next()).
        getName();
    SecurityContext newSC = new SecurityContext(initiator,subject);
    SecurityContext.setCurrent(newSC);
      }
  }

        return rvalue;
View Full Code Here

            "Container Auth: ServerAuthContext.secureResponse");
        }

  // subject may change if runAs identity differs from caller's.
  // Therefore, session state is saved in sharedState not subject
  SecurityContext sc = SecurityContext.getCurrent();
  Subject subject = sc.getSubject();

  SOAPAuthParam param = new SOAPAuthParam(null, response);

        try{
            sAC.secureResponse((AuthParam)param, subject, sharedState);
View Full Code Here

      ClientSecurityContext sc = ClientSecurityContext.getCurrent();
      if (sc != null) {
    subject = sc.getSubject();
      }
  } else {
      SecurityContext sc = SecurityContext.getCurrent();
      if (sc != null && !sc.didServerGenerateCredentials()) {
    // make sure we don't use default unauthenticated subject,
    // so that module cannot change this important (constant)
    // subject.
    subject = sc.getSubject();
      }
  }
  if (subject == null) subject = new Subject();
 
  cAC.secureRequest ( param, subject, sharedState);
View Full Code Here

        NormalizedMessage msg = meTransport.getMessage();
        if(msg == null) return;

        Subject subject = (Subject)msg.getProperty(SECURITY_PROPERTY);
        if(subject != null) {
            SecurityContext sc = new SecurityContext(subject);
            SecurityContext.setCurrent(sc);
        }
    }
View Full Code Here

     * Sets caller principal information.
     */
    private void setCallerPrincipal(
            com.sun.appserv.management.ext.wsmgmt.MessageTraceImpl trace) {

        SecurityContext sc = SecurityContext.getCurrent();
        if (sc != null) {
            Principal p = sc.getCallerPrincipal();
            if (p != null) {
                trace.setPrincipalName( p.getName() );
                _logger.fine("[MTF] Caller Principal: " + p.getName());
            }
        }
View Full Code Here

            throw cause;
        }
    }

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

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

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

                    mappedPrincipals[0].getName(), null);
            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

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.