Examples of RunAsIdentity


Examples of org.jboss.security.RunAsIdentity

                final org.jboss.security.SecurityContext securityContext =
                    SecurityContextFactory.createSecurityContext(principal, credential, subject, securityDomain) ;
                SecurityContextAssociation.setSecurityContext(securityContext) ;
                if ((securityConfig != null) && securityConfig.hasRunAs())
                {
                    securityContext.setOutgoingRunAs(new RunAsIdentity(securityConfig.getRunAs(), principal.getName()));
                }
            }
            catch (final Exception ex)
            {
              throw new RuntimeException("Unexpected exception creating security context", ex) ;
View Full Code Here

Examples of org.jboss.security.RunAsIdentity

   {
      SecurityAssociation.popRunAsIdentity();
   }
   public void pushRunAsRole()
   {
      RunAsIdentity runAs = new RunAsIdentity("SuperUser", "admin");
      SecurityAssociation.pushRunAsIdentity(runAs);
   }
View Full Code Here

Examples of org.jboss.security.RunAsIdentity

    */
   public void testCloneRunAsIdentity() throws Exception
   {
      SimplePrincipal sp1 = new SimplePrincipal("sp1");
      SimplePrincipal sp2 = new SimplePrincipal("sp2");
      RunAsIdentity ras = new RunAsIdentity("testRole", "testUser");
      //There is no need to test the set of run-as roles
      //as each time, a new HashSet is returned
      Set principalSet = ras.getPrincipalsSet();
      principalSet.add(sp1);
      principalSet.add(sp2);
      //Clone
      RunAsIdentity rasClone = (RunAsIdentity)ras.clone();
      principalSet.remove(sp1);
      assertFalse("principalSet.contains(sp1)==false",
            principalSet.contains(sp1));

      Set clonedPrincipalSet = rasClone.getPrincipalsSet();
      assertTrue("clonedPrincipalSet.contains(sp1)",
                     clonedPrincipalSet.contains(sp1));
      assertTrue("clonedPrincipalSet.contains(sp2)",
                     clonedPrincipalSet.contains(sp2));
   }
View Full Code Here

Examples of org.jboss.security.RunAsIdentity

        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

Examples of org.jboss.security.RunAsIdentity

            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

Examples of org.jboss.security.RunAsIdentity

            throw SecurityLogger.ROOT_LOGGER.invalidUserException();
        }

        SecurityContext previous = contexts.peek();
        if (runAs != null) {
            RunAs runAsIdentity = new RunAsIdentity(runAs, runAsPrincipal, extraRoles);
            context.setOutgoingRunAs(runAsIdentity);
        } else if (propagate && previous != null && previous.getOutgoingRunAs() != null) {
            // Ensure the propagation continues.
            context.setOutgoingRunAs(previous.getOutgoingRunAs());
        }
View Full Code Here

Examples of org.jboss.security.RunAsIdentity

    @Resource
    private SessionContext ctx;

    @PermitAll
    public Set<Principal> unchecked() {
        RunAsIdentity rs = (RunAsIdentity) ctx.getCallerPrincipal();
        return rs.getRunAsRoles();
    }
View Full Code Here

Examples of org.jboss.security.RunAsIdentity

        RoleGroup roleGroup = null;

        RunAs runAs = securityContext.getIncomingRunAs();
        if (runAs != null && runAs instanceof RunAsIdentity) {
            RunAsIdentity runAsIdentity = (RunAsIdentity) runAs;
            roleGroup = runAsIdentity.getRunAsRolesAsRoleGroup();
        } else {
            AuthorizationManager am = securityContext.getAuthorizationManager();
            SecurityContextCallbackHandler scb = new SecurityContextCallbackHandler(securityContext);

            roleGroup = am.getSubjectRoles(securityContext.getSubjectInfo().getAuthenticatedSubject(), scb);
View Full Code Here

Examples of org.jboss.security.RunAsIdentity

                throw SecurityMessages.MESSAGES.invalidUserException();
            }
        }

        if (runAs != null) {
            RunAs runAsIdentity = new RunAsIdentity(runAs, runAsPrincipal, extraRoles);
            current.setOutgoingRunAs(runAsIdentity);
        } else if (previous != null && previous.getOutgoingRunAs() != null) {
            // Ensure the propagation continues.
            current.setOutgoingRunAs(previous.getOutgoingRunAs());
        }
View Full Code Here

Examples of org.jboss.security.RunAsIdentity

   /** Push the run as role using the SecurityAssociation.pushRunAsIdentity method
    *@see SecurityAssociation#pushRunAsIdentity(RunAsIdentity)
    */
   public boolean login()
   {
      RunAsIdentity runAsRole = new RunAsIdentity(roleName, principalName);
      SecurityAssociation.pushRunAsIdentity(runAsRole);
      pushedRole = true;
      return true;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.