📄 updatecertificate.java
字号:
package SOMA.security.infrastructure.updatePolicy;
import java.io.PrintStream;
import SOMA.network.connection.Daemon;
import SOMA.security.infrastructure.Infrastructure;
public class UpdateCertificate implements Runnable, Daemon
{
Thread myServerDaemon;
private Object status = OFF;
private UpdatePolicy policy;
private Infrastructure pki;
private PrintStream out;
public UpdateCertificate ( UpdatePolicy policy , Infrastructure pki , PrintStream out )
{
this.policy = policy;
this.pki = pki;
this.out = out;
}
/** Avvio del demone. */
public synchronized void start()
throws PolicyException
{
if( status != ON )
{
myServerDaemon = new Thread( this, toString() );
status = ON;
myServerDaemon.start();
}
else throw new PolicyException( "Server already ON" );
}
/** Arresto del demone. */
public void stop()
throws PolicyException
{
if( status != OFF ) status = OFF;
else throw new PolicyException( "Server already OFF" );
}
public Object getStatus()
{
return status;
}
public String toString()
{
return "<UpdateCertificate: status = " + status + "\n Policy = " + policy + ">";
}
/** Metodo eseguito dal demone: attende richieste ed attiva connessioni finche' lo stato rimane ON e la ServerSocket attiva. */
public void run()
{
while( status == ON )
{
try{
if ( this.policy.update() )
if ( pki.getInfrastructureAddress().onLine )
{
out.println("Updating certificate into local list.");
long t0 = System.currentTimeMillis();
pki.updateCertificateCRLList();
long t1 = System.currentTimeMillis();
out.println("Update certificate into local list t = " + (t1 - t0) + " ms");
}
Thread.sleep( this.policy.getSleepTime() );
} catch ( Exception e ) { out.println( "Certificate update error." ); }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -