/** * Get the certificate of a platform. * @param cid The platform component identifier (null for own certificate). * @return The certificate. */ public IFuture<Certificate> getPlatformCertificate(IComponentIdentifier cid) { return getCertificate(cid==null? null: cid.getPlatformPrefix()); }
/** * Get the certificate of a platform. * @param cid The platform component identifier (null for own certificate). * @return The certificate. */ public IFuture<Certificate> getPlatformCertificate(IComponentIdentifier cid) { return getCertificate(cid==null? null: cid.getPlatformPrefix()); }
/** * Set the password for a target component. * Note that passwords are currently stored on a per platform basis, * i.e. there is only one stored password for all components of the same platform. * Moreover, the security service strips the auto-generated extension from the platform * name and therefore can reuse the password for different instances of the same platform. * @param target The id of the target component. * @param password The password or null if no password should be used. */ @SecureTransmission // Todo: password is transferred in plain text unless transport uses encryption. public IFuture<Void> setPlatformPassword(IComponentIdentifier target, String password) { if(password!=null) { platformpasses.put(target.getPlatformPrefix(), password); } else { // Use remove to avoid keeping old mappings forever (name would still be stored otherwise) platformpasses.remove(target.getPlatformPrefix()); } return IFuture.DONE; }
/** * Get the password for a target component. * @param target The id of the target component. * @return The stored password. Returns null if no password is stored, unless the * component is a local component in which case the local password (if any) is returned. */ @SecureTransmission // Todo: password is transferred in plain text unless transport uses encryption. public IFuture<String> getPlatformPassword(IComponentIdentifier target) { String starget = target.getPlatformPrefix(); String ret = platformpasses.get(starget); if(ret==null && starget.equals(component.getComponentIdentifier().getPlatformPrefix())) { ret = this.password; } return new Future<String>(ret); }
/** * Get the password for a target component. * @param target The id of the target component. * @return The stored password. Returns null if no password is stored, unless the * component is a local component in which case the local password (if any) is returned. */ @SecureTransmission // Todo: password is transferred in plain text unless transport uses encryption. public IFuture<String> getPlatformPassword(IComponentIdentifier target) { String starget = target.getPlatformPrefix(); String ret = platformpasses.get(starget); if(ret==null && starget.equals(component.getComponentIdentifier().getPlatformPrefix())) { ret = this.password; } return new Future<String>(ret); }
/** * Get the password for a target component. * @param target The id of the target component. * @return The stored password. Returns null if no password is stored, unless the * component is a local component in which case the local password (if any) is returned. */ @SecureTransmission // Todo: password is transferred in plain text unless transport uses encryption. public IFuture<String> getPlatformPassword(IComponentIdentifier target) { String starget = target.getPlatformPrefix(); String ret = platformpasses.get(starget); if(ret==null && starget.equals(component.getComponentIdentifier().getPlatformPrefix())) { ret = this.password; } return new Future<String>(ret); }
/** * Get the keystore. */ protected KeyStore getKeyStore() { if(keystore==null) { // Fetch keystore and possible auto-generate self-signed certificate String name = component.getComponentIdentifier().getPlatformPrefix(); this.keystore = SSecurity.getKeystore(storepath, storepass, keypass, name); } return keystore; }
/** * Set the password for a target component. * Note that passwords are currently stored on a per platform basis, * i.e. there is only one stored password for all components of the same platform. * Moreover, the security service strips the auto-generated extension from the platform * name and therefore can reuse the password for different instances of the same platform. * @param target The id of the target component. * @param password The password or null if no password should be used. */ @SecureTransmission // Todo: password is transferred in plain text unless transport uses encryption. public IFuture<Void> setPlatformPassword(IComponentIdentifier target, String password) { if(password!=null) { platformpasses.put(target.getPlatformPrefix(), password); } else { // Use remove to avoid keeping old mappings forever (name would still be stored otherwise) platformpasses.remove(target.getPlatformPrefix()); } publishEvent(new ChangeEvent<Object>(null, PROPERTY_PLATFORMPASS, platformpasses)); return IFuture.DONE; }
/** * Get the keystore. */ protected KeyStore getKeyStore() { if(keystore==null) { // Fetch keystore and possible auto-generate self-signed certificate String name = component.getComponentIdentifier().getPlatformPrefix(); this.keystore = SSecurity.getKeystore(storepath, storepass, keypass, name); } return keystore; }
/** * Create a settings service. * @param prefix The settings file prefix to be used (if any). * Uses name from service provider, if no prefix is given. */ public SettingsService(IInternalAccess access, boolean saveonexit) { super(access.getServiceContainer().getId(), ISettingsService.class, null); this.access = access; this.providers = new LinkedHashMap(); this.saveonexit = saveonexit; filename = access.getComponentIdentifier().getPlatformPrefix() + SETTINGS_EXTENSION; }
/** * Create a collection of tags and replace the variable values. */ public static Collection<String> createRuntimeTags(Object vals, IExternalAccess component) { Collection<String> tags = convertToCollection(vals); Iterator<String> it = tags.iterator(); List<String> ret = new ArrayList<String>(); for(int i=0; i<tags.size(); i++) { String tag = it.next(); if(PLATFORM_NAME_INTERNAL.equals(tag) || PLATFORM_NAME.equals(tag)) { tag = component.getComponentIdentifier().getPlatformPrefix(); } else if(JADEX_VERSION_INTERNAL.equals(tag) || JADEX_VERSION.equals(tag)) { tag = VersionInfo.getInstance().getVersion(); } ret.add(tag); } return ret; } }
/** * Set the ttpcid. * @param ttpcid The ttpcid to set. */ public void setTTPCid(IComponentIdentifier ttpcid) { if(ttpcid!=null) ttpcid = new ComponentIdentifier(ttpcid.getPlatformPrefix(), ttpcid.getAddresses()); this.ttpcid = ttpcid; getSecurityService().publishEvent(new ChangeEvent<Object>(getClass(), ISecurityService.PROPERTY_MECHANISMPARAMETER, new Object[]{"ttpcid", ttpcid})); }
public void intermediateResultAvailable(final ISecurityService ss) { if(!found && ((IService)ss).getServiceIdentifier().getProviderId().getPlatformPrefix().equals(ttpcid.getName())) { found = true; verifyTTP(ss).addResultListener(new ExceptionDelegationResultListener<Void, ISecurityService>(ret) { public void customResultAvailable(Void result) { ret.setResult(ss); } }); } }
public void intermediateResultAvailable(final ISecurityService ss) { if(!found && ((IService)ss).getServiceIdentifier().getProviderId().getPlatformPrefix().equals(ttpcid.getName())) { found = true; verifyTTP(ss).addResultListener(new ExceptionDelegationResultListener<Void, ISecurityService>(ret) { public void customResultAvailable(Void result) { ret.setResult(ss); } }); } }
/** * Create a key pair entry (with associated certificate). * @param cid The entry name. * @param algorithm The algorithm. * @param keysize The key size (in bits). */ public IFuture<Void> createKeyPair(IComponentIdentifier cid, String algorithm, int keysize, String pass, int validity) { try { KeyPair keys = SSecurity.generateKeyPair(algorithm, keysize); Certificate cert = SSecurity.generateCertificate(keys, validity, "MD5With"+algorithm); getKeyStore().setKeyEntry(cid.getPlatformPrefix(), keys.getPrivate(), pass==null? null: pass.toCharArray(), new Certificate[]{cert}); publishEvent(new ChangeEvent<Object>(null, PROPERTY_KEYSTOREENTRIES, null)); saveKeyStore(); return IFuture.DONE; } catch(Exception e) { return new Future<Void>(e); } }
/** * Create a key pair entry (with associated certificate). * @param cid The entry name. * @param algorithm The algorithm. * @param keysize The key size (in bits). */ public IFuture<Void> createKeyPair(IComponentIdentifier cid, String algorithm, int keysize, String pass, int validity) { try { KeyPair keys = SSecurity.generateKeyPair(algorithm, keysize); Certificate cert = SSecurity.generateCertificate(keys, validity, "MD5With"+algorithm); getKeyStore().setKeyEntry(cid.getPlatformPrefix(), keys.getPrivate(), pass==null? null: pass.toCharArray(), new Certificate[]{cert}); publishEvent(new ChangeEvent<Object>(null, PROPERTY_KEYSTOREENTRIES, null)); saveKeyStore(); return IFuture.DONE; } catch(Exception e) { return new Future<Void>(e); } }
/** * Start the service. * @return A future that is done when the service has completed starting. */ @ServiceStart public IFuture<Void> startService() { this.providers = new LinkedHashMap<String, IPropertiesProvider>(); Object soe = access.getComponentFeature(IArgumentsResultsFeature.class).getArguments().get("saveonexit"); this.saveonexit = soe instanceof Boolean && ((Boolean)soe).booleanValue(); this.filename = access.getComponentIdentifier().getPlatformPrefix() + SETTINGS_EXTENSION; final Future<Void> ret = new Future<Void>(); contextService = SServiceProvider.getLocalService(access, IContextService.class, RequiredServiceInfo.SCOPE_PLATFORM); loadProperties().addResultListener(new DelegationResultListener<Void>(ret)); return ret; }
/** * Add a trusted certificate of a platform. * @param name The entry name. * @param cert The certificate. */ public IFuture<Void> addPlatformCertificate(IComponentIdentifier cid, Certificate cert) { try { KeyStore ks = getKeyStore(); ks.setCertificateEntry(cid.getPlatformPrefix(), cert); publishEvent(new ChangeEvent<Object>(null, PROPERTY_KEYSTOREENTRIES, null)); // publishEvent(new ChangeEvent<Object>(null, PROPERTY_KEYSTOREENTRIES, getKeystoreDetails())); saveKeyStore(); return IFuture.DONE; } catch(Exception e) { return new Future<Void>(e); } }
/** * Start the service. * @return A future that is done when the service has completed starting. */ @ServiceStart public IFuture<Void> startService() { this.providers = new LinkedHashMap<String, IPropertiesProvider>(); Object soe = access.getArguments().get("saveonexit"); this.saveonexit = soe instanceof Boolean && ((Boolean)soe).booleanValue(); this.filename = access.getComponentIdentifier().getPlatformPrefix() + SETTINGS_EXTENSION; final Future<Void> ret = new Future<Void>(); access.getServiceContainer().searchService(IContextService.class) .addResultListener(new DefaultResultListener<IContextService>() { public void resultAvailable(IContextService result) { contextService = result; loadProperties().addResultListener(new DelegationResultListener<Void>(ret)); } }); return ret; }
/** * Add a trusted certificate of a platform. * @param name The entry name. * @param cert The certificate. */ public IFuture<Void> addPlatformCertificate(IComponentIdentifier cid, Certificate cert) { try { KeyStore ks = getKeyStore(); ks.setCertificateEntry(cid.getPlatformPrefix(), cert); publishEvent(new ChangeEvent<Object>(null, PROPERTY_KEYSTOREENTRIES, null)); // publishEvent(new ChangeEvent<Object>(null, PROPERTY_KEYSTOREENTRIES, getKeystoreDetails())); saveKeyStore(); return IFuture.DONE; } catch(Exception e) { return new Future<Void>(e); } }