小编I_d*_*now的帖子

终端机中的Google搜索

我正在尝试编写一个脚本,以便在终端中进行Google搜索。下面是代码:

google.sh

#!/bin/bash
echo "Searching for : $@"
for term in $@ ; do
    echo "$term"
    $search = $search%20$term
done
    open "http://www.google.com/search?q=$search"
Run Code Online (Sandbox Code Playgroud)

每当我尝试以以下方式运行脚本时:

./google.sh some string
Run Code Online (Sandbox Code Playgroud)

我得到的错误为:

Searching for : some string
some
./google.sh: line 5: =: command not found
string
./google.sh: line 5: =: command not found
Run Code Online (Sandbox Code Playgroud)

Google主页也会在浏览器中打开。请告诉我我在这里做错了什么?

bash google-search

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

如何使用Spring Security提供多种身份验证方式

我从各种资源中了解了Spring Security,我知道过滤器和身份验证管理器如何分别工作,但是我不确定请求与它们一起工作的确切顺序。如果我没看错,总之,请求首先通过过滤器,然后过滤器调用它们各自的身份验证管理器。

我想允许两种身份验证-一种使用JWT令牌,另一种使用用户名和密码。以下是来自security.xml的摘录

Security.xml

<http pattern="/api/**" create-session="stateless" realm="protected-apis" authentication-manager-ref="myAuthenticationManager" >
        <csrf disabled="true"/>
        <http-basic entry-point-ref="apiEntryPoint" />
        <intercept-url pattern="/api/my_api/**" requires-channel="any" access="isAuthenticated()" />  <!-- make https only. -->
        <custom-filter ref="authenticationTokenProcessingFilter" position = "FORM_LOGIN_FILTER"/>
</http>

<beans:bean id="authenticationTokenProcessingFilter"
                class="security.authentication.TokenAuthenticationFilter">
    <beans:constructor-arg value="/api/my_api/**" type="java.lang.String"/>
</beans:bean>

<authentication-manager id="myAuthenticationManager">
    <authentication-provider ref="myAuthenticationProvider" />
</authentication-manager>   

<beans:bean id="myAuthenticationProvider"
                class="security.authentication.myAuthenticationProvider" />
Run Code Online (Sandbox Code Playgroud)

MyAuthenticationProvider.java

public class MyAuthenticationProvider implements AuthenticationProvider {
    @Override
    public Authentication authenticate(Authentication authentication)
                                      throws AuthenticationException {
        // Code
    }

    @Override
    public boolean supports(Class<?> authentication) {
        return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
    }
}
Run Code Online (Sandbox Code Playgroud)

TokenAuthenticationFilter.java

public …
Run Code Online (Sandbox Code Playgroud)

java authentication spring spring-security

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