小编Axe*_*Axe的帖子

mongodb.conf bind_ip = 127.0.0.1不起作用,但0.0.0.0工作

我无法理解bind_ipmongodb是什么.我可以通过拥有bind_ip = 0.0.0.0,但无法使其工作,从桌面到EC2机器进行远程连接bind_ip = 127.0.0.1.

请解释一下bind_ip是什么以及它为什么适用0.0.0.0而不适用于127.0.0.1.

mongodb docs参考:

bind_ip

默认值:所有接口.

设置此选项可将mongod或mongos进程配置为绑定并侦听此地址上应用程序的连接.您可以将mongod或mongos实例附加到任何接口; 但是,如果将进程附加到可公开访问的接口,请实施适当的身份验证或防火墙限制以保护数据库的完整性.

您可以连接逗号分隔值列表以将mongod绑定到多个IP地址.

amazon-ec2 mongodb

26
推荐指数
3
解决办法
6万
查看次数

切换到特定的片段会产生奇怪的java.lang.NullPointerException

这是我目前面临的问题.我最近已经从带有ADT插件的Eclipse切换到Android Studio,并且在Eclipse工作室中出现了我从未遇到过的错误.

当我切换到一个名为"LineFragment"的特定片段时,我收到以下错误:

java.lang.NullPointerException: Attempt to write to field 'int android.support.v4.app.Fragment.mNextAnim' on a null object reference
        at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:708)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
        at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
        at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
        at android.support.v4.view.ViewPager$3.run(ViewPager.java:249)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
        at android.view.Choreographer.doCallbacks(Choreographer.java:580)
        at android.view.Choreographer.doFrame(Choreographer.java:549)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
Run Code Online (Sandbox Code Playgroud)

它似乎与片段为null或左右有关.我在互联网上搜索,但只有极少数人喜欢这样的东西.

这是我的片段的代码(它像所有3个片段一样扩展android.support.v4.app.Fragment)

public class LineFragment extends Fragment{

private View v;
private ListView list;
private LineList listAdapter;
private Home home;  // Current activity

public static LineFragment  newInstance(String chaine) …
Run Code Online (Sandbox Code Playgroud)

java eclipse android nullpointerexception android-studio

10
推荐指数
2
解决办法
2万
查看次数

CollapsingToolbarLayout有时会在下面留下空白区域

我有个问题.以下是截图:

在此输入图像描述

在此输入图像描述

在此输入图像描述

以下是代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/rootLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="256dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbarLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:expandedTitleMarginStart="64dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:minHeight="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo …
Run Code Online (Sandbox Code Playgroud)

android android-support-library material-design

10
推荐指数
1
解决办法
5174
查看次数

管理运行权限VB.NET的测试应用程序

我想要一个确定的方法来测试应用程序是否通过UAC框运行并具有完全的管理权限.之前,我曾想过在C:\ Windows \中创建一个文件夹进行测试,但在其他计算机上运行它被证明是失败的!

UAC框为计算机提供了执行任何操作的所有管理权限(包括在需要权限的位置创建文件夹和创建文件),并确保所谓的或创建的任何子程序也具有与父项相同的权限.

是否有一种可靠的方法来测试我的应用程序是否已经提供了用户在运行应用程序时最大程度上获得的所有管理权限?如果是的话,我很高兴能够完成代码工作!

提前致谢

vb.net windows uac

9
推荐指数
1
解决办法
1万
查看次数

无法调用没有args的公共okhttp3.RequestBody()失败

这是我使用改造错误的时候

第一步:

public interface RequestService {
    @POST ("home/indexThree")
    Call<RequestBody> getHomeinfo(@Body RequestBody info);
}
Run Code Online (Sandbox Code Playgroud)

第二步:

 Retrofit retrofit = new Retrofit.Builder()
             .baseUrl(url)
             .addConverterFactory(GsonConverterFactory.create())
             .build();
    RequestService requestService = retrofit.create(RequestService.class);
    RequestBody body = RequestBody.create(JSON, jsonObject.toString());
            Call<RequestBody> homeinfo = requestService.getHomeinfo(body);
    homeinfo.enqueue(new Callback<RequestBody>() {
        @Override
        public void onResponse(Call<RequestBody> call, Response<RequestBody> response) {
            System.out.println("response"+response.body().toString());
        }

        @Override
        public void onFailure(Call<RequestBody> call, Throwable t) {
            System.out.println("onFailure"+t.getMessage().toString());
        }
    });
Run Code Online (Sandbox Code Playgroud)

我在网上搜索了很长时间.但没用.请帮助或尝试提供一些如何实现这一点的想法.谢谢!

android okhttp3

6
推荐指数
1
解决办法
3101
查看次数

调整Windows扬声器音量VB.NET

如何通过VB.NET更改Windows扬声器音量(主输出音量控制音量值)?我想要一种方式来像我们从Windows 7上的音量控制应用程序那样间接地改变整个系统的音量

vb.net windows volume

5
推荐指数
1
解决办法
4432
查看次数

禁用关闭按钮VB.NET

在VB.NET中是否有可能禁用主窗体的关闭按钮,就像我在许多安装程序中看到的那样!我不想隐藏它,我想完全禁用它!

提前致谢

.net vb.net winforms

5
推荐指数
1
解决办法
6969
查看次数

NotificationManager.notify锁定手机和模拟器

问题:

电话/模拟器会锁定重复的通知更新.在锁定之后让仿真器恢复响应的唯一方法是按给定的顺序按Home => Menu => Lock => Home => Menu Button.

码:

通知推送代码:

        // Set up notifcation views
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); // Get notification manager
        RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.service_notification);
        contentView.setViewVisibility(R.id.current_error_text, View.GONE);
        contentView.setViewVisibility(R.id.error_text, View.GONE);
        contentView.setViewVisibility(R.id.info_error_text, View.GONE);
        contentView.setViewVisibility(R.id.info_text, View.GONE);
        contentView.setViewVisibility(R.id.next_check_in_text, View.VISIBLE);
        contentView.setViewVisibility(R.id.current_profile_text, View.VISIBLE);
        contentView.setViewVisibility(R.id.profile_name_text, View.VISIBLE);
        contentView.setTextViewText(R.id.next_check_in_text, mainText);
        // Set profile text now
        contentView.setTextViewText(R.id.profile_name_text, miniText);
        // Set up a new notification
        Notification notif = new Notification(R.drawable.service_logo_small, "Service is running", System.currentTimeMillis());
        notif.contentView = contentView; // Set content …
Run Code Online (Sandbox Code Playgroud)

android android-notifications

5
推荐指数
1
解决办法
599
查看次数

如何使用Spring Security for REST API对用户进行身份验证

我一直在寻找这个问题的答案.但是,在阅读了包括Spring Security文档在内的大量资源之后,我仍然无法完全理解如何使用Spring Security对REST API的用户进行身份验证.
这是我想要做的:

  • 1)我想使用公钥 - 私钥实现像Amazon S3服务这样的身份验证
  • 2)为此,我将发送一个HMAC令牌,其中包含授权标头中的每个请求和公钥或我自己的自定义标头.
  • 3)我想使用spring security来实现令牌的服务器端处理,如下所示:
    • 1)从头部获取公钥.
    • 2)使用我的cutom UserDetailService类获取存储在数据库中的私钥
    • 3)使用请求和私钥计算服务器端的HMAC令牌,就像我在客户端上做的那样
    • 4)比较两个令牌以验证用户
    • 5)如果成功,则在SecurityContextHolder中存储认证对象.

从上面我不知道如何在Spring Security中执行此操作.我所理解的如下:

  • 1)使用<http>元素和自定义过滤器.我这样做了如下

    <http use-expressions="true" create-session="stateless" 
          authentication-manager-ref="restAuthenticationManager" 
          entry-point-ref="jkwebRestAuthenticationEntryPoint">
        <intercept-url pattern="/api/**" access="isAuthenticated()">
        </intercept-url>
        <custom-filter ref="jkWebSecurityHmacAuthenticationFilter"
         position="FORM_LOGIN_FILTER"/>
    </http>  
    
    Run Code Online (Sandbox Code Playgroud)
  • 2)现在我可以访问此过滤器中的标头并从中访问公钥.
    但是,我不知道如何使用此公钥从数据库中检索私钥.我是否需要使用自定义AuthenticationManager或AuthenticationProvider?以及如何做到这一点.我可以直接将我的UserDetailService Bean注入过滤器bean吗?

  • 3)如果我不需要使用自定义AuthenticationManager或AuthenticationProvider,我可以将UserDetailService直接注入过滤器bean,那么我是否需要自定义AuthenticationEntryPoint?
  • 4)假设我能够在过滤器中检索并进行身份验证,我是否需要调用chain.doFilter并将请求转发到相应的控制器?
  • 5)如果过滤器中的身份验证失败,我应该如何使用401响应客户端或自定义身份验证入口点?如果有,怎么样?
  • 6)我还需要将Authioities放在UserDetails中,我在UserDetailsS​​ervice实现中构造它并在UserDetails对象中设置它.只需在安全上下文中设置身份验证对象就可以完成工作,一旦身份验证成功,我们就会进行授权吗?

如果需要,我可以发布更多代码以便清晰.

authentication rest spring-mvc spring-security

5
推荐指数
0
解决办法
2084
查看次数