private void jMenu2ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenu2ActionPerformed
   // TODO add your handling code here:
   Principal p = new Principal();
   p.setVisible(true);
   dispose();
 } // GEN-LAST:event_jMenu2ActionPerformed
Example #2
0
  //
  // This function is the recursive search of groups for this
  // implementation of the Group. The search proceeds building up
  // a vector of already seen groups. Only new groups are considered,
  // thereby avoiding loops.
  //
  boolean isMemberRecurse(Principal member, Vector<Group> alreadySeen) {
    Enumeration<? extends Principal> e = members();
    while (e.hasMoreElements()) {
      boolean mem = false;
      Principal p = (Principal) e.nextElement();

      // if the member is in this collection, return true
      if (p.equals(member)) {
        return true;
      } else if (p instanceof GroupImpl) {
        //
        // if not recurse if the group has not been checked already.
        // Can call method in this package only if the object is an
        // instance of this class. Otherwise call the method defined
        // in the interface. (This can lead to a loop if a mixture of
        // implementations form a loop, but we live with this improbable
        // case rather than clutter the interface by forcing the
        // implementation of this method.)
        //
        GroupImpl g = (GroupImpl) p;
        alreadySeen.addElement(this);
        if (!alreadySeen.contains(g)) mem = g.isMemberRecurse(member, alreadySeen);
      } else if (p instanceof Group) {
        Group g = (Group) p;
        if (!alreadySeen.contains(g)) mem = g.isMember(member);
      }

      if (mem) return mem;
    }
    return false;
  }
 @Test
 public void checkCreatingSimplePrincipalWithDefaultRepository() {
   final PrincipalFactory f = new DefaultPrincipalFactory();
   final Principal p = f.createPrincipal("uid");
   assertEquals(p.getId(), "uid");
   assertEquals(p.getAttributes().size(), 0);
 }
Example #4
0
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj instanceof MockX509Certificate)
     return subject.equals(((MockX509Certificate) obj).subject)
         && issuer.equals(((MockX509Certificate) obj).issuer);
   return false;
 }
  protected boolean matchGroupPrincipal(List<Principal> groupPrincipals, String userRole) {
    boolean res = false;

    {
      if (groupPrincipals != null) {
        if (userRole != null) {
          for (Principal groupPrincipal : groupPrincipals) {
            if (groupPrincipal instanceof DistinguishedNamePrincipal) {
              DistinguishedNamePrincipal p = (DistinguishedNamePrincipal) groupPrincipal;

              res = matchGroupPrincipal(p, userRole);
            } else {
              if (groupPrincipal instanceof CommonNamePrincipal) {
                CommonNamePrincipal p = (CommonNamePrincipal) groupPrincipal;

                res = matchGroupPrincipal(p, userRole);
              } else {
                String name = groupPrincipal.getName();
                if (name.equals(userRole)) {
                  res = true;
                }
              }
            }

            if (res) // if a match has been found...
            {
              break; // stop loop
            }
          }
        }
      }
    }

    return res;
  }
 private void jMenu2MouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jMenu2MouseClicked
   // TODO add your handling code here:
   Principal p = new Principal();
   p.setVisible(true);
   dispose();
 } // GEN-LAST:event_jMenu2MouseClicked
  /**
   * Load a User for ACEGI given its user name
   *
   * @param username user name
   * @throws org.acegisecurity.userdetails.UsernameNotFoundException
   * @throws org.springframework.dao.DataAccessException
   * @return the user object description as specified by ACEGI
   */
  public UserDetails loadUserByUsername(String username)
      throws UsernameNotFoundException, DataAccessException {
    try {
      Version db = Version.getDatabaseVersion();
      Version code = Version.getApplicationVersion();

      if (db.compareTo(code, Version.MINOR) == 0) {
        log.info("loadUserByUsername - getting user " + username + " using Hibernate");
        User user = userDAO.searchByLogin(username);

        GrantedAuthority[] auths = userRolesService.getAuthorities(user);

        if (log.isDebugEnabled()) {
          StringBuilder sb = new StringBuilder();
          for (GrantedAuthority auth : auths) {
            sb.append(auth);
            sb.append(" ");
          }
          log.debug("loadUserByUsername - user roles: " + sb);
        }

        final Principal principal = new Principal(user, auths);

        // setting user preferred Locale
        final SettingSearch s = new SettingSearch();
        s.setName(SettingPath.GENERAL_PREFERRED_LOCALE);
        s.setOwnerId(user.getId());
        final List<Setting> vals = settings.search(s, null);

        final Setting val = (vals != null && vals.size() > 0) ? vals.get(0) : null;

        if (val != null) {
          final Locale local = new Locale(val.getValue());
          principal.setLocale(local);
        }

        return principal;
      } else {
        log.info("loadUserByUsername - getting user " + username + " using JDBC");
        return jdbcSearchByLogin(username);
      }
    } catch (SecException e) {
      log.warn("loadUserByUsername - exception", e);
      throw new DataRetrievalFailureException("Error getting roles for user: "******"loadUserByUsername - exception", e);
      throw new DataIntegrityViolationException("Inconsistent user name: " + username, e);
    } catch (DataNotFoundException e) {
      log.warn("loadUserByUsername - exception", e);
      throw new UsernameNotFoundException("User not found: " + username, e);
    } catch (DataAccException e) {
      log.warn("loadUserByUsername - exception", e);
      throw new DataRetrievalFailureException("Error getting user: "******"loadUserByUsername - exception", e);
      throw new DataRetrievalFailureException("Error getting user: " + username, e);
    }
  }
Example #8
0
 /**
  * @param args the command line arguments
  * @throws java.sql.SQLException
  */
 public static void main(String[] args) throws SQLException {
   Operacoes op = new Operacoes();
   op.Setroot();
   Principal roda = new Principal();
   Login login = new Login();
   login.setLogin(true);
   login.LayoutLogin();
   roda.layout();
 }
 @Test
 public void checkCreatingSimplePrincipalWithAttributes() {
   final PrincipalFactory f = new DefaultPrincipalFactory();
   final Principal p =
       f.createPrincipal("uid", Collections.singletonMap("mail", "*****@*****.**"));
   assertEquals(p.getId(), "uid");
   assertEquals(p.getAttributes().size(), 1);
   assertTrue(p.getAttributes().containsKey("mail"));
 }
 @Test
 public void verifyAttributesWithPrincipal() {
   final PersonDirectoryPrincipalResolver resolver = new PersonDirectoryPrincipalResolver();
   resolver.setAttributeRepository(TestUtils.getAttributeRepository());
   resolver.setPrincipalAttributeName("cn");
   final Credential c = TestUtils.getCredentialsWithSameUsernameAndPassword();
   final Principal p = resolver.resolve(c);
   assertNotNull(p);
   assertNotEquals(p.getId(), TestUtils.CONST_USERNAME);
   assertTrue(p.getAttributes().containsKey("memberOf"));
 }
Example #11
0
  private void botaoLogar() {
    CondominoDAO dao = new CondominoDAO();
    Condomino condomino = dao.validarLogin(condominoConsulta());

    if (condomino != null) {
      Principal principal = new Principal(condomino);
      principal.setVisible(true);
      stage.close();
    } else {
      JOptionPane.showMessageDialog(
          null, "Login ou senha incorreta", "ERRO", JOptionPane.ERROR_MESSAGE);
    }
  }
 /** 授权查询回调函数, 进行鉴权但缓存中无用户的授权信息时调用 */
 @Override
 protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
   Principal principal = (Principal) getAvailablePrincipal(principals);
   // 获取当前已登录的用户
   if (!Global.TRUE.equals(Global.getConfig("user.multiAccountLogin"))) {
     Collection<Session> sessions =
         getSystemService()
             .getSessionDao()
             .getActiveSessions(true, principal, UserUtils.getSession());
     if (sessions.size() > 0) {
       // 如果是登录进来的,则踢出已在线用户
       if (UserUtils.getSubject().isAuthenticated()) {
         for (Session session : sessions) {
           getSystemService().getSessionDao().delete(session);
         }
       }
       // 记住我进来的,并且当前用户已登录,则退出当前用户提示信息。
       else {
         UserUtils.getSubject().logout();
         throw new AuthenticationException("msg:账号已在其它地方登录,请重新登录。");
       }
     }
   }
   User user = getSystemService().getUserByLoginName(principal.getLoginName());
   if (user != null) {
     SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
     List<Menu> list = UserUtils.getMenuList();
     for (Menu menu : list) {
       if (StringUtils.isNotBlank(menu.getPermission())) {
         // 添加基于Permission的权限信息
         for (String permission : StringUtils.split(menu.getPermission(), ",")) {
           info.addStringPermission(permission);
         }
       }
     }
     // 添加用户权限
     info.addStringPermission("user");
     // 添加用户角色信息
     for (Role role : user.getRoleList()) {
       info.addRole(role.getEnname());
     }
     // 更新登录IP和时间
     getSystemService().updateUserLoginInfo(user);
     // 记录登录日志
     LogUtils.saveLog(Servlets.getRequest(), "系统登录");
     return info;
   } else {
     return null;
   }
 }
  // crea los objetos de textura y audio
  private void crearObjetos() {
    AssetManager assetManager = principal.getAssetManager(); // Referencia al assetManager
    // Textura de fondos y botones
    texturaFondo = assetManager.get("seleccionNivel/recursosPerdiste/gameOver.png");
    texturaBtnMenu = assetManager.get("seleccionNivel/recursosPausa/menu.png");
    texturaBtnContinue = assetManager.get("seleccionNivel/recursosPerdiste/continue.png");

    // Crear fondo
    fondo = new Fondo(texturaFondo);

    fondo.getSprite().setCenter(Principal.ANCHO_MUNDO / 2, Principal.ALTO_MUNDO / 2);
    fondo.getSprite().setOrigin(1500 / 2, 1500 / 2);

    // botones
    btnContinue = new Boton(texturaBtnContinue);
    btnContinue.setPosicion(Principal.ANCHO_MUNDO / 2 - 160, Principal.ALTO_MUNDO / 2 - 200);

    btnMenu = new Boton(texturaBtnMenu);
    btnMenu.setPosicion(Principal.ANCHO_MUNDO / 2 - 160, Principal.ALTO_MUNDO / 2 - 350);

    efectoClick = assetManager.get("sonidoVentana.wav");
    efectoMuerteNinja = assetManager.get("seleccionNivel/recursosPerdiste/muerteNinja.wav");
    // Batch
    batch = new SpriteBatch();
  }
Example #14
0
  public void generarFondo(Component componente) {
    boolean dibujarFondo = false;
    Rectangle med = this.getBounds();
    Rectangle areaDibujo = this.getBounds();
    BufferedImage tmp;
    GraphicsConfiguration gc =
        GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getDefaultScreenDevice()
            .getDefaultConfiguration();

    if (Principal.fondoBlur) {
      dibujarFondo = true;
    }
    if (dibujarFondo) {
      JRootPane root = SwingUtilities.getRootPane(this);
      blurBuffer = GraphicsUtilities.createCompatibleImage(Principal.sysAncho, Principal.sysAlto);
      Graphics2D g2 = blurBuffer.createGraphics();
      g2.setClip(med);
      blurBuffer = blurBuffer.getSubimage(med.x, med.y, med.width, med.height);
      ((Escritorio) Principal.getEscritorio()).getFrameEscritorio().paint(g2);
      g2.dispose();
      backBuffer = blurBuffer;
      // blurBuffer = toGrayScale(blurBuffer);
      blurBuffer = GraphicsUtilities.createThumbnailFast(blurBuffer, getWidth() / 2);
      blurBuffer = new GaussianBlurFilter(4).filter(blurBuffer, null);
      g2 = (Graphics2D) blurBuffer.getGraphics();
      g2.setColor(new Color(0, 0, 0, 195));
      g2.fillRect(0, 0, Principal.sysAncho, Principal.sysAlto);
      listo = true;
    }
  }
  /**
   * * Convert principal attributes to person attributes.
   *
   * @param p the principal carrying attributes
   * @return person attributes
   */
  private Map<String, List<Object>> convertPrincipalAttributesToPersonAttributes(
      final Principal p) {
    final Map<String, List<Object>> convertedAttributes = new HashMap<>(p.getAttributes().size());
    final Map<String, Object> principalAttributes = p.getAttributes();

    for (final Map.Entry<String, Object> entry : principalAttributes.entrySet()) {
      final Object values = entry.getValue();
      final String key = entry.getKey();
      if (values instanceof List) {
        convertedAttributes.put(key, (List) values);
      } else {
        convertedAttributes.put(key, Collections.singletonList(values));
      }
    }
    return convertedAttributes;
  }
Example #16
0
  /**
   * adds the specified member to the group.
   *
   * @param user The principal to add to the group.
   * @return true if the member was added - false if the member could not be added.
   */
  public boolean addMember(Principal user) {
    if (groupMembers.contains(user)) return false;

    // do not allow groups to be added to itself.
    if (group.equals(user.toString())) throw new IllegalArgumentException();

    groupMembers.addElement(user);
    return true;
  }
Example #17
0
 private void jButton1ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
   // TODO add your handling code here:
   String correo = jTextField1.getText();
   String pass = new String(jPasswordField1.getPassword());
   Usuario login;
   try {
     login = org.login(correo, pass);
     Principal p = new Principal();
     p.setVisible(true);
     this.setVisible(false);
   } catch (ObjetoVacio | NoEncontrado e) {
     jTextField1.setText("");
     jPasswordField1.setText("");
     JOptionPane.showMessageDialog(
         this, "Email o password incorrecto", "Error", JOptionPane.WARNING_MESSAGE);
   }
 } // GEN-LAST:event_jButton1ActionPerformed
 @Override
 public void dispose() {
   // Eliminar basura
   principal.dispose();
   batch.dispose();
   texturaBtnContinue.dispose();
   texturaBtnMenu.dispose();
   texturaFondo.dispose();
   this.efectoMuerteNinja.dispose();
   this.efectoClick.dispose();
 }
  @Override
  public Map<String, Object> getAttributes(final Principal p) {
    final Map<String, Object> cachedAttributes = this.cache.get(p.getId());
    if (cachedAttributes != null) {
      LOGGER.debug(
          "Found [{}] cached attributes for principal [{}]", cachedAttributes.size(), p.getId());
      return cachedAttributes;
    }

    final Map<String, List<Object>> sourceAttributes =
        retrievePersonAttributesToPrincipalAttributes(p.getId());
    LOGGER.debug(
        "Found [{}] attributes for principal [{}] from the attribute repository.",
        sourceAttributes.size(),
        p.getId());

    if (this.mergingStrategy == null || this.mergingStrategy.getAttributeMerger() == null) {
      LOGGER.debug(
          "No merging strategy found, so attributes retrieved from the repository will be used instead.");
      final Map<String, Object> finalAttributes =
          convertPersonAttributesToPrincipalAttributes(sourceAttributes);
      addPrincipalAttributesIntoCache(p.getId(), finalAttributes);
      return finalAttributes;
    }

    final Map<String, List<Object>> principalAttributes =
        convertPrincipalAttributesToPersonAttributes(p);
    LOGGER.debug(
        "Merging current principal attributes with that of the repository via strategy [{}]",
        this.mergingStrategy.getClass().getSimpleName());
    final Map<String, List<Object>> mergedAttributes =
        this.mergingStrategy
            .getAttributeMerger()
            .mergeAttributes(principalAttributes, sourceAttributes);

    final Map<String, Object> finalAttributes =
        convertPersonAttributesToPrincipalAttributes(mergedAttributes);
    addPrincipalAttributesIntoCache(p.getId(), finalAttributes);
    return finalAttributes;
  }
Example #20
0
  @Override
  public void render(float delta) {
    tiempo = Gdx.graphics.getRawDeltaTime() + tiempo;
    if (tiempo > 3) {
      principal.setScreen(new PantallaMenu(principal));
    }
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.setProjectionMatrix(camara.combined);

    batch.begin();
    spriteFondo.draw(batch);

    batch.end();
  }
Example #21
0
  /*
   * Test method for 'net.sf.jguard.core.authorization.permissions.PrincipalUtils.getPrincipal(String, String)'
   */
  @Test
  public void testGetPrincipal() {
    // we test jGuardPrincipal
    Principal ppal =
        PrincipalUtils.getPrincipal(RolePrincipal.class.getName(), RolePrincipal.getName("stuff"));
    Assert.assertEquals(RolePrincipal.class, ppal.getClass());
    Assert.assertEquals("*#stuff", ppal.getName());

    // we test X509Principal
    Principal ppal2 =
        PrincipalUtils.getPrincipal(X509Principal.class.getName(), "C=AU,ST=Victoria");
    Assert.assertEquals(org.bouncycastle.jce.X509Principal.class, ppal2.getClass());

    // we test X500Principal
    Principal ppal3 =
        PrincipalUtils.getPrincipal(X500Principal.class.getName(), "C=AU,ST=Victoria");
    Assert.assertEquals(javax.security.auth.x500.X500Principal.class, ppal3.getClass());

    //        we test KerberosPrincipal
    Principal ppal4 =
        PrincipalUtils.getPrincipal(KerberosPrincipal.class.getName(), "*****@*****.**");
    Assert.assertEquals(javax.security.auth.kerberos.KerberosPrincipal.class, ppal4.getClass());
  }
 @Override
 public void start(Stage escenario) {
   escenario.setTitle("Responsabilidad");
   escenario0 = escenario;
   try {
     FXMLLoader cargador2 = new FXMLLoader(Principal.class.getResource("DescriGralView.fxml"));
     cargador2.setController(new ResponsabilidadController());
     AnchorPane root = (AnchorPane) cargador2.load();
     escenario0.setScene(new Scene(root, Color.TRANSPARENT));
     //			escenario0.initStyle(StageStyle.UNDECORATED);
     //			escenario0.setResizable(false);
     escenario0.initModality(Modality.NONE);
     escenario0.initOwner(Principal.getStagePrincipal());
     escenario0.show();
     System.out.println("Muestra la Ventana Responsabilidad???");
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
 /*
  * Returns the label String from a X50name
  */
 private String issuerString(Principal principal) {
   // 19902
   //		try {
   //			if (principal instanceof X500Name) {
   //				StringBuffer buf = new StringBuffer();
   //				X500Name name = (X500Name) principal;
   //				buf.append((name.getDNQualifier() != null) ? name.getDNQualifier() + ", " : "");
   //				buf.append(name.getCommonName());
   //				buf.append((name.getOrganizationalUnit() != null) ? ", " + name.getOrganizationalUnit() :
   // "");
   //				buf.append((name.getOrganization() != null) ? ", " + name.getOrganization() : "");
   //				buf.append((name.getLocality() != null) ? ", " + name.getLocality() : "");
   //				buf.append((name.getCountry() != null) ? ", " + name.getCountry() : "");
   //				return new String(buf);
   //			}
   //		} catch (Exception e) {
   //			UpdateCore.warn("Error parsing X500 Certificate",e);
   //		}
   return principal.toString();
 }
Example #24
0
 public String toString() {
   return subject.toString();
 }
 public static void main(String[] args) {
   Principal exe = new Principal();
   exe.show();
 }
Example #26
0
 private void jButton3ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed
   Prin = new Principal();
   this.setVisible(false);
   Prin.setVisible(true);
 } // GEN-LAST:event_jButton3ActionPerformed
Example #27
0
 /**
  * Gets the specified Identity within this scope by the specified Principal.
  *
  * @param principal The Principal of the Identity to get
  * @returns an identity representing the principal or null if it cannot be found
  */
 public Identity getIdentity(Principal principal) {
   return getIdentity(principal.getName());
 }
Example #28
0
 public int hashCode() {
   return subject.hashCode() + issuer.hashCode();
 }
 /**
  * Removes cached principal from the cache.
  *
  * @param p the principal
  */
 public void removePrincipalFromCache(final Principal p) {
   this.cache.remove(p.getId());
 }