Skip to content

Commit df667d8

Browse files
author
Pascal Robert
committed
Removed the Basic-Auth stuff
1 parent 3aa99a1 commit df667d8

File tree

1 file changed

+0
-55
lines changed

1 file changed

+0
-55
lines changed

SimpleBlog/Sources/com/wowodc/rest/controllers/BaseRestController.java

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import er.rest.routes.ERXRouteController;
1616

1717
public class BaseRestController extends ERXRouteController {
18-
19-
private Person authenticatedUser;
2018

2119
public BaseRestController(WORequest request) {
2220
super(request);
@@ -39,62 +37,9 @@ protected ERXRestFormat defaultFormat() {
3937
protected boolean isAutomaticHtmlRoutingEnabled() {
4038
return true;
4139
}
42-
43-
protected void initAuthentication() throws NotAuthorizedException {
44-
String authValue = request().headerForKey( "authorization" );
45-
46-
if( authValue != null ) {
47-
try {
48-
byte[] authBytes = new BASE64Decoder().decodeBuffer( authValue.replace( "Basic ", "" ) );
49-
String[] parts = new String( authBytes ).split( ":", 2 );
50-
String username = parts[0];
51-
String password = parts[1];
52-
setAuthenticatedUser(Person.validateLogin(editingContext(), username, password));
53-
} catch ( IOException e ) {
54-
log.error( "Could not decode basic auth data: " + e.getMessage() );
55-
e.printStackTrace();
56-
}
57-
} else {
58-
throw new NotAuthorizedException();
59-
}
60-
}
61-
62-
protected Person authenticatedUser() {
63-
return authenticatedUser;
64-
}
65-
66-
@Override
67-
public WOActionResults performActionNamed(String actionName, boolean throwExceptions) {
68-
if (!isHTMlFormat()) {
69-
try {
70-
initAuthentication();
71-
} catch (NoSuchElementException ex) {
72-
WOResponse response = (WOResponse)errorResponse(ERXHttpStatusCodes.UNAUTHORIZED);
73-
response.setHeader("Basic realm=\"Members\"", "WWW-Authenticate");
74-
return response;
75-
} catch (NotAuthorizedException ex) {
76-
WOResponse response = (WOResponse)errorResponse(ERXHttpStatusCodes.UNAUTHORIZED);
77-
response.setHeader("Basic realm=\"Members\"", "WWW-Authenticate");
78-
return response;
79-
}
80-
}
81-
return super.performActionNamed(actionName, throwExceptions);
82-
}
83-
84-
protected void setAuthenticatedUser(Person authenticatedUser) {
85-
this.authenticatedUser = authenticatedUser;
86-
}
8740

8841
protected boolean isHTMlFormat() {
8942
return (ERXRestFormat.html().name().equals(this.format().name())) ? true: false;
9043
}
91-
92-
public class NotAuthorizedException extends Exception {
93-
94-
public NotAuthorizedException() {
95-
super();
96-
}
97-
98-
}
9944

10045
}

0 commit comments

Comments
 (0)