Package org.jboss.security

Examples of org.jboss.security.AuthenticationManager


   /**
    * @inheritDoc
    *
    */
   public synchronized Subject authenticate(Object creds) {
      AuthenticationManager am;
      SecurityContext securityContext;

      // wine and complain if we don't get what we expect.
      if (creds == null) {
         throw new SecurityException(
            "JMXConnectorAuthenticator requires userid/password credentials to be passed in");
      }
      if (! (creds instanceof String[])) {
         // only support passing in array of Strings
         throw new SecurityException(
            "JMXConnectorAuthenticator can only handle authentication parameter that is array of two strings, instead got " +
            creds.getClass().getName());
      }
      String[] pair = (String[]) creds;
      if( pair.length != 2 ) {
         // only support passing userid + password
         throw new SecurityException(
            "JMXConnectorAuthenticator can only handle authentication parameter that is array of two strings, instead got " +
         pair.length +" strings");
      }

      String user, pass;
      user = pair[0];
      pass = pair[1];
      Principal principal = new JMXPrincipal(user);
      Subject subject = new Subject();

      securityContext = SecurityFactory.establishSecurityContext(securityDomainName);
      am = securityContext.getAuthenticationManager();

      boolean result = am.isValid(principal, pass , subject);
      if( result ) {
         subject.setReadOnly();
      }
      else {
         throw new SecurityException("user authentication check failed");
View Full Code Here


   public void setContainer(Container container)
   {
      super.setContainer(container);
      if (container != null)
      {
         AuthenticationManager am = container.getSecurityManager();
         if(am != null)
         {
            securityDomain = am.getSecurityDomain();
         }
      }
      try
      {
         timedObjectMethod = TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class})
View Full Code Here

         of the ejb spec requirement that runtime exceptions should invalidate
         the session.
          */
         if(!callerRunAsIdentityPresent && pushSecurityContext)
         {
            AuthenticationManager am = container.getSecurityManager();
            String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY;
            if(am != null)
               securityDomain = am.getSecurityDomain();
            SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(),
                  securityDomain , null);
            //SecurityActions.pushSubjectContext(mi.getPrincipal(), mi.getCredential(), null);
         }

View Full Code Here

      if(this.securityManagement == null)
         throw new IllegalStateException("SecurityManagement has not been injected");
      Subject subject = new Subject();
      //Validate the caller
      Principal principal = SecurityActions.getPrincipal();
      AuthenticationManager authenticationManager = securityManagement.getAuthenticationManager(securityDomainName);
      if(authenticationManager == null)
      {
         String defaultSecurityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY;
         if(log.isTraceEnabled())
         {
            log.trace("AuthenticationManager for "
                  + securityDomainName + " not found. Using " + defaultSecurityDomain);
         }
         authenticationManager =
            securityManagement.getAuthenticationManager(defaultSecurityDomain);
      }
      if(authenticationManager.isValid(principal,
            SecurityActions.getCredential(), subject) == false)
         throw new SecurityException("Unauthenticated caller:" + principal);
      return subject;
   }
View Full Code Here

   @ManagementOperation(description = "Get the authentication manager for the specified security domain",
         params = {@ManagementParameter(name = "securityDomain", description = "The security domain name")})
   public AuthenticationManager getAuthenticationManager(String securityDomain)
   {
      initialize();
      AuthenticationManager am = null;
      try
      {
         am = this.authMgrMap.get(securityDomain);
         if(am == null)
         {
View Full Code Here

   @ManagementOperation(description = "Create the context for the specified security domain",
         params = {@ManagementParameter(name = "securityDomain", description = "The security domain name")})
   public SecurityDomainContext createSecurityDomainContext(String securityDomain) throws Exception
   {  
      log.debug("Creating SDC for domain="+securityDomain);
      AuthenticationManager am = createAuthenticationManager(securityDomain);
      CachePolicy cache = createDefaultCachePolicy();
      //Set security cache if the auth manager implementation supports it
      setSecurityDomainCache(am, cache);
      //Set DeepCopySubject option if supported
      if(SecurityConfiguration.isDeepCopySubjectMode())
View Full Code Here

            String domainCtx = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + unprefixed + "/domainContext";
            SecurityDomainContext sdc = (SecurityDomainContext) iniCtx.lookup(domainCtx);
            Object securityMgr = sdc.getSecurityManager();

            // Object securityMgr = iniCtx.lookup(confSecurityDomain);
            AuthenticationManager ejbS = (AuthenticationManager) securityMgr;
            RealmMapping rM = (RealmMapping) securityMgr;
            container.setSecurityManager(ejbS);
            container.setRealmMapping(rM);

            container.setSecurityManagement(securityManagement);
View Full Code Here

            {
               javax.naming.Context securityNamingCtx = getSecurityNamingContext();
               if (securityNamingCtx != null)
               {
                  // Get the JBoss security manager from the ENC context
                  AuthenticationManager securityMgr = (AuthenticationManager) securityNamingCtx.lookup("securityMgr");
                  Subject subject = securityMgr.getActiveSubject();
                  request.getRequest().setAttribute(subjectAttributeName, subject);
               }
            }
         }
         catch (Throwable e)
View Full Code Here

            {
               javax.naming.Context securityNamingCtx = getSecurityNamingContext();
               if (securityNamingCtx != null)
               {
                  // Get the JBoss security manager from the ENC context
                  AuthenticationManager securityMgr = (AuthenticationManager) securityNamingCtx.lookup("securityMgr");
                  Subject subject = securityMgr.getActiveSubject();
                  request.getRequest().setAttribute(subjectAttributeName, subject);
               }
            }
         }
         catch (Throwable e)
View Full Code Here

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

TOP

Related Classes of org.jboss.security.AuthenticationManager

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.