Package java.security

Examples of java.security.Principal


      {
         status = gam.validateRequest(authParam, clientSubject, serviceSubject);
         if(status.equals(AuthStatus.FAILURE))
            throw new SecurityException("Authentication failed");
      }
      Principal authenticatedPrincipal = this.getAuthenticatedPrincipal(clientSubject);
      return null;
      /*
      AuthorizationManager authzManager = getAuthorizationManager();
      Principal callerPrincipal = getAuthenticationManager().getPrincipal(authenticatedPrincipal);
      return getCachingPrincipal(authzManager, authenticatedPrincipal, callerPrincipal, null, clientSubject);
View Full Code Here


      if (userRoles != null)
      {
         Iterator iterator = userRoles.iterator();
         while (iterator.hasNext())
         {
            Principal role = (Principal) iterator.next();
            roles.add(role.getName());
         }
      }
      JBossGenericPrincipal gp = new JBossGenericPrincipal(this, subject,
         authPrincipal, callerPrincipal, credential, roles, userRoles);
      return gp;
View Full Code Here

      {
         if( beanPrincipal == null )
         {   
            RealmMapping rm = con.getRealmMapping();
            SecurityContext sc = SecurityActions.getSecurityContext();
            Principal caller = null;
            try
            {
               caller = SecurityHelperFactory.getEJBAuthorizationHelper(sc).getCallerPrincipal();
            }
            catch (Exception e)
View Full Code Here

        // References to objects we will need later
        Session session = null;

        // Have we already authenticated someone?
        Principal principal = request.getUserPrincipal();
        String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
        if (principal != null) {
            if (log.isDebugEnabled())
                log.debug("Already authenticated '" +
                    principal.getName() + "'");
            // Associate the session with any existing SSO session
            if (ssoId != null)
                associate(ssoId, request.getSessionInternal(true));
            return (true);
        }
View Full Code Here

    * @param certs Array of client certificates, with the first one in the array
    *              being the certificate of the client itself.
    */
   public Principal authenticate(X509Certificate[] certs)
   {
      Principal principal = null;

      try
      {
         // Get the JBoss security manager from the ENC context
         SubjectSecurityManager securityMgr = getSubjectSecurityManager("authenticate(X509Certificate[] certs)");
         if(securityMgr == null)
            return null;
        
         Subject subject = new Subject();
         principal = certMapping.toPrinicipal(certs);
         if (securityMgr.isValid(principal, certs, subject))
         {
            if (trace)
            {
               log.trace("User: " + principal + " is authenticated");
            }
            securityDomain = securityMgr.getSecurityDomain();
            SecurityAssociationActions.setPrincipalInfo(principal, certs, subject);

            // Get the CallerPrincipal mapping
            RealmMapping realmMapping = null;
            if(securityMgr instanceof RealmMapping)
               realmMapping = (RealmMapping)securityMgr;
            else
               realmMapping = getRealmMapping();
           
            if(realmMapping == null)
            {
               log.trace("RealmMapping is null for authenticate(x509 params)");
               return null;
            }
            Principal oldPrincipal = principal;
            principal = realmMapping.getPrincipal(oldPrincipal);
            if (trace)
            {
               log.trace("Mapped from input principal: " + oldPrincipal + "to: " + principal);
            }
View Full Code Here

    *                 ":" + uri)
    */
   public Principal authenticate(String username, String digest, String nonce, String nc, String cnonce, String qop,
         String realm, String md5a2)
   {
      Principal principal = null;

      Principal caller = SecurityAssociationValve.userPrincipal.get();
      if (caller == null && username == null && digest == null)
      {
         return null;
      }

      try
      {
         DigestCallbackHandler handler = new DigestCallbackHandler(username, nonce, nc, cnonce, qop, realm, md5a2);
         CallbackHandlerPolicyContextHandler.setCallbackHandler(handler);

         // Get the JBoss security manager from the ENC context
         SubjectSecurityManager securityMgr = getSubjectSecurityManager("authenticate( digest related)");
         if(securityMgr == null)
            return null;
        
         principal = new SimplePrincipal(username);
         Subject subject = new Subject();
         if (securityMgr.isValid(principal, digest, subject))
         {
            log.trace("User: " + username + " is authenticated");
            securityDomain = securityMgr.getSecurityDomain();
            SecurityAssociationActions.setPrincipalInfo(principal, digest, subject);

            // Get the CallerPrincipal mapping
            RealmMapping realmMapping = null;
            if(securityMgr instanceof RealmMapping)
               realmMapping = (RealmMapping)securityMgr;
            else
               realmMapping = getRealmMapping();
           
            if(realmMapping == null)
            {
               log.trace("RealmMapping is null for authenticate(digest params)");
               return null;
            }
            Principal oldPrincipal = principal;
            principal = realmMapping.getPrincipal(oldPrincipal);
            if (trace)
            {
               log.trace("Mapped from input principal: " + oldPrincipal + "to: " + principal);
            }
View Full Code Here

   {
      if (trace)
      {
         log.trace("Begin authenticate, username=" + username);
      }
      Principal principal = null;

      Principal caller = SecurityAssociationValve.userPrincipal.get();
      if (caller == null && username == null && credentials == null)
      {
         return null;
      }

      try
      {
         // Get the JBoss security manager from the ENC context
         SubjectSecurityManager securityMgr = getSubjectSecurityManager("authenticate(username,cred)");
         if(securityMgr == null)
            return null;
        
         principal = new SimplePrincipal(username);
         Subject subject = new Subject();
         if (securityMgr.isValid(principal, credentials, subject))
         {
            log.trace("User: " + username + " is authenticated");
            securityDomain = securityMgr.getSecurityDomain();
            SecurityAssociationActions.setPrincipalInfo(principal, credentials, subject);
           
            // Get the CallerPrincipal mapping
            RealmMapping realmMapping = null;
            if(securityMgr instanceof RealmMapping)
               realmMapping = (RealmMapping)securityMgr;
            else
               realmMapping = getRealmMapping();
           
            if(realmMapping == null)
            {
               log.trace("RealmMapping is null for authenticate(username,cred)");
               return null;
            }
            Principal oldPrincipal = principal;
            principal = realmMapping.getPrincipal(oldPrincipal);
            if (trace)
            {
               log.trace("Mapped from input principal: " + oldPrincipal + "to: " + principal);
            }
View Full Code Here

      boolean ok = ignoreBaseDecision ? true : super.hasUserDataPermission(request, response, constraints);
      //If the realmbase check has passed, then we can go to authz framework
      if (ok && !ignoreJBossAuthorization)
      {
         Principal requestPrincipal = request.getPrincipal();
         establishSubjectContext(requestPrincipal);
         Map<String, Object> map = new HashMap<String, Object>();
         map.put("securityConstraints", constraints);
         map.put(ResourceKeys.USERDATA_PERM_CHECK, Boolean.TRUE);
View Full Code Here

      if (userRoles != null)
      {
         Iterator<Principal> iterator = userRoles.iterator();
         while (iterator.hasNext())
         {
            Principal role = iterator.next();
            roles.add(role.getName());
         }
      }
      JBossGenericPrincipal gp = new JBossGenericPrincipal(this, subject, authPrincipal, callerPrincipal, credential,
            roles, userRoles);
      return gp;
View Full Code Here

   {
      //Get the active request
      Request request = ActiveRequestResponseCacheValve.activeRequest.get();
      if (request == null)
         throw new IllegalStateException("request is null");
      Principal p = request.getContext().getRealm().authenticate(certs);
      if (p != null)
      {
         register(request, p, null, null);
      }
      return p != null;
View Full Code Here

TOP

Related Classes of java.security.Principal

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.