首页 \ 问答 \ 在互联网上发送Android市场公钥(Sending Android market public key across the internet)

在互联网上发送Android市场公钥(Sending Android market public key across the internet)

通过互联网以原始base64形式发送Android Market公钥是否安全? 如果我这样做会遇到什么问题?


Is it safe to send the Android Market public key in raw base64 form across the internet? What problems could I encounter if I did this?


原文:https://stackoverflow.com/questions/4422428
更新时间:2024-04-23 17:04

最满意答案

这是一个使用Observer模式将观察者注册到登录系统的示例。 在示例中,我注册了一个观察者,在创建新用户时向管理员发送电子邮件:

首先,我们创建定义observable / observers行为的接口

interface IObserver
{
     //an observer has to implement a function, that will be called when the observable changes
     //the function receive data (in this case the user name) and also the observable object (since the observer could be observing more than on system)
     function onUserAdded( $observable, $data );
}

interface IObservable
{
    //we can attach observers to the observable
    function attach( $observer );
}

然后让您的主登录系统实现IObservable,实现attach函数,并保留一组观察者。 在内部,您实现了一个notify函数,在调用它时,迭代数组并通知每个观察者。

你做的是,在创建用户的所有正常行为之后,你调用你的通知函数。

class LoginSystem implements IObservable
{
    private $observers = array();

    private function notify( $userName )
    {
        foreach( $this->observers as $o )
            $o->onUserAdded( $this, $userName );
    }

    public function attach( $observer )
    {
        $this->observers []= $observer;
    }

    public function createUser( $userName )
    {

        //all your logic to add it to the databse or whatever, and then:

        $this->notify($userName);

    }

}

然后,您创建一个类而不是实现Iobserver。 在onUserAdded函数中,您可以在发生观察事件时执行任何操作。 在这个例子中,我只是将邮件发送到硬编码的电子邮件。 它可能会像你想要的那样复杂。

class NewUserMailer implements IObserver
{
    public function  onUserAdded( $observable, $data ) 
    {
        mail("admin@yoursite.com", "new user", $data);
    }
}

然后,行为就是在创建登录系统之后,您还创建了一个观察者,并且附加到登录系统

$ls = new LoginSystem();
$ls->attach( new NewUserMailer() );

有了这个,每次创建新用户时,邮件都会发送到“admin@yoursite.com”


This is an example that uses the Observer pattern to register observers to your login system. In the example, i register an observer that sends a email to the admin when a new user is created:

First, we create the interfaces that define the behavior of the observable/observers

interface IObserver
{
     //an observer has to implement a function, that will be called when the observable changes
     //the function receive data (in this case the user name) and also the observable object (since the observer could be observing more than on system)
     function onUserAdded( $observable, $data );
}

interface IObservable
{
    //we can attach observers to the observable
    function attach( $observer );
}

Then you let your main login system implement IObservable, you implement the attach function, and keep an array of observers. internally, you implement a notify function that when it is called, iterate the array and notify every observer.

What you do, is after all the normal behavior of creating an user, you call your notify function.

class LoginSystem implements IObservable
{
    private $observers = array();

    private function notify( $userName )
    {
        foreach( $this->observers as $o )
            $o->onUserAdded( $this, $userName );
    }

    public function attach( $observer )
    {
        $this->observers []= $observer;
    }

    public function createUser( $userName )
    {

        //all your logic to add it to the databse or whatever, and then:

        $this->notify($userName);

    }

}

Then, you create a class than implements Iobserver. in the onUserAdded function, you do whatever you want to happen when the observed event occurs. In this example i just send a mail to a hardcoded email. It could be as complex as you want.

class NewUserMailer implements IObserver
{
    public function  onUserAdded( $observable, $data ) 
    {
        mail("admin@yoursite.com", "new user", $data);
    }
}

Then, the behavior is just, after creating the loginsystem, you also create an observer, and attach is to the login system

$ls = new LoginSystem();
$ls->attach( new NewUserMailer() );

With this, everytime a new user is created, a mail will be sent to "admin@yoursite.com"

相关问答

更多
  • 那么从技术角度来看,上面给出的代码是否代表观察者模式? 没有 但只是想知道什么构成观察者模式? 我已更新您的代码以模拟观察者模式。 #[allow(unused_variables)] pub trait Events { fn on_value(&self, value: &str) {} } struct Observable { value: String, observers: Vec>, } impl Observable { fn new ...
  • 观察员实际上并没有与他们正在观察的课程相联系。 观察者的处理程序和观察对象之间的连接使用文字字符串值(例如`upload.error'),这意味着: 如果你想观察一个特定的对象,你必须事先知道它将要发布的事件的名称; 这是你不喜欢的“耦合”。 另一方面,如果您只对特定事件感兴趣,则可以观察该事件的任何类型的对象,而无需了解该对象的任何知识。 上述第2项是您关心的一项好处,但对项目1应该如何处理? 如果你仔细想想,如果它们代表不同的事件发生,就需要有一些方法来区分同一观察者的回调。 无论采取何种形式,这些“标 ...
  • 在支持多重继承的语言中,支持这种功能的对象来自支持这些方法的Observable类的INHERIT并不罕见。 我从来没有遇到过使用聚合来支持这个的解决方案,这就是你所描述的,但鉴于PHP不支持多重继承,这听起来像是一个合理的解决方法。 It's not unusual for an object that supports this functionality to INHERIT from an Observable class, which supports these methods, in lang ...
  • 在这里,我剥离了java.util.Observable不重要的部分,这是一个为扩展而设计的类,它使用了Observer接口。 这是Java代码,但当然任何OOP语言都可以实现这种模式。 package java.util; public class Observable { private boolean changed = false; private Vector obs; public Observable() { obs = new Vector(); ...
  • MVVM-和Observable-模式是不同的模式,你会发现很多很好的例子。 假设您正在实施MVVM电话应用程序,这两种模式可以很好地结合使用: 您的ViewModel(MV VM )具有要在XAML-VIEW(M V VM)中显示/更新的属性。 无论何时设置(或更新)属性值(在ViewModel中),都会触发类似()=> PropertyChanged("PropertyName); Observer现在位于MVVM Framework(或ViewModel的基类)中,此组件观察这些更改并使用VIEW管理 ...
  • 这是一个使用Observer模式将观察者注册到登录系统的示例。 在示例中,我注册了一个观察者,在创建新用户时向管理员发送电子邮件: 首先,我们创建定义observable / observers行为的接口 interface IObserver { //an observer has to implement a function, that will be called when the observable changes //the function receive data (i ...
  • 是调度Event很慢,如果您的目标是性能,您可以选择自己的事件系统,或者如果您不想重新发明轮子,请查看Robert Penner的as3信号库 。 Yes dispatching Event are slow, if performance are you goal you can go for your own event system or if you don't want to reinvent the wheel take a look at the as3 signals library fro ...
  • 为了直接回答你的问题,我可能会将Observer实现为控制器中的内部类。 然后它可以访问控制器中的所有内容。 假设这里PhoneBook定义了表单的方法 public List getPhoneNumbers() ; 然后你可以这样做: public class Controller { @FXML private ListView phoneNumberList ; private PhoneBook numbers = n ...
  • Observer模式减少了参与者之间的耦合,因为它在Subject和Observers之间引入了一个抽象类型Observer。 想象一个模型(四人帮中的主题/维基百科描述,以及业务逻辑的主页)和一个视图(一个观察者)。 如果没有Observer,模型需要在View发生变化时调用方法。 模型将知道View的具体类并与之相关联,以及View所属的任何UI特定框架。 使用Observer,Model只知道Observer的类型(抽象类或接口),因此它没有与具体的View耦合。 The Observer patte ...
  • 第二个例子看起来不错,但我不确定是否在OrderItemPickObserver类的update方法中创建新的Position对象。 相反,我建议将Position对象保持为OrderItem类的属性,以便您可以从外部设置它。 class OrderItem extends Observable { private $_position; public function setPosition($position){ $this->_posit ...

相关文章

更多

最新问答

更多
  • CSS修复容器和溢出元素(CSS Fix container and overflow elements)
  • SQL多个连接在与where子句相同的表上(SQL Multiple Joins on same table with where clause)
  • nginx 80端口反向代理多个域名,怎样隐藏端口的
  • xcode提醒样式,swift 3(xcode alert style, swift 3)
  • 在Chrome控制台中调试JavaScript(debugging javascript in Chrome console)
  • Javascript - 试图围绕自定义事件(Javascript - Trying to wrap my head around custom events)
  • 边栏链接不可点击(Sidebar links aren't clickable)
  • 使用recpatcha gem时如何显示其他表单错误?(How do I display other form errors when using the recpatcha gem?)
  • boost.python避免两次注册内部类,但仍然在python中公开(boost.python Avoid registering inner class twice but still expose in python)
  • Android 现在软件很少吗?以后会多起来吗
  • 如何在ActiveAdmin 0.5.0中为资源全局指定预先加载?(How to specify eager loading globally for a resource in ActiveAdmin 0.5.0?)
  • matlab代码为黄金比例持续分数(matlab code for golden ratio continued fraction)
  • Android浏览器触摸事件位置(Android browser touch event location)
  • 将cURL输出分配给Bash中的变量(Assign output to variable in Bash)
  • 我如何在MVC视图上没有时间获取当前日期(how i can get current date without time on MVC view)
  • sql连接函数(sql join of function)
  • 为什么在Xamarin Media插件中使用ImageSource.FromStream而不是FromFile?(Why use ImageSource.FromStream instead of FromFile in Xamarin Media plugin?)
  • 这段代码是否真的可以防止SQL注入?(Will this code actually work against SQL-injection? [duplicate])
  • 信阳方远计算机学校大专证被国家认可么
  • React / Rails AJAX POST请求返回404(React/Rails AJAX POST request returns 404)
  • Android与php服务器交互(Android interact with php server)
  • 自动刷新QTableWidget可能吗?(Refresh QTableWidget automatically possible?)
  • JVM / Compiler优化对象的未使用属性(optimization of unused properties of object by JVM / Compiler)
  • 插入表格时,乌克兰字符会更改为问号(Ukrainian character change to question mark when insert to table)
  • 在头文件中包含异常类(Including an exception class in a header file)
  • 完成c#中的执行后关闭sqlcmd(Close sqlcmd after finishing executing in c#)
  • 使用软导航栏正确检测屏幕尺寸(Detecting screensize correctly with soft navigation bar)
  • Typescript:从输入更新值(Typescript : update value from input)
  • 如何在执行某些行后仅在断点处停止?(How to only stop at a breakpoint after some line was executed?)
  • 以未定义的元素在JSON中循环(loop in JSON with undefined elements)