FileDocCategorySizeDatePackage
SESecurityManagerImpl.javaAPI DocAzureus 3.0.3.45716Thu Jan 11 11:47:38 GMT 2007org.gudy.azureus2.pluginsimpl.local.utils.security

SESecurityManagerImpl

public class SESecurityManagerImpl extends Object implements org.gudy.azureus2.plugins.utils.security.SESecurityManager
author
parg

Fields Summary
private com.aelitis.azureus.core.AzureusCore
core
private Map
password_listeners
private Map
certificate_listeners
Constructors Summary
public SESecurityManagerImpl(com.aelitis.azureus.core.AzureusCore _core)

	
	
	
				 
	
		core	= _core;
	
Methods Summary
public voidaddCertificateListener(org.gudy.azureus2.plugins.utils.security.CertificateListener listener)

		SECertificateListener	sepl = 
			new SECertificateListener()
			{
			public boolean
			trustCertificate(
				String			resource,
				X509Certificate	cert )
			{
				return( listener.trustCertificate( resource, cert ));
			}
			};
			
		certificate_listeners.put( listener, sepl );
		
		SESecurityManager.addCertificateListener( sepl );
	
public voidaddPasswordListener(org.gudy.azureus2.plugins.utils.security.PasswordListener listener)

		SEPasswordListener	sepl = 
			new SEPasswordListener()
			{
				public PasswordAuthentication
				getAuthentication(
					String		realm,
					URL			tracker )
				{
					return( listener.getAuthentication( realm, tracker ));
				}
				
				public void
				setAuthenticationOutcome(
					String		realm,
					URL			tracker,
					boolean		success )
				{
					listener.setAuthenticationOutcome( realm, tracker, success );
				}
				
				public void
				clearPasswords()
				{
				}
			};
			
		password_listeners.put( listener, sepl );
		
		SESecurityManager.addPasswordListener( sepl );
	
public byte[]calculateSHA1(byte[] data_in)

		if (data_in == null ){
			
			data_in = new byte[0];
		}
		
        SHA1Hasher hasher = new SHA1Hasher();
        
        return( hasher.calculateHash(data_in));	
	
public java.security.cert.CertificatecreateSelfSignedCertificate(java.lang.String alias, java.lang.String cert_dn, int strength)

		return( SESecurityManager.createSelfSignedCertificate(alias, cert_dn, strength ));		
	
public org.gudy.azureus2.plugins.utils.security.SEPublicKeydecodePublicKey(byte[] encoded)

		return( SEPublicKeyImpl.decode( encoded ));
	
public byte[]getIdentity()

		return( core.getCryptoManager().getSecureID());
	
public java.security.KeyStoregetKeyStore()

		return( SESecurityManager.getKeyStore());
	
public org.gudy.azureus2.plugins.utils.security.SEPublicKeygetPublicKey(int key_type, java.lang.String reason_resource)

		byte[]	encoded = core.getCryptoManager().getECCHandler().getPublicKey( reason_resource );
		 
		return( new SEPublicKeyImpl( key_type, encoded ));
	
public org.gudy.azureus2.plugins.messaging.generic.GenericMessageConnectiongetSTSConnection(org.gudy.azureus2.plugins.messaging.generic.GenericMessageConnection connection, org.gudy.azureus2.plugins.utils.security.SEPublicKey my_public_key, org.gudy.azureus2.plugins.utils.security.SEPublicKeyLocator key_locator, java.lang.String reason_resource, int block_crypto)

		return( new SESTSConnectionImpl( core, (GenericMessageConnectionImpl)connection, my_public_key, key_locator, reason_resource, block_crypto ));
	
public java.security.KeyStoregetTrustStore()

		return( SESecurityManager.getTrustStore());
	
public javax.net.ssl.SSLSocketFactoryinstallServerCertificate(java.net.URL url)

		return( SESecurityManager.installServerCertificates( url ));
	
public voidremoveCertificateListener(org.gudy.azureus2.plugins.utils.security.CertificateListener listener)

		SECertificateListener	sepl = (SECertificateListener)certificate_listeners.get( listener );
		
		if ( sepl != null ){
			
			SESecurityManager.removeCertificateListener( sepl );
		}
	
public voidremovePasswordListener(org.gudy.azureus2.plugins.utils.security.PasswordListener listener)

		SEPasswordListener	sepl = (SEPasswordListener)password_listeners.get( listener );
		
		if ( sepl != null ){
			
			SESecurityManager.removePasswordListener( sepl );
		}
	
public voidrunWithAuthenticator(java.net.Authenticator authenticator, java.lang.Runnable target)

		try{
			Authenticator.setDefault( authenticator );
			
			target.run();
			
		}finally{
			
			SESecurityManager.installAuthenticator();
		}