完成此1后,我已将代码添加到application.groovy
这样的
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
[pattern: '/', access: ['permitAll']],
[pattern: '/error', access: ['permitAll']],
[pattern: '/index', access: ['permitAll']],
[pattern: '/shutdown', access: ['permitAll']],
[pattern: '/assets/**', access: ['permitAll']],
[pattern: '/**/js/**', access: ['permitAll']],
[pattern: '/**/css/**', access: ['permitAll']],
[pattern: '/**/images/**', access: ['permitAll']],
[pattern: '/**/favicon.ico', access: ['permitAll']],
[pattern: '/login/ajaxSuccess', access: ['permitAll']],
[pattern: '/login/ajaxSuccess/**', access: ['permitAll']],
[pattern: '/**/ajaxSuccess/**', access: ['permitAll']]
我的错误日志变为post
这是corporateUserService.groovy文件
def getCurrentCifUser() { //line 949
def cifUser = CifUser.find("from com.vastpalaso.app.cif.CifUser cu where cu.userDetails.user.id=?", [
springSecurityService.principal.id //line 950
])
return cifUser
}
这是在logincotroller ..
def cifUser = corporateUserService.getCurrentCifUser() //line 168
答案 0 :(得分:1)
尝试将950段更改为:
def getCurrentCifUser() {
def cifUser = CifUser.find("from com.vastpalaso.app.cif.CifUser cu where cu.userDetails.user=?", [
springSecurityService.currentUser
])
return cifUser
}
如何在Android应用上更改HTTPURLConnection to be more like this:
public class BasicAuthenticationExample {
public static final String URL_SECURE = "[secure url]";
public static final String URL_LOGOUT = "[logout url]";
private HttpClient client = null;
/**
* Constructor for BasicAuthenticatonExample.
*/
public BasicAuthenticationExample(String host, int port) {
client = new HttpClient();
List<String> authPrefs = new ArrayList<String>(2);
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
client.getParams().setAuthenticationPreemptive(true);
client.getState().setCredentials(new AuthScope(host, port, AuthScope.ANY_REALM),
new UsernamePasswordCredentials(ConnectionConstants.USERNAME, ConnectionConstants.PASSWORD));
}
public static void main(String[] args) {
BasicAuthenticationExample example = new BasicAuthenticationExample("localhost", 8080);
// create a GET method that reads a file over HTTPS, we're assuming
// that this file requires basic authentication using the realm above.
GetMethod get = new GetMethod(URL_SECURE);
// Tell the GET method to automatically handle authentication. The
// method will use any appropriate credentials to handle basic
// authentication requests. Setting this value to false will cause
// any request for authentication to return with a status of 401.
// It will then be up to the client to handle the authentication.
get.setDoAuthentication(true);
try {
// execute the GET
int status = example.client.executeMethod(get);
// print the status and response
System.out.println(status + example.client.getState().toString() + "\n" + get.getStatusLine()
+ get.getResponseBodyAsString());
example.logout();
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// release any connection resources used by the method
get.releaseConnection();
}
}
private void logout() throws HttpException, IOException {
// create a GET method that reads a file over HTTPS, we're assuming
// that this file requires basic authentication using the realm above.
System.out.println("Logging out...");
System.out.println("--------------");
GetMethod get = new GetMethod(URL_LOGOUT);
try {
// execute the GET
int status = client.executeMethod(get);
// print the status and response
System.out.println(status + client.getState().toString() + "\n" + get.getStatusLine()
+ get.getResponseBodyAsString());
} finally {
// release any connection resources used by the method
get.releaseConnection();
}
}
}