Engineeringserver.com

A community for computer science students & developers about software development, game development, game design, games, anime preview & reviews and more!

Archive for the ‘infosupport visumaanvraagsysteem’


Hooray! It took ~6 months but we finished it!

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...
1,854 views


Our “Visumaanvraagsysteem” project is finally done and we finished it with a 7.0 average. The presentation was tough but we somehow managed through it till the end. We spent the last half year on this project but we managed to finish this project successfully so a big Hooray! to us.

Now that thats done I have way more time to do other things so i’ll concentrate on my super duper ninja skill vids that was requested by a few people here a few months ago. So expect a new vid from us soon while i’m going to train more often again!

I can do better than this guy below, thats for sure.

Bookmark this page: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • De.lirio.us
  • Slashdot
  • StumbleUpon
  • Technorati
  • Reddit
  • Digg

Your Ad Here

Java token decrypter, sourecode released.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...
339 views

Since i successfully finished my project I'll release my Java token decrypter that makes use of the DES alghoritm. Have fun with it!

SourceCode:

JAVA:
  1. import java.awt.Color;
  2. import java.awt.TextArea;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.io.File;
  6. import java.io.FileInputStream;
  7. import java.io.FileNotFoundException;
  8. import java.io.ObjectInputStream;
  9. import java.io.OptionalDataException;
  10. import java.io.StreamCorruptedException;
  11. import java.util.HashMap;
  12. import javax.swing.ImageIcon;
  13. import javax.swing.JButton;
  14. import javax.swing.JFileChooser;
  15. import javax.swing.JFrame;
  16. import javax.swing.JLabel;
  17. import javax.swing.JMenu;
  18. import javax.swing.JMenuBar;
  19. import javax.swing.JMenuItem;
  20. import javax.swing.JOptionPane;
  21.  
  22. public class TokenDecrypter extends JFrame implements ActionListener{
  23. static File file;
  24. static String userDir = System.getProperty("user.dir");
  25.  
  26. JMenuBar mb = new JMenuBar();
  27. JMenu menu = new JMenu("Read token");
  28. JMenu menuExit = new JMenu("Exit");
  29. JLabel imageLbl = new JLabel();
  30. JLabel visaLbl = new JLabel();
  31.  
  32. JMenuItem mi = new JMenuItem("Read token from disk");
  33. JMenuItem miExit = new JMenuItem("Exit");
  34.  
  35. JButton geldigheid = new JButton("Check validation");
  36. TextArea ta = new TextArea("", 30,50,1);
  37. JFileChooser  fileChooser = new JFileChooser(userDir);
  38. Color backgroundClr = new Color(0,76,77);
  39. String decrypt;
  40. HashMap map;
  41.  
  42. public static void main(String[] args){
  43. TokenDecrypter TD = new TokenDecrypter();
  44. }
  45.  
  46. public TokenDecrypter(){
  47.  
  48. getContentPane().setLayout(null);
  49. getContentPane().setBackground(backgroundClr);
  50.  
  51. setTitle("Token decrypter - www.engineeringserver.com");
  52.  
  53. ta.setEditable(false);
  54. ta.setBackground(Color.WHITE);
  55. ta.setBounds(1, 21, 391, 410);
  56.  
  57. imageLbl = new JLabel(new ImageIcon(userDir +"\\logo.gif"));
  58. imageLbl.setBounds(150, 200, 148, 61);
  59.  
  60. visaLbl.setForeground(Color.WHITE);
  61. visaLbl = new JLabel();
  62. visaLbl.setBounds(5,40, 120,800);
  63.  
  64. geldigheid.setBounds(3, 430, 160, 28);
  65. geldigheid.addActionListener(this);
  66.  
  67. getContentPane().add(visaLbl);
  68. getContentPane().add(ta);
  69. getContentPane().add(imageLbl);
  70.  
  71. ta.setVisible(false);
  72. geldigheid.setVisible(false);
  73.  
  74. mb.add(menu);
  75. mb.add(menuExit);
  76. menu.add(mi);
  77. menuExit.add(miExit);
  78. mi.addActionListener(this);
  79. miExit.addActionListener(this);
  80.  
  81. setJMenuBar(mb);
  82. setSize(400,500);
  83. setBackground(backgroundClr);
  84. setLocationRelativeTo(null);
  85. setVisible(true);
  86. setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  87. }
  88.  
  89. public void readEncryptedFile(String filePath) throws StreamCorruptedException, OptionalDataException{
  90. if(file != null){
  91. ta.setText("Name:\t" + map.get("1")     +
  92. "\nReason:\t\t" + map.get("25"));
  93. ta.setVisible(true);
  94. geldigheid.setVisible(true);
  95. }
  96. }
  97.  
  98. public void actionPerformed(ActionEvent e) {
  99. visaLbl.setText("");
  100. getContentPane().setBackground(backgroundClr);
  101. if(e.getSource() == mi){
  102. geldigheidVisum();
  103. }
  104.  
  105. if(e.getSource() == miExit){
  106. System.out.println("exit");
  107. System.exit(0);
  108. }
  109. if(e.getSource() == geldigheid){
  110. System.out.println("Token is valid");
  111. }
  112. }
  113.  
  114. public void ingetrokkenVisum(){
  115. JOptionPane.showMessageDialog(null, decrypt + " \n\nGeldigheid: unknown");
  116. }
  117.  
  118. public void  geldigheidVisum(){
  119. getContentPane().setBackground(backgroundClr);
  120. int returnVal = 0;
  121. try{
  122. ta.setVisible(false);
  123. geldigheid.setVisible(false);
  124.  
  125. returnVal = fileChooser.showOpenDialog(fileChooser);
  126. fileChooser.addChoosableFileFilter(null);
  127. if (returnVal == JFileChooser.APPROVE_OPTION) {
  128. file = fileChooser.getSelectedFile();
  129. ois = new ObjectInputStream(new FileInputStream(file));
  130. decrypt = (String) ois.readObject();
  131. StringEncrypter SE = new StringEncrypter("DES","acvbnmkiacvbnmkiacvbnmkiacv");
  132. String hp = SE.decrypt(decrypt);
  133. hp = hp.substring(1, hp.length()-1);
  134. map = new HashMap();
  135.  
  136. String[] parts = hp.split(", |=");
  137.  
  138. for (int i = 0; i <parts.length; i+=2) {
  139. map.put(parts[i].toString(), parts[i+1].toString());
  140. }
  141.  
  142. //System.out.println(map.size());
  143. if(map.size()!=28){
  144. throw new Exception("Token is not valid!");
  145. }
  146.  
  147. String response = JOptionPane.showInputDialog(null,"Enter visa number: ","Visumaanvraagsysteem",JOptionPane.QUESTION_MESSAGE);
  148.  
  149. if(response !=null){
  150. String validate = "" + map.get("0");
  151.  
  152. while(!response.equals(validate))
  153. {
  154. response = JOptionPane.showInputDialog(null,"Enter visa nummer: ","Visumaanvraagsysteem", JOptionPane.QUESTION_MESSAGE);
  155. }
  156.  
  157. if(response.equals(validate)){
  158. getContentPane().setBackground(Color.lightGray);
  159. visaLbl.setForeground(Color.WHITE);
  160. visaLbl.setText("Visa nummer: " + map.get("0"));
  161. geldigheid.setText(response);
  162. this.readEncryptedFile("");
  163. ta.setVisible(true);
  164. geldigheid.setVisible(true);
  165.  
  166. }
  167.  
  168. }
  169.  
  170. }
  171. }catch (NullPointerException e){System.out.println("Token ongeldig");
  172. JOptionPane.showMessageDialog(null, "Token is not a valid format");
  173. ta.setVisible(false);
  174. geldigheid.setVisible(false);
  175.  
  176. }catch (ClassCastException e) {
  177. JOptionPane.showMessageDialog(null, "Token is not a valid format");
  178. ta.setVisible(false);
  179. geldigheid.setVisible(false);
  180.  
  181. JOptionPane.showMessageDialog(null, "Token is not a valid format");
  182. ta.setVisible(false);
  183. geldigheid.setVisible(false);
  184.  
  185. e.printStackTrace();
  186. }catch (Exception e) {
  187. JOptionPane.showMessageDialog(null, "Token is not a valid format");
  188. }
  189. }
  190. }

Screenshot:

For more screenshots: http://www.engineeringserver.com/blog/2008/03/14/java-token-encrypter-decrypter/

Bookmark this page: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • De.lirio.us
  • Slashdot
  • StumbleUpon
  • Technorati
  • Reddit
  • Digg

Your Ad Here

Java token encrypter, decrypter

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4 out of 5)
Loading ... Loading ...
538 views

Today I wrote an application that reads an encrypted file and decrypts the file into an appropiate readable format and showing it in a Swing user interface.

It also has exception handling like wrong file (not an encrypted file)  or bad file header etc but i'll blog about the features later when I have more time to write a full size blogpost. Until then, here are some screenshots.

Screenshot(s):
1.PNG2.PNG3.PNG4.PNG5.PNG

Bookmark this page: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • De.lirio.us
  • Slashdot
  • StumbleUpon
  • Technorati
  • Reddit
  • Digg

Your Ad Here

Sending a Java (EJB 3.0) StringArrayArray from server to client the correct way

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
528 views

Remember this post: here?

Well, that was the wrong way of sending a StringArrayArray from a Java (EJB 3.0) webservice to the client. In the mean time I managed to sent the StringArrayArray the correct way with the help of my projectmembers and a few other students.

This is the correct way to sent a StringArrayArray from server to client:

(This code describes how to get all users and iterate them to the JSP frontend, just like my previous post about this but now the "correct" way)

Client:
Import these packages:

import net.java.dev.jaxb.array.StringArray;
import net.java.dev.jaxb.array.StringArrayArray;

Put this code in your Servlet:
List<StringArray> data = ((StringArrayArray)port.getAllUsers()).getItem();
String[][] users = new String[data.size()][3];

for (int i = 0, n = data.size(); i < n; i++) {
StringArray list = data.get(i);
List<String> user = list.getItem();

for (int j = 0, m = user.size(); j < m; j++) {
users[i][j] = user.get(j);
}

uo.setList(users);

Auto generated from the client:
Folder: net/java/dev/jaxb/array

Classes:
public class ObjectFactory {}
public class StringArray {}
Public class StringArrayArray {}

Server:
Implement:

@WebMethod
@RolesAllowed ("beheerders")
public String[][] getAllUsers() {
final List<Gebruikers> list = entityManager.createQuery("select g from Gebruikers g").getResultList();
int i = 0;
String[][] tmp = new String[list.size()][3];
for (Gebruikers gebruiker : list) {
tmp[i][0] = ""+gebruiker.getId();
tmp[i][1] = ""+gebruiker.getNaam();
tmp[i][2] = ""+gebruiker.getRole();
System.out.println("-----------------> getAllUsers() ="+tmp.toString());
i++;
}
return tmp;
}

Interface:
String[][] getAllUsers();

Thats all you need to do to send the StringArrayArray from the server to the client.

If you want to know how to use a taglib to show the data on the JSP, I recommend you to visit the link here where i talked about it last time. (code included)

HappyFace
www.engineeringserver.com

Bookmark this page: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us