Package org.jboss.security

Examples of org.jboss.security.SubjectInfo


  @Override
  public Subject getSubjectInContext(String securityDomain) {
    SecurityContext sc = SecurityActions.getSecurityContext();
    if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
      SubjectInfo si = sc.getSubjectInfo();
      Subject subject = si.getAuthenticatedSubject();
      return subject;
    }   
    return null;
  }
View Full Code Here


        }
    }

    private boolean authenticate(SecurityContext context) {
        SecurityContextUtil util = context.getUtil();
        SubjectInfo subjectInfo = context.getSubjectInfo();
        Subject subject = new Subject();
        Principal principal = util.getUserPrincipal();
        Object credential = util.getCredential();

        boolean authenticated = false;
        if (principal == null) {
            Identity unauthenticatedIdentity = getUnauthenticatedIdentity();
            subjectInfo.addIdentity(unauthenticatedIdentity);
            subject.getPrincipals().add(unauthenticatedIdentity.asPrincipal());
            authenticated = true;
        }

        if (authenticated == false) {
            AuthenticationManager authenticationManager = context.getAuthenticationManager();
            authenticated = authenticationManager.isValid(principal, credential, subject);
        }
        if (authenticated == true) {
            subjectInfo.setAuthenticatedSubject(subject);
        }

        return authenticated;
    }
View Full Code Here

        }
    }

    private boolean authenticate(SecurityContext context) {
        SecurityContextUtil util = context.getUtil();
        SubjectInfo subjectInfo = context.getSubjectInfo();
        Subject subject = new Subject();
        Principal principal = util.getUserPrincipal();
        Object credential = util.getCredential();

        boolean authenticated = false;
        if (principal == null) {
            Identity unauthenticatedIdentity = getUnauthenticatedIdentity();
            subjectInfo.addIdentity(unauthenticatedIdentity);
            subject.getPrincipals().add(unauthenticatedIdentity.asPrincipal());
            authenticated = true;
        }

        if (authenticated == false) {
            AuthenticationManager authenticationManager = context.getAuthenticationManager();
            authenticated = authenticationManager.isValid(principal, credential, subject);
        }
        if (authenticated == true) {
            subjectInfo.setAuthenticatedSubject(subject);
        }

        return authenticated;
    }
View Full Code Here

   @Override
   public Principal getUserPrincipal()
   { 
      validateSecurityContext();
      Principal p = null;
      SubjectInfo subjectInfo = this.securityContext.getSubjectInfo();
      if(subjectInfo != null)
      {
         CredentialIdentity cIdentity = subjectInfo.getIdentity(CredentialIdentity.class);
         p = cIdentity != null ? cIdentity.asPrincipal() : null;
      }
      return p;
   }
View Full Code Here

  
   public Object getCredential()
   {
      validateSecurityContext();
      Object cred = null;
      SubjectInfo subjectInfo = this.securityContext.getSubjectInfo();
      if(subjectInfo != null)
      {
         CredentialIdentity cIdentity = subjectInfo.getIdentity(CredentialIdentity.class);
         cred = cIdentity != null ? cIdentity.getCredential(): null;
      }
      return cred;
   }
View Full Code Here

  
   public Subject getSubject()
   {
      validateSecurityContext();
      Subject s = null;
      SubjectInfo subjectInfo = this.securityContext.getSubjectInfo();
      if(subjectInfo != null)
      {
         s = subjectInfo.getAuthenticatedSubject();
      }
      return s;
   }
View Full Code Here

      {
         Subject theSubject = null;
         SecurityContext sc = SecurityContextAssociation.getSecurityContext();
         if(sc != null)
         {
            SubjectInfo si = sc.getSubjectInfo();
           
            if(si != null)
            {
               Subject activeSubject = si.getAuthenticatedSubject();
               RunAsIdentity callerRunAsIdentity = (RunAsIdentity)sc.getIncomingRunAs();
              
               if( activeSubject != null )
               {
                  Set<Principal> principalsSet = null;
View Full Code Here

        propagator.pushSecurityContext(context, null, securityConfig, as5Operations);

        final org.jboss.security.SecurityContext securityContext = SecurityContextAssociation.getSecurityContext() ;
        assertNotNull("securityContext", securityContext) ;
       
        final SubjectInfo subjectInfo = securityContext.getSubjectInfo() ;
        assertNotNull("subjectInfo", subjectInfo) ;
       
        final Subject pushedSubject = subjectInfo.getAuthenticatedSubject() ;
        assertEquals("Subject comparison", context.getSubject(), pushedSubject);

        propagator.popSecurityContext(context, securityConfig, as5Operations);
        assertNull("securityContext", SecurityContextAssociation.getSecurityContext());
    }
View Full Code Here

        propagator.pushSecurityContext(context, null, null, as5Operations);

        final org.jboss.security.SecurityContext securityContext = SecurityContextAssociation.getSecurityContext() ;
        assertNotNull("securityContext", securityContext) ;
       
        final SubjectInfo subjectInfo = securityContext.getSubjectInfo() ;
        assertNotNull("subjectInfo", subjectInfo) ;
       
        final Subject pushedSubject = subjectInfo.getAuthenticatedSubject() ;
        assertEquals("Subject comparison", context.getSubject(), pushedSubject);

        propagator.popSecurityContext(context, securityConfig, as5Operations);
        assertNull("securityContext", SecurityContextAssociation.getSecurityContext());
    }
View Full Code Here

        }
    }

    private boolean authenticate(SecurityContext context, Subject subject) {
        SecurityContextUtil util = context.getUtil();
        SubjectInfo subjectInfo = getSubjectInfo(context);
        if (subject == null) {
            subject = new Subject();
        }
        Principal principal = util.getUserPrincipal();
        Principal auditPrincipal = principal;
        Object credential = util.getCredential();
        Identity unauthenticatedIdentity = null;

        boolean authenticated = false;
        if (principal == null) {
            unauthenticatedIdentity = getUnauthenticatedIdentity();
            subjectInfo.addIdentity(unauthenticatedIdentity);
            auditPrincipal = unauthenticatedIdentity.asPrincipal();
            subject.getPrincipals().add(auditPrincipal);
            authenticated = true;
        } else {
            subject.getPrincipals().add(principal);
        }

        if (authenticated == false) {
            AuthenticationManager authenticationManager = context.getAuthenticationManager();
            authenticated = authenticationManager.isValid(principal, credential, subject);
        }
        if (authenticated == true) {
            subjectInfo.setAuthenticatedSubject(subject);
        }

        AuditManager auditManager = context.getAuditManager();
        if (auditManager != null) {
            audit(authenticated ? AuditLevel.SUCCESS : AuditLevel.FAILURE, auditManager, auditPrincipal);
View Full Code Here

TOP

Related Classes of org.jboss.security.SubjectInfo

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.