Package org.jboss.metadata.javaee.jboss

Examples of org.jboss.metadata.javaee.jboss.RunAsIdentityMetaData


                  webXmlRunAs = "PLACEHOLDER_FOR_ANNOTATION";
                  //throw new IllegalStateException("run-as-principal: " + principalName + " found in jboss-web.xml but there was no run-as in web.xml");
               }
               // See if there are any additional roles for this principal
               Set<String> extraRoles = securityRoles.getSecurityRoleNamesByPrincipal(principalName);
               RunAsIdentityMetaData runAsId = new RunAsIdentityMetaData(webXmlRunAs, principalName, extraRoles);
               runAsIdentity.put(servletName, runAsId);
            }
            else if (webXmlRunAs != null)
            {
               RunAsIdentityMetaData runAsId = new RunAsIdentityMetaData(webXmlRunAs, null);
               runAsIdentity.put(servletName, runAsId);
            }
         }
      }
   }
View Full Code Here


    }

    @Override
    public void handleRequest(final HttpServerExchange exchange) throws Exception {
        SecurityContext sc = exchange.getAttachment(UndertowSecurityAttachments.SECURITY_CONTEXT_ATTACHMENT);
        RunAsIdentityMetaData identity = null;
        RunAs old = null;
        try {
            final ServletChain servlet = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getCurrentServlet();
            identity = runAsIdentityMetaDataMap.get(servlet.getManagedServlet().getServletInfo().getName());
            RunAsIdentity runAsIdentity = null;
            if (identity != null) {
                UndertowLogger.ROOT_LOGGER.tracef("%s, runAs: %s", servlet.getManagedServlet().getServletInfo().getName(), identity);
                runAsIdentity = new RunAsIdentity(identity.getRoleName(), identity.getPrincipalName(), identity.getRunAsRoles());
            }
            old = SecurityActions.setRunAsIdentity(runAsIdentity, sc);

            // Perform the request
            next.handleRequest(exchange);
View Full Code Here

    public RunAsLifecycleInterceptor(final Map<String, RunAsIdentityMetaData> runAsIdentityMetaDataMap) {
        this.runAsIdentityMetaDataMap = runAsIdentityMetaDataMap;
    }

    private void handle(ServletInfo servletInfo, LifecycleContext context) throws ServletException {
        RunAsIdentityMetaData identity = null;
        RunAs old = null;
        SecurityContext sc = SecurityActions.getSecurityContext();
        if (sc == null) {
            context.proceed();
            return;
        }
        try {
            identity = runAsIdentityMetaDataMap.get(servletInfo.getName());
            RunAsIdentity runAsIdentity = null;
            if (identity != null) {
                UndertowLogger.ROOT_LOGGER.tracef("%s, runAs: %s", servletInfo.getName(), identity);
                runAsIdentity = new RunAsIdentity(identity.getRoleName(), identity.getPrincipalName(), identity.getRunAsRoles());
            }
            old = SecurityActions.setRunAsIdentity(runAsIdentity, sc);

            // Perform the request
            context.proceed();
View Full Code Here

            Wrapper servlet = null;
            try {
                servlet = request.getWrapper();
                if (servlet != null) {
                    String name = servlet.getName();
                    RunAsIdentityMetaData identity = runAsIdentity.get(name);
                    RunAsIdentity runAsIdentity = null;
                    if (identity != null) {
                        WebLogger.WEB_SECURITY_LOGGER.tracef(name + ", runAs: " + identity);
                        runAsIdentity = new RunAsIdentity(identity.getRoleName(), identity.getPrincipalName(),
                                identity.getRunAsRoles());
                    }
                    SecurityActions.pushRunAsIdentity(runAsIdentity);
                }

                // If there is a session, get the tomcat session for the principal
View Full Code Here

            Wrapper servlet = null;
            try {
                servlet = request.getWrapper();
                if (servlet != null) {
                    String name = servlet.getName();
                    RunAsIdentityMetaData identity = metaData.getRunAsIdentity(name);
                    RunAsIdentity runAsIdentity = null;
                    if (identity != null) {
                        log.tracef(name + ", runAs: " + identity);
                        runAsIdentity = new RunAsIdentity(identity.getRoleName(), identity.getPrincipalName(),
                                identity.getRunAsRoles());
                    }
                    SecurityActions.pushRunAsIdentity(runAsIdentity);
                }

                // If there is a session, get the tomcat session for the principal
View Full Code Here

                String roleName = entry.getValue().getRoleName();
                if (principalVersusRolesMap.containsKey(roleName)) {
                    Set<String> principals = principalVersusRolesMap.get(roleName);
                    // assign the first (and probably only) principal as the run as principal
                    String runAsPrincipal = principals.iterator().next();
                    RunAsIdentityMetaData newRunAsIdentity = new RunAsIdentityMetaData(roleName, runAsPrincipal);
                    newRunAs.put(entry.getKey(), newRunAsIdentity);
                }
            }
            if (!newRunAs.isEmpty()) {
                metaData.setRunAsIdentity(newRunAs);
View Full Code Here

            Wrapper servlet = null;
            try {
                servlet = request.getWrapper();
                if (servlet != null) {
                    String name = servlet.getName();
                    RunAsIdentityMetaData identity = metaData.getRunAsIdentity(name);
                    RunAsIdentity runAsIdentity = null;
                    if (identity != null) {
                        if (trace)
                            log.trace(name + ", runAs: " + identity);
                        runAsIdentity = new RunAsIdentity(identity.getRoleName(), identity.getPrincipalName(),
                                identity.getRunAsRoles());
                    }
                    SecurityActions.pushRunAsIdentity(runAsIdentity);
                }

                // If there is a session, get the tomcat session for the principal
View Full Code Here

    * @return RunAsIdentity for the servet if one exists, null otherwise
    */
   @XmlTransient
   public RunAsIdentityMetaData getRunAsIdentity(String servletName)
   {
      RunAsIdentityMetaData identity = runAsIdentity.get(servletName);
      if (identity == null)
      {
         JBossServletsMetaData servlets = getServlets();
         if(servlets != null)
         {
            ServletMetaData servlet = servlets.get(servletName);
            if (servlet != null)
            {
               // Check for a web.xml run-as only specification
               synchronized (runAsIdentity)
               {
                  RunAsMetaData runAs = servlet.getRunAs();
                  if (runAs != null)
                  {
                     String roleName = runAs.getRoleName();
                     identity = new RunAsIdentityMetaData(roleName, null);
                     runAsIdentity.put(servletName, identity);
                  }
               }
            }
         }
View Full Code Here

                  webXmlRunAs = "PLACEHOLDER_FOR_ANNOTATION";
                  //throw new IllegalStateException("run-as-principal: " + principalName + " found in jboss-web.xml but there was no run-as in web.xml");
               }
               // See if there are any additional roles for this principal
               Set<String> extraRoles = securityRoles.getSecurityRoleNamesByPrincipal(principalName);
               RunAsIdentityMetaData runAsId = new RunAsIdentityMetaData(webXmlRunAs, principalName, extraRoles);
               runAsIdentity.put(servletName, runAsId);
            }
            else if (webXmlRunAs != null)
            {
               RunAsIdentityMetaData runAsId = new RunAsIdentityMetaData(webXmlRunAs, null);
               runAsIdentity.put(servletName, runAsId);
            }
         }
      }
   }
View Full Code Here

            Wrapper servlet = null;
            try {
                servlet = request.getWrapper();
                if (servlet != null) {
                    String name = servlet.getName();
                    RunAsIdentityMetaData identity = runAsIdentity.get(name);
                    RunAsIdentity runAsIdentity = null;
                    if (identity != null) {
                        WebLogger.WEB_SECURITY_LOGGER.tracef(name + ", runAs: " + identity);
                        runAsIdentity = new RunAsIdentity(identity.getRoleName(), identity.getPrincipalName(),
                                identity.getRunAsRoles());
                    }
                    SecurityActions.pushRunAsIdentity(runAsIdentity);
                }

                // If there is a session, get the tomcat session for the principal
View Full Code Here

TOP

Related Classes of org.jboss.metadata.javaee.jboss.RunAsIdentityMetaData

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.