Skip to content

Commit

Permalink
Work on authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosmo committed Jun 20, 2012
1 parent a236483 commit 8c99193
Show file tree
Hide file tree
Showing 15 changed files with 221 additions and 295 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "http://rubygems.org"
gem "buildr", "= 1.4.7"

56 changes: 56 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
GEM
remote: http://rubygems.org/
specs:
atoulme-Antwrap (0.7.2-java)
bouncy-castle-java (1.5.0146.1)
builder (2.1.2)
buildr (1.4.7-java)
atoulme-Antwrap (~> 0.7.2)
builder (= 2.1.2)
diff-lcs (= 1.1.3)
highline (= 1.6.2)
hoe (= 2.3.3)
jruby-openssl (>= 0.7)
json_pure (= 1.4.3)
minitar (= 0.5.3)
net-sftp (= 2.0.5)
net-ssh (= 2.3.0)
rake (= 0.9.2.2)
rspec (= 2.9.0)
rspec-core (= 2.9.0)
rspec-expectations (= 2.9.0)
rspec-mocks (= 2.9.0)
rubyforge (= 2.0.3)
rubyzip (= 0.9.4)
xml-simple (= 1.0.12)
diff-lcs (1.1.3)
highline (1.6.2)
hoe (2.3.3)
rake (>= 0.8.7)
rubyforge (>= 1.0.4)
jruby-openssl (0.7.7)
bouncy-castle-java (>= 1.5.0146.1)
json_pure (1.4.3)
minitar (0.5.3)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.3.0)
rake (0.9.2.2)
rspec (2.9.0)
rspec-core (~> 2.9.0)
rspec-expectations (~> 2.9.0)
rspec-mocks (~> 2.9.0)
rspec-core (2.9.0)
rspec-expectations (2.9.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.9.0)
rubyforge (2.0.3)
json_pure (>= 1.1.7)
rubyzip (0.9.4)
xml-simple (1.0.12)

PLATFORMS
java

DEPENDENCIES
buildr (= 1.4.7)
6 changes: 6 additions & 0 deletions architecture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
t.string(:Name, 255)
end

data_module.enumeration(:UserType, :integer, :values => {"STAFF" => 0 ,"ADMIN" => 1})

data_module.entity(:User) do |t|
t.integer(:ID, :primary_key => true)
t.string(:Login, 255)
t.string(:Name, 255)
t.string(:Email, 255)
t.string(:Password, 255)
t.enumeration(:UserType, :UserType)
t.unique_constraint([:Login])
t.unique_constraint([:Name])
end
Expand All @@ -32,6 +35,7 @@
s.text(:Login)
s.text(:Name)
s.text(:Email)
s.enumeration(:UserType, :UserType)
end

data_module.entity(:Project) do |t|
Expand All @@ -55,6 +59,7 @@
m.string(:Name, 255)
m.string(:Password, 255)
m.string(:Email, 255)
m.enumeration(:UserType, :UserType)
m.returns(:struct, :referenced_struct => :UserDTO)
end

Expand All @@ -67,6 +72,7 @@
m.string(:Login, 255)
m.string(:Name, 255)
m.string(:Email, 255)
m.enumeration(:UserType, :UserType)
m.returns(:struct, :referenced_struct => :UserDTO)
end

Expand Down
3 changes: 2 additions & 1 deletion build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gems:
repositories:
remote:
- http://repo.fire.dse.vic.gov.au/content/groups/fisg
- http://repo1.maven.org/
- http://repo1.maven.org/maven2
release_to:
url: http://repo.fire.dse.vic.gov.au/content/repositories/releases/
username: upload
Expand All @@ -24,6 +24,7 @@ artifacts:
javax_persistence: org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final
javax_transaction: javax.transaction:jta:jar:1.1
javax_annotation: com.google.code.findbugs:jsr305:jar:1.3.9
javax_security_annotations: org.apache.tomcat:annotations-api:jar:6.0.35
javax_interceptor: org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.1_spec:jar:1.0.0.Final
javax_jaxrpc: org.apache.geronimo.specs:geronimo-jaxrpc_1.1_spec:jar:2.1

Expand Down
14 changes: 8 additions & 6 deletions buildfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ define('tide', :layout => layout) do
:javax_servlet,
:javax_validation,
:javax_annotation,
:javax_security_annotations,
:jackson_core,
:jackson_mapper,
:gxt,
:gxt_uibinder,
:javax_annotation,
:gwt_user,
:google_guice,
:aopalliance,
:google_guice_assistedinject,
Expand All @@ -36,7 +35,7 @@ define('tide', :layout => layout) do
test.with :mockito, :guiceyloops, :eclipselink, :jtds
test.using :testng

tide_module = gwt(["au.com.stocksoftware.tide.Tide"],
tide_module = gwt(["au.com.stocksoftware.tide.TideDev"],
:dependencies => [project.compile.dependencies,
project.compile.target,
:gxt,
Expand Down Expand Up @@ -65,12 +64,15 @@ define('tide', :layout => layout) do
iml.add_ejb_facet
iml.add_web_facet

ipr.add_exploded_war_artifact(project,
:dependencies => [project, :gwt_user],
end

Buildr.project('tide').ipr.add_exploded_war_artifact(project('tide'),
:name => 'tide',
:dependencies => [project('tide'), :gwt_user],
:enable_gwt => true,
:enable_ejb => true,
:enable_jpa => true)
end


define_dbt_tasks(Buildr.project('tide'))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class AdminUsersPresenter

@Inject
private UserService _userService;

private UserVO _currentUser;
private boolean _newUser;

Expand Down Expand Up @@ -78,6 +79,7 @@ public void actionSave()
if ( null != _currentUser )
{
_userService.updateUser( _currentUser.getId(), newValues.getLogin(), newValues.getName(), newValues.getEmail(),
newValues.getUserType(),
new AsyncCallback<UserDTO>()
{
@Override
Expand All @@ -92,6 +94,7 @@ public void onSuccess( final UserDTO updatedUser )
else if ( _newUser )
{
_userService.addUser( newValues.getLogin(), newValues.getName(), "password", newValues.getEmail(),
newValues.getUserType(),
new AsyncCallback<UserDTO>()
{
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package au.com.stocksoftware.tide.client.entity;

import au.com.stocksoftware.tide.client.data_type.core.UserType;
import java.util.List;
import javax.annotation.Nonnull;

Expand All @@ -9,16 +10,19 @@ public class UserVO
private String _login;
private String _name;
private String _email;
private UserType _userType;

public UserVO( final int id,
@Nonnull final String login,
@Nonnull final String name,
@Nonnull final String email )
@Nonnull final String email,
@Nonnull final UserType userType )
{
_id = id;
_login = login;
_name = name;
_email = email;
_userType = userType;
}

public int getId()
Expand All @@ -40,4 +44,9 @@ public String getLogin()
{
return _login;
}

public UserType getUserType()
{
return _userType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public static UserVO userDTOToVO( final UserDTO dto )
return new UserVO( dto.getID(),
dto.getLogin(),
dto.getName(),
dto.getEmail() );
dto.getEmail(),
dto.getUserType());
}

public static List<ProjectVO> projectDTOsToVOs( final List<ProjectDTO> dtos )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.com.stocksoftware.tide.client.view.ui;

import au.com.stocksoftware.tide.client.activity.AdminUsersPresenter;
import au.com.stocksoftware.tide.client.data_type.core.UserType;
import au.com.stocksoftware.tide.client.entity.UserVO;
import au.com.stocksoftware.tide.client.view.AdminUsersView;
import com.google.gwt.core.client.GWT;
Expand All @@ -15,6 +16,7 @@
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.core.client.ValueProvider;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
Expand All @@ -23,6 +25,7 @@
import com.sencha.gxt.widget.core.client.ListView;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.form.ComboBox;
import com.sencha.gxt.widget.core.client.form.TextField;
import java.util.List;

Expand Down Expand Up @@ -64,6 +67,9 @@ public class AdminUsersUI

@UiField
ContentPanel _userContentPanel;

@UiField
ComboBox<UserType> _type;

Presenter _presenter;

Expand Down Expand Up @@ -103,7 +109,7 @@ public void setPresenter( final AdminUsersPresenter presenter )
@Override
public void showAddUser()
{
_userList.getSelectionModel().deselectAll( );
_userList.getSelectionModel().deselectAll();
updateValues( null );
enableFields( true );
_userLogin.focus();
Expand Down Expand Up @@ -132,13 +138,14 @@ public void clearCurrentUser()
updateValues( null );
enableFields( false );
configureButtons( false, false, false, false, false );
_userList.getSelectionModel().deselectAll( );
_userList.getSelectionModel().deselectAll();
}

@Override
public UserVO getCurrentValues()
{
return new UserVO( -1, _userLogin.getCurrentValue(), _userName.getCurrentValue(), _userEmail.getCurrentValue() );
return new UserVO( -1, _userLogin.getCurrentValue(), _userName.getCurrentValue(), _userEmail.getCurrentValue(),
UserType.STAFF );
}

@Override
Expand All @@ -155,7 +162,8 @@ ListView createListView()
final ListView<UserVO, String> list = new ListView<UserVO, String>(
new ListStore<UserVO>( userProperties.key() ), userProperties.name() );

list.getSelectionModel().addSelectionHandler( new SelectionHandler<UserVO>() {
list.getSelectionModel().addSelectionHandler( new SelectionHandler<UserVO>()
{
@Override
public void onSelection( final SelectionEvent<UserVO> userVOSelectionEvent )
{
Expand All @@ -166,6 +174,16 @@ public void onSelection( final SelectionEvent<UserVO> userVOSelectionEvent )
return list;
}

@UiFactory
ComboBox<UserType> createUserTypeCombo()
{
final UserTypeProperties props = GWT.create( UserTypeProperties.class );

final ListStore<UserType> store = new ListStore<UserType>(props.key());

return new ComboBox<UserType>(store, props.name());
}

interface UserProperties
extends PropertyAccess<UserVO>
{
Expand All @@ -176,6 +194,16 @@ interface UserProperties
ValueProvider<UserVO, String> name();
}

interface UserTypeProperties
extends PropertyAccess<UserType>
{
@Path( "ordinal" )
ModelKeyProvider<UserType> key();

@Path( "name" )
LabelProvider<UserType> name();
}

@UiHandler( { "_addButton" } )
public void onAddUserClicked( final SelectEvent event )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@
</container:west>
<container:center>
<g:VerticalPanel spacing="10">
<c:ContentPanel width="280" height="120" headerVisible="false" borders="false" bodyBorder="false"
<c:ContentPanel width="280" height="160" headerVisible="false" borders="false" bodyBorder="false"
bodyStyle="background: none; padding: 5px" ui:field="_userContentPanel">
<container:VerticalLayoutContainer>
<container:child layoutData="{verticalLayoutData}">
<form:FieldLabel text="User Type">
<form:widget>
<form:ComboBox ui:field="_type" allowBlank="true" forceSelection="true" triggerAction="ALL"/>
</form:widget>
</form:FieldLabel>
</container:child>
<container:child layoutData="{verticalLayoutData}">
<form:FieldLabel text="Login">
<form:widget>
Expand Down
Loading

0 comments on commit 8c99193

Please sign in to comment.