Package java.security

Examples of java.security.Principal


      Object sc = null;
        if (this.loginContext != null) {
          sc = this.securityHelper.getSecurityContext(this.securitydomain);
          if ( sc == null){
            Subject subject = this.loginContext.getSubject();
            Principal principal = null;
            for(Principal p:subject.getPrincipals()) {
              if (this.userName.startsWith(p.getName())) {
                principal = p;
                break;
              }
View Full Code Here


      throw new LoginException("Failed to decode password: "+e.getMessage()); //$NON-NLS-1$
    }
  } 

  protected Principal getIdentity() {
    Principal principal = new SimplePrincipal(this.mappedRole);
    return principal;       
  }
View Full Code Here

  private String getPrincipal() {
    // Retrieve the principal (members of the Group.class)   
    Set principals = subject.getPrincipals(Principal.class);
    Iterator iterator = principals.iterator();
    while (iterator.hasNext()) {
      Principal principal = (Principal) iterator.next();
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, "getPrincipal class = " + principal.getClass().getName());
      // Signed group (empty group that contains a signature)?
      if (principal instanceof JPrincipal) {
        if (logger.isLoggable(BasicLevel.DEBUG))
          logger.log(BasicLevel.DEBUG, "getPrincipal name = " + ((JPrincipal)principal).getName());
        return principal.getName();
      }
    }
    return null;
  }
View Full Code Here

      if (group instanceof JSigned) {
        continue;
      }
      Enumeration e = group.members();
      while (e.hasMoreElements()) {
        Principal p = (Principal) e.nextElement();
        principalRoles.add(p.getName());
      }
    }
    return principalRoles.toArray();
  }
View Full Code Here

       
        assertEquals("@", TeiidLoginContext.getBaseUsername("@")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    private TeiidLoginContext createMembershipService() throws Exception {
      Principal p = Mockito.mock(Principal.class);
      Mockito.stub(p.getName()).toReturn("alreadylogged"); //$NON-NLS-1$
      HashSet<Principal> principals = new HashSet<Principal>();
      principals.add(p);
     
      Subject subject = new Subject(false, principals, new HashSet(), new HashSet());
      SecurityHelper sh = Mockito.mock(SecurityHelper.class);
View Full Code Here

    if (this.request == null)
      return null;
    Object uRoleObj = this.session
        .getAttribute(CacheProvider.USER_PRINCIPAL_CACHE_KEY_PREFIX);
    if (uRoleObj == null) {
      Principal userPrincipal = this.request.getUserPrincipal();
      if (userPrincipal != null) {
        String userName = userPrincipal.getName();
        String cacheName = CacheProvider.USER_PRINCIPAL_CACHE_KEY_PREFIX
            + userName;

        if (this.cacheProvider != null && this.cacheProvider.isAvailable()) {
          uRoleObj = this.cacheProvider.get(cacheName);
View Full Code Here

  }

  @Get
  @Path("userRoles")
  public UserSecurityInfo listCurrentUserRoles() {
    Principal userPrincipal = this.request.getUserPrincipal();
    if (userPrincipal != null) {
      String name = userPrincipal.getName();
      List<Role> roles = this.listUserRoles(name);
      List<String> roleNames = new ArrayList<String>();
      for (Role r : roles)
        roleNames.add(r.getName());
View Full Code Here

   public boolean authorize(String user, Set rolePrincipals)
   {
      if (trace) { log.trace("authorizing user " + user + " for role(s) " + rolePrincipals.toString()); }

      Principal principal = user == null ? null : new SimplePrincipal(user);

      boolean hasRole = realmMapping.doesUserHaveRole(principal, rolePrincipals);

      if (trace) { log.trace("user " + user + (hasRole ? " is " : " is NOT ") + "authorized"); }
View Full Code Here

     * @return true if the bean caller and the bean callee are called by the
     *         same role, false otherwise.
     */
    @PermitAll
    public boolean testCallerPrincipal() {
        Principal principalCaller = sessionContext.getCallerPrincipal();
        return principalCaller.equals(bean.getCallerPrincipal());
    }
View Full Code Here

        // Structure associating a principal with its roles
        Map<Principal, List<Principal>> principals = getRunAsPrincipals();

        // Add principal name
        Principal principal = principals.keySet().iterator().next();
        this.runAsSubject.getPrincipals().add(principal);

        // Add roles for this principal
        Group roles = new JGroup("roles");
        roles.addMember(new JPrincipal(runAsRole));
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.