06.11.2014 Views

A User Centric Security Model for Tamper-Resistant Devices

A User Centric Security Model for Tamper-Resistant Devices

A User Centric Security Model for Tamper-Resistant Devices

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

C.10 Abstract Virtual Machine<br />

93 <strong>for</strong> ( int i = 0 ; i < number ; i ++) {<br />

94 commands [ i + 2 ] = inputCommandString [ i ] ;<br />

95 }<br />

96 System . out . p r i n t ( " Executing : " ) ;<br />

97 <strong>for</strong> ( int i = 0 ; i < commands . l e n g t h ; i ++) {<br />

98 System . out . p r i n t ( commands [ i ] + " " ) ;<br />

99 }<br />

100 Runtime runtime = Runtime . getRuntime ( ) ;<br />

101 Process p r o c e s s = runtime . exec ( commands ) ;<br />

102 CheckStream cmdProcessInputStream = new CheckStream<br />

103 ( p r o c e s s . getInputStream ( ) ) ;<br />

104 CheckStream cmdProcessErrorStream = new CheckStream<br />

105 ( p r o c e s s . getErrorStream ( ) ) ;<br />

106 cmdProcessInputStream . s t a r t ( ) ;<br />

107 cmdProcessErrorStream . s t a r t ( ) ;<br />

108 System . out . p r i n t ( " Waiting . . . . . . . " ) ;<br />

109 int done = p r o c e s s . waitFor ( ) ;<br />

110 p r o c e s s . d e s t r o y ( ) ;<br />

111 System . out . p r i n t l n ( " Conversion Completed . " ) ;<br />

112 } catch ( I n t e r r u p t e d E x c e p t i o n i e ) {<br />

113 System . out . p r i n t l n ( " Error Execution : " + i e . getMessage ( ) ) ;<br />

114 } catch ( IOException i o e ) {<br />

115 System . out . p r i n t l n ( " Error IO Operations : " + i o e . getMessage ( ) ) ;<br />

116 }<br />

117 }<br />

118 public s t a t i c void c r e a t e I n d e x ( ) throws CorruptIndexException ,<br />

119 LockObtainFailedException ,<br />

120 IOException {<br />

121 F i l e f i l e D i r = new F i l e (FILES_TO_INDEX_DIRECTORY) ;<br />

122 F i l e indexDir = new F i l e (INDEX_DIRECTORY) ;<br />

123 Analyzer luceneAnalyzer = new StandardAnalyzer ( ) ;<br />

124 IndexWriter indexWriter = new IndexWriter ( indexDir ,<br />

125 luceneAnalyzer , true ) ;<br />

126 F i l e [ ] t e x t F i l e s = f i l e D i r . l i s t F i l e s ( ) ;<br />

127 long startTime = new Date ( ) . getTime ( ) ;<br />

128 <strong>for</strong> ( int i = 0 ; i < t e x t F i l e s . l e n g t h ; i ++) {<br />

129 i f ( t e x t F i l e s [ i ] . i s F i l e ( ) >> t e x t F i l e s [ i ] . getName ( ) . endsWith (<br />

130 " . t x t " ) ) {<br />

131 System . out . p r i n t l n ( " F i l e " + t e x t F i l e s [ i ] . getCanonicalPath ( )<br />

132 + " i s being indexed " ) ;<br />

133 Reader textReader = new FileReader ( t e x t F i l e s [ i ] ) ;<br />

134 Document document = new Document ( ) ;<br />

135 document . add ( F i e l d . Text (FIELD_CONTENTS, textReader ) ) ;<br />

136 document . add ( F i e l d . Text (FIELD_PATH, t e x t F i l e s [ i ] . getPath ( ) ) ) ;<br />

137 indexWriter . addDocument ( document ) ;<br />

138 }<br />

139 }<br />

140 indexWriter . optimize ( ) ;<br />

141 indexWriter . c l o s e ( ) ;<br />

142 long endTime = new Date ( ) . getTime ( ) ;<br />

143 System . out . p r i n t l n ( " I t took " + ( endTime − startTime ) +<br />

432

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!