小编use*_*340的帖子

Openid和数据库集成的Spring安全性

我是Spring和Spring Security的新手,希望有人能帮助我解决以下问题.

我想要实现的是在OpenID提供程序(gmail)成功验证此用户之后提取用户的用户名和电子邮件地址,然后检查数据库以便为该用户加载用户模型.

在我的spring-security.xml中,我有

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:security="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-3.0.xsd
                           http://www.springframework.org/schema/security 
                           http://www.springframework.org/schema/security/spring-security-3.0.xsd">

    <security:authentication-manager alias="openIDAuthenticationManager" />

    <bean id="authenticationSuccessHandler" class="org.school.openid.service.YouEatAuthenticationSuccessHandler">
        <property name="defaultTargetUrl" value="/krams/main/common" />
        <property name="attributes2UserDetails" ref="openIDAttributes2UserDetails" />
    </bean>

    <security:http >
        <security:anonymous enabled="false" />
        <security:logout />
        <security:openid-login user-service-ref="userDetailsServiceOpenIDImpl" authentication-success-handler-ref="authenticationSuccessHandler"
            login-page="/krams/auth/login" authentication-failure-url="/krams/auth/login?error=true">
            <security:attribute-exchange>
                <security:openid-attribute name="email" type="http://schema.openid.net/contact/email" required="true" />
                <security:openid-attribute name="firstName" type="http://axschema.org/namePerson/first" required="true" />
                <security:openid-attribute name="lastName" type="http://axschema.org/namePerson/last" required="true" />
            </security:attribute-exchange>
        </security:openid-login>
    </security:http>

    <bean id="openIDAttributes2UserDetails" class="org.school.openid.service.OpenIDAttributes2UserDetailsImpl" />

    <bean id="userDetailsServiceOpenIDImpl" class="org.school.openid.service.UserDetailsServiceOpenIDImpl" />

</beans>

我的问题出在UserDetailsS​​erviceOpenIDImpl.java上

public class UserDetailsServiceOpenIDImpl implements …

openid spring spring-security

25
推荐指数
1
解决办法
7202
查看次数

首次安装Chrome扩展程序后,打开"帮助"页面

我是Chrome扩展新用户.我有一个问题,关于如何使扩展程序在安装后自动打开"帮助"页面.目前,我可以通过将值保存到localStorage来检查扩展是否第一次运行.但只有在单击工具栏上的图标时才会执行此检查.只是想知道是否有一种方式喜欢FF扩展,它在安装后使用javascript打开帮助页面.谢谢.

编辑:感谢davgothic的回答.我已经解决了这个问题.我有关于弹出窗口的另一个问题.我的扩展程序会检查当前标签的网址,

__PRE__
是否有可能以这种方式显示弹出窗口?

google-chrome google-chrome-extension

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

TensorFlow:使用张量来索引另一个张量

我有一个关于如何在TensorFlow中进行索引的基本问题.

在numpy:

x = np.asarray([1,2,3,3,2,5,6,7,1,3])
e = np.asarray([0,1,0,1,1,1,0,1])
#numpy 
print x * e[x]
Run Code Online (Sandbox Code Playgroud)

我可以得到

[1 0 3 3 0 5 0 7 1 3]
Run Code Online (Sandbox Code Playgroud)

我怎么能在TensorFlow中做到这一点?

x = np.asarray([1,2,3,3,2,5,6,7,1,3])
e = np.asarray([0,1,0,1,1,1,0,1])
x_t = tf.constant(x)
e_t = tf.constant(e)
with tf.Session():
    ????
Run Code Online (Sandbox Code Playgroud)

谢谢!

python numpy tensorflow

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

从servlet返回JSON

这是一个非常基本的请求 - 响应测试.浏览器使用jQuery $ .ajax API将"hello from browser"发送到servlet,servlet接收此消息,然后使用org.json.simple库创建一个JSON对象,并向浏览器发送一条消息"hello from server"的JSON响应.

我在localhost上运行它,只是假设我的IP地址是123.123.12.123,平台是Ubuntu,服务器是Tomcat 6.0,在Eclipse IDE中运行.

测试1.我从Eclipse启动服务器,打开Firefox,输入http:// localhost:8080/myproject/test.jsp,我可以看到servlet接收消息并且浏览器收到响应,测试通过.

测试2.服务器仍然在Ubuntu的Eclipse上运行,我从VirtualBox启动Windows 7客户机和Windows 7中的Firefox浏览器,输入http://123.123.12.123:8080/myproject/test.jsp,作为我工作预计,测试通过.

测试3.服务器仍然在Eclipse的Ubuntu上运行,打开Internet Explorer 9浏览器,给它地址http://123.123.12.123:8080/myproject/test.jsp,没有任何反应. 调试给了我

响应HTTP/1.1 200 OK

响应正文{"message":"你好,来自服务器"}

test.jsp是

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="release/js/libs/json2.js"></script>
<script>
$(document).ready(function(){
    var request = ({"message":'Hello from browser'});
    var jsonobj=JSON.stringify(request);
    $.ajax({
        data: {para:jsonobj},
        dataType: 'json',
        url: …

jquery internet-explorer json servlets java-ee

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

安装没有root的Cuda

我知道我可以用以下方法安装Cuda:

wget http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run
chmod +x cuda_7.0.28_linux.run
./cuda_7.0.28_linux.run -extract=`pwd`/nvidia_installers
cd nvidia_installers
sudo ./NVIDIA-Linux-x86_64-346.46.run 
sudo modprobe nvidia
sudo ./cuda-linux64-rel-7.0.28-19326674.run 

只是想知道我是否可以在没有root的情况下安装Cuda?

谢谢,

cuda gpu theano tensorflow

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

将JSP值传递给外部Javascript文件

有没有办法可以通过仅使用Javascript和JSP将JSP变量值传递给外部Javascript文件.就像是:

JSP

String str = "Hello";

external.js

//not working
var str = "<%=str%>";

谢谢.

javascript jsp

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

JNI将参数传递给c ++的方法

我有一个c ++文件myCppTest.cpp,它有方法

int myFunction(int argv, char **argc) {
}

和myClass.java中的Java本机方法

public native int myFunction (int argv, char[][] argc);

使用javah -jni myClass生成头文件后,我有头

JNIEXPORT jint JNICALL Java_JPTokenizer_init
  (JNIEnv *, jobject, jint, jobjectArray);

在我的myClass.cpp中,我定义了

JNIEXPORT jint JNICALL Java_JPTokenizer_init
  (JNIEnv *env, jobject obj, jint argv, jobjectArray argc) {
        //need to call int myFunction(int argv, char **argc) in myCppTest.cpp 
}

我怎么能将参数"jint argv,jobjectArray argc"传递给"int argv,char**argc",谢谢.

编辑:

我认为我犯了一个错误

myClass.java中的Java本机方法应该是

public native int init (int argv, char[][] argc);

所以有

JNIEXPORT jint JNICALL Java_myClass_init
  (JNIEnv *, jobject, jint, jobjectArray); …

c++ java java-native-interface

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

"this()"在构造函数中做了什么?

我有两个关于以下代码的问题.1.如何在不使用setter的情况下构造第三个构造函数?2. this()在最后一个构造函数中做了什么.

public class Person {

    private String name;
    private String address;

    Person(){}
    Person(String name){
        this.name = name;
    }
    Person(String address){
        //Person(java.lang.String) is already defined.
    }

    Person(String name,String address){
        this();
        this.name = name;
        this.address = address;
    }
}

我的问题解决方案是Person(对象地址){this.address =(String)address; 但是,我不确定这一点.

我认为这(); 在最后一个构造函数中调用构造函数Person(){},但如果确实如此,是否意味着当我调用时会创建两个Person对象

Person p = new Person("myName","myAddress");

谢谢!!!

java constructor

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

我什么时候应该在 RMI 中实现 java.io.Serializable?

我刚刚开始使用 Java RMI,并且在何时使用 java.io.Serializable 时遇到了一些问题,所以任何人都可以给我一个必须实现 java.io.Serializable 的 RMI 示例。

谢谢!!!


更新:我做了一个简单的例子,但是,我认为仍然存在问题,因为输出不正确。人机界面

包服务器;导入 java.rmi.Remote; 导入 java.rmi.RemoteException; 导入 java.rmi.server.UnicastRemoteObject;

public interface PersonInterface extends Remote  
{
    public void setName(String name) throws RemoteException;
    public String getPerson() throws RemoteException;
    public void setAddress(Address address) throws RemoteException;
}
Run Code Online (Sandbox Code Playgroud)

个人实施

package server;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.rmi.Naming;
import java.rmi.Remote;

class Person extends UnicastRemoteObject implements PersonInterface
{
    private String name;
    private int age;
    private Address address;


    Person() throws RemoteException {super();}
    Person(String name,int age, Address address) throws RemoteException { …
Run Code Online (Sandbox Code Playgroud)

java rmi

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

带有$ LD_LIBRARY_PATH的Eclipse

我在目录/ usr/local/lib /中使用JNI构建了一些库文件.

如果我从luncher启动Eclipse,那么Eclipse永远不会选择路径,因此我需要为Run Configurations指定-Djava.library.path.

但是,如果我从命令行启动Eclipse.看起来工作正常.

有谁知道为什么它的行为如此以及如何配置它以从luncher知道/ usr/local/lib/path.谢谢.

我在Ubuntu OS上使用Eclipse SDK版本:3.6.2.

java eclipse path

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