git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/auth-portlet-manager@133825 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
cfccbff824
commit
d574f0766d
|
@ -8,6 +8,7 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.portlets.admin.authportletmanager.client.event.AddPoliciesEvent;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.event.AddQuoteEvent;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.event.ListContextEvent;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.event.ListPolicyEvent;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.event.ListQuoteEvent;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.event.RemovePoliciesEvent;
|
||||
|
@ -91,14 +92,17 @@ public class AuthManagerController {
|
|||
|
||||
public AuthManagerController() {
|
||||
eventBus = new SimpleEventBus();
|
||||
|
||||
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
loadContext();
|
||||
loadMainPanel();
|
||||
loadEnviromentPolicy();
|
||||
//loadEnviromentQuote();
|
||||
|
||||
bindToEvents();
|
||||
}
|
||||
|
||||
|
@ -124,6 +128,7 @@ public class AuthManagerController {
|
|||
|
||||
GWT.log("AuthManager -Init Start with -DEBUG_MODE:"+ConstantsSharing.DEBUG_MODE+" DEBUG_TOKEN:"+ConstantsSharing.DEBUG_TOKEN+" MOCKUP:"+ConstantsSharing.MOCK_UP);
|
||||
|
||||
|
||||
AuthResources.INSTANCE.authCSS().ensureInjected();
|
||||
|
||||
mainPanelLayout = new Container();
|
||||
|
@ -150,12 +155,13 @@ public class AuthManagerController {
|
|||
Tab tab_quota =new Tab();
|
||||
tab_quota.add(dockQuota);
|
||||
tab_quota.setHeading("QUOTA");
|
||||
*/
|
||||
*/
|
||||
|
||||
TabPanel tabPanel = new TabPanel();
|
||||
tabPanel.add(tab_policy);
|
||||
//tabPanel.add(tab_quota);
|
||||
|
||||
|
||||
tab_policy.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
@ -217,11 +223,15 @@ public class AuthManagerController {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void loadPolicy(final int numberLoad){
|
||||
//reset provider
|
||||
final String context=PolicyDataProvider.get().getContext();
|
||||
|
||||
PolicyDataProvider.get().resetPolicyProvider();
|
||||
AuthManagerServiceAsync.INSTANCE
|
||||
.loadListPolicy(new AsyncCallback<ArrayList<PolicyAuth>>() {
|
||||
.loadListPolicy(context,new AsyncCallback<ArrayList<PolicyAuth>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
|
@ -238,7 +248,7 @@ public class AuthManagerController {
|
|||
@Override
|
||||
public void onSuccess(ArrayList<PolicyAuth> result) {
|
||||
PolicyDataProvider.get().loadPolicyProvider(result);
|
||||
GWT.log("AuthManager - Load Policy complete");
|
||||
GWT.log("AuthManager - Load Policy complete on context:"+context);
|
||||
checkLoader(numberLoad,0);
|
||||
|
||||
}
|
||||
|
@ -249,9 +259,10 @@ public class AuthManagerController {
|
|||
* Load a caller from AsyncCallBack from server
|
||||
*/
|
||||
private void loadCaller(final int numberLoad){
|
||||
|
||||
//String context= "/gcube/devNext";
|
||||
String context=PolicyDataProvider.get().getContext();
|
||||
AuthManagerServiceAsync.INSTANCE
|
||||
.loadListCaller(new AsyncCallback<ArrayList<Caller>>() {
|
||||
.loadListCaller(context,new AsyncCallback<ArrayList<Caller>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -282,9 +293,10 @@ public class AuthManagerController {
|
|||
|
||||
|
||||
public void loadServicePolicy(final int numberLoad){
|
||||
|
||||
//String context= "/gcube/devNext";
|
||||
String context=PolicyDataProvider.get().getContext();
|
||||
AuthManagerServiceAsync.INSTANCE
|
||||
.loadListService(new AsyncCallback<Map<String, List<String>>>() {
|
||||
.loadListService(context,new AsyncCallback<Map<String, List<String>>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -341,6 +353,34 @@ public class AuthManagerController {
|
|||
|
||||
|
||||
|
||||
private void loadContext(){
|
||||
AuthManagerServiceAsync.INSTANCE
|
||||
.loadRetrieveListContexts(new AsyncCallback<ArrayList<String>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof ExpiredSessionServiceException) {
|
||||
GWT.log("AuthManager - Alert Expired Session");
|
||||
sessionExpiredShowDelayed();
|
||||
} else {
|
||||
dialogLoader.stopLoader();
|
||||
dialogError.showError(caught.getLocalizedMessage());
|
||||
GWT.log("AuthManager - Failed to load a list context:"+caught.getLocalizedMessage());
|
||||
caught.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(ArrayList<String> result) {
|
||||
GWT.log("AuthManager - Load Context complete loadListContext"+result.toString());
|
||||
// TODO Auto-generated method stub
|
||||
PolicyDataProvider.get().setContextList(result);
|
||||
policyfilter.setInitContext();
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -406,23 +446,6 @@ public class AuthManagerController {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
private void checkLocale() {
|
||||
String[] locales = LocaleInfo.getAvailableLocaleNames();
|
||||
|
||||
for (String locale : locales) {
|
||||
//Log.debug("Locale avaible:" + locale);
|
||||
}
|
||||
|
||||
String currentLocaleCookie = Cookies.getCookie(LocaleInfo
|
||||
.getLocaleCookieName());
|
||||
//Log.debug(Constants.AM_LANG_COOKIE + ":" + currentLocaleCookie);
|
||||
|
||||
LocaleInfo currentLocaleInfo = LocaleInfo.getCurrentLocale();
|
||||
//Log.debug("Current Locale:" + currentLocaleInfo.getLocaleName());
|
||||
|
||||
}
|
||||
*/
|
||||
protected void changeLanguage(String localeName) {
|
||||
Date now = new Date();
|
||||
long nowLong = now.getTime();
|
||||
|
@ -486,7 +509,18 @@ public class AuthManagerController {
|
|||
|
||||
});
|
||||
|
||||
//event bus for load context
|
||||
eventBus.addHandler(ListContextEvent.TYPE,
|
||||
new ListContextEvent.ListContextEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onAdd(ListContextEvent event) {
|
||||
// TODO Auto-generated method stub
|
||||
loadContext();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
/***
|
||||
|
@ -542,8 +576,9 @@ public class AuthManagerController {
|
|||
final List<PolicyAuth> policies = event.getPolicies();
|
||||
final PolicyAddDialog policyAddDialog =event.getDialog();
|
||||
dialogLoader.startLoader();
|
||||
String context=PolicyDataProvider.get().getContext();
|
||||
AuthManagerServiceAsync.INSTANCE.
|
||||
addPolicies(policies,new AsyncCallback<Void>() {
|
||||
addPolicies(context,policies,new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -611,10 +646,9 @@ public class AuthManagerController {
|
|||
protected void updatePolicy(UpdatePolicyEvent event) {
|
||||
final PolicyAuth policies = event.getPolicies();
|
||||
final PolicyAddDialog policyUpdateDialog =event.getDialog();
|
||||
|
||||
String context=PolicyDataProvider.get().getContext();
|
||||
dialogLoader.startLoader();
|
||||
|
||||
AuthManagerServiceAsync.INSTANCE.updatePolicy(policies,new AsyncCallback<Void>() {
|
||||
AuthManagerServiceAsync.INSTANCE.updatePolicy(context,policies,new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -753,6 +787,9 @@ public class AuthManagerController {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void asyncCodeLoadingFailed(Throwable reason) {
|
||||
//Log.error("Async code loading failed", reason);
|
||||
|
|
|
@ -22,6 +22,7 @@ public class Entities {
|
|||
private static ArrayList<Caller> callers;
|
||||
private static Map<String, List<String>> servicesMap;
|
||||
private static ArrayList<String> access;
|
||||
//private static ArrayList<String> context =new ArrayList<String>();
|
||||
|
||||
|
||||
private Entities(){
|
||||
|
@ -92,4 +93,6 @@ public class Entities {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package org.gcube.portlets.admin.authportletmanager.client.event;
|
||||
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.google.gwt.event.shared.HasHandlers;
|
||||
|
||||
public class ListContextEvent extends GwtEvent<ListContextEvent.ListContextEventHandler> {
|
||||
|
||||
|
||||
|
||||
public static Type<ListContextEventHandler> TYPE = new Type<ListContextEventHandler>();
|
||||
|
||||
public static Type<ListContextEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<ListContextEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public interface ListContextEventHandler extends EventHandler {
|
||||
void onAdd(ListContextEvent event);
|
||||
}
|
||||
|
||||
public interface HasListPolicyEventHandler extends HasHandlers {
|
||||
public HandlerRegistration addListContextEventHandler(
|
||||
ListContextEventHandler handler);
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source,
|
||||
ListContextEvent event) {
|
||||
source.fireEvent(event);
|
||||
}
|
||||
|
||||
public ListContextEvent() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(ListContextEventHandler handler) {
|
||||
// TODO Auto-generated method stub
|
||||
handler.onAdd(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -19,8 +19,12 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.ConstantsSharing;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.PolicyAuth;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.view.client.HasData;
|
||||
|
@ -53,11 +57,32 @@ public class PolicyDataProvider {
|
|||
*/
|
||||
private ListDataProvider<PolicyAuth> dataProvider = new ListDataProvider<PolicyAuth>();
|
||||
|
||||
private String context=null;
|
||||
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public void setContext(String context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
private ArrayList<String> contextList=new ArrayList<String>();
|
||||
|
||||
public ArrayList<String> getContextList() {
|
||||
return contextList;
|
||||
}
|
||||
|
||||
public void setContextList(ArrayList<String> contextList) {
|
||||
this.contextList = contextList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The list string used for search
|
||||
*/
|
||||
private List<String> initialSearch= new ArrayList<String>();;
|
||||
private List<String> initialSearch= new ArrayList<String>();
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package org.gcube.portlets.admin.authportletmanager.client.pagelayout;
|
||||
|
||||
import org.gcube.portlets.admin.authportletmanager.client.AuthManagerController;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.Entities;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.event.ListPolicyEvent;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.widget.BulletList;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.widget.ListItem;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.widget.Paragraph;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.widget.Span;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.Caller.TypeCaller;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.ConstantsSharing;
|
||||
import org.gcube.portlets.widgets.widgettour.client.extendedclasses.GCubeTour;
|
||||
|
||||
import com.ait.toolkit.hopscotch.client.Placement;
|
||||
|
@ -14,8 +16,11 @@ import com.ait.toolkit.hopscotch.client.TourStep;
|
|||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.ButtonGroup;
|
||||
import com.github.gwtbootstrap.client.ui.InputAddOn;
|
||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyCodes;
|
||||
|
@ -67,6 +72,10 @@ public class PolicyFilter extends Composite {
|
|||
Button b_group_service;
|
||||
|
||||
|
||||
@UiField
|
||||
ListBox l_context;
|
||||
|
||||
|
||||
@UiField
|
||||
Button b_search_start;
|
||||
|
||||
|
@ -91,7 +100,8 @@ public class PolicyFilter extends Composite {
|
|||
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
initFilter();
|
||||
// guideTour();
|
||||
|
||||
// guideTour();
|
||||
|
||||
}
|
||||
|
||||
|
@ -140,13 +150,40 @@ public class PolicyFilter extends Composite {
|
|||
* Init filter
|
||||
*/
|
||||
public void initFilter(){
|
||||
|
||||
|
||||
list = new BulletList();
|
||||
list.setStyleName("input-list-caller");
|
||||
list.clear();
|
||||
}
|
||||
|
||||
public void setInitContext(){
|
||||
for (String context:PolicyDataProvider.get().getContextList()){
|
||||
l_context.addItem(context,context);
|
||||
}
|
||||
|
||||
|
||||
l_context.addChangeHandler(new ChangeHandler() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void onChange(ChangeEvent event) {
|
||||
int indexC = l_context.getSelectedIndex();
|
||||
String newValue =l_context.getValue(indexC);
|
||||
PolicyDataProvider.get().setContext(newValue);
|
||||
GWT.log("AuthManager - initContext"+newValue);
|
||||
list.clear();
|
||||
b_group_none.setFocus(true);
|
||||
b_group_none.setActive(true);
|
||||
|
||||
b_group_user.setFocus(false);
|
||||
b_group_user.setActive(false);
|
||||
|
||||
b_group_role.setFocus(false);
|
||||
b_group_role.setActive(false);
|
||||
|
||||
b_group_service.setFocus(false);
|
||||
b_group_service.setActive(false);
|
||||
AuthManagerController.eventBus.fireEvent(new ListPolicyEvent());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@UiHandler("t_search")
|
||||
public void onKeyDown(KeyDownEvent event) {
|
||||
|
@ -319,4 +356,8 @@ public class PolicyFilter extends Composite {
|
|||
PolicyDataProvider.get().refreshlistFromSearch(typeSearch);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
.btn_search {
|
||||
border-radius: 0px 8px 8px 0 !important;
|
||||
-webkit-border-radius: 0px 8px 8px 0 !important;;
|
||||
-webkit-border-radius: 0px 8px 8px 0 !important;
|
||||
-moz-border-radius: 0px 8px 8px 0 !important;
|
||||
margin-right: 30px !important;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
|||
-webkit-border-radius: 0px;
|
||||
border-radius: 0px !important;
|
||||
}
|
||||
|
||||
.btn_search_start:before {
|
||||
color: #333333;
|
||||
content: "\f036";
|
||||
|
@ -36,12 +37,24 @@
|
|||
display: inline-block;
|
||||
font-family: "fontawesome";
|
||||
}
|
||||
|
||||
.filter_bar {
|
||||
height: 30px;
|
||||
padding: 2px;
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.context_bar {
|
||||
height: 30px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.context_bar_select {
|
||||
display: block !important;
|
||||
margin: auto !important;
|
||||
}
|
||||
|
||||
.label_wizard_policy {
|
||||
margin-left: 10 px;
|
||||
font-size: 15 px;
|
||||
|
@ -50,6 +63,12 @@
|
|||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<b:WellForm type="SEARCH" ui:field="form_search">
|
||||
<g:FlowPanel addStyleNames="{style.context_bar}"
|
||||
ui:field="string_context">
|
||||
<b:ListBox ui:field="l_context" addStyleNames="{style.context_bar_select}">
|
||||
</b:ListBox>
|
||||
|
||||
</g:FlowPanel>
|
||||
<b:ControlGroup>
|
||||
<b:Controls>
|
||||
<b:Tooltip text='Delete Policy'>
|
||||
|
@ -60,9 +79,6 @@
|
|||
<b:Button type="SUCCESS" addStyleNames="btn btn_add"
|
||||
ui:field="b_add_policy" />
|
||||
</b:Tooltip>
|
||||
|
||||
|
||||
|
||||
<b:InputAddOn prependIcon="SEARCH" ui:field="i_search"
|
||||
b:id="idSearchPolicy">
|
||||
|
||||
|
@ -112,10 +128,11 @@
|
|||
</b:Tooltip>
|
||||
<span styleName="{style.label_wizard_policy}">
|
||||
Create policy to deny access to Services
|
||||
in the current context
|
||||
in the
|
||||
current context
|
||||
</span>
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
</b:ControlGroup>
|
||||
<g:FlowPanel addStyleNames="{style.filter_bar}" ui:field="string_search">
|
||||
</g:FlowPanel>
|
||||
</b:WellForm>
|
||||
|
|
|
@ -4,9 +4,11 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.Caller;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.PolicyAuth;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.Quote;
|
||||
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.exceptions.ServiceException;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
|
@ -27,17 +29,23 @@ public interface AuthManagerService extends RemoteService {
|
|||
* Get informations on the current user
|
||||
*
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
* @throws Throwable
|
||||
* @throws AccountingManagerServiceException
|
||||
*/
|
||||
|
||||
// Service for load context
|
||||
public ArrayList<String> loadRetrieveListContexts() throws ServiceException ;
|
||||
|
||||
|
||||
// Service for load Policy
|
||||
public ArrayList<PolicyAuth> loadListPolicy() throws ServiceException;
|
||||
public ArrayList<PolicyAuth> loadListPolicy(String context) throws ServiceException;
|
||||
|
||||
// Service for load Caller
|
||||
public ArrayList<Caller> loadListCaller() throws ServiceException;
|
||||
public ArrayList<Caller> loadListCaller(String context) throws ServiceException;
|
||||
|
||||
//Service for load Service
|
||||
public Map<String, List<String>> loadListService()throws ServiceException;
|
||||
public Map<String, List<String>> loadListService(String context)throws ServiceException;
|
||||
|
||||
//Service for load Access
|
||||
public ArrayList<String> loadListAccess() throws ServiceException;
|
||||
|
@ -47,10 +55,10 @@ public interface AuthManagerService extends RemoteService {
|
|||
List<Long> deletePolicies(List<Long>identifier) throws ServiceException;
|
||||
|
||||
|
||||
public void addPolicies(List<PolicyAuth>identifier) throws ServiceException;
|
||||
public void addPolicies(String context,List<PolicyAuth>identifier) throws ServiceException;
|
||||
|
||||
//Service for update policy
|
||||
public void updatePolicy(PolicyAuth policies) throws ServiceException;
|
||||
public void updatePolicy(String context,PolicyAuth policies) throws ServiceException;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -26,11 +26,14 @@ public interface AuthManagerServiceAsync {
|
|||
.create(AuthManagerService.class);
|
||||
|
||||
//load init value
|
||||
void loadListPolicy(AsyncCallback<ArrayList<PolicyAuth>> callback);
|
||||
|
||||
void loadListCaller(AsyncCallback<ArrayList<Caller>> callback);
|
||||
void loadRetrieveListContexts(AsyncCallback<ArrayList<String>> callback);
|
||||
|
||||
void loadListService(AsyncCallback<Map<String, List<String>>> asyncCallback);
|
||||
void loadListPolicy(String context,AsyncCallback<ArrayList<PolicyAuth>> callback);
|
||||
|
||||
void loadListCaller(String context,AsyncCallback<ArrayList<Caller>> callback);
|
||||
|
||||
void loadListService(String context,AsyncCallback<Map<String, List<String>>> asyncCallback);
|
||||
|
||||
void loadListAccess(AsyncCallback<ArrayList<String>> callback);
|
||||
|
||||
|
@ -45,9 +48,9 @@ public interface AuthManagerServiceAsync {
|
|||
AsyncCallback<Long> callback);
|
||||
*/
|
||||
|
||||
void updatePolicy(PolicyAuth policies, AsyncCallback<Void> callback);
|
||||
void updatePolicy(String context,PolicyAuth policies, AsyncCallback<Void> callback);
|
||||
|
||||
void addPolicies(List<PolicyAuth> identifier,AsyncCallback<Void> asyncCallback);
|
||||
void addPolicies(String context,List<PolicyAuth> identifier,AsyncCallback<Void> asyncCallback);
|
||||
|
||||
void deletePolicies(List<Long> identifier,AsyncCallback<List<Long>> callback);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -15,6 +16,7 @@ import java.util.Map;
|
|||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.common.authorization.library.policies.Action;
|
||||
import org.gcube.common.authorization.library.policies.Policy;
|
||||
|
@ -26,7 +28,9 @@ import org.gcube.common.authorization.library.policies.Services;
|
|||
import org.gcube.common.authorization.library.policies.User2ServicePolicy;
|
||||
import org.gcube.common.authorization.library.policies.Users;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.library.provider.UserInfo;
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.admin.authportletmanager.client.rpc.AuthManagerService;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.Access;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.Caller;
|
||||
|
@ -35,6 +39,7 @@ import org.gcube.portlets.admin.authportletmanager.shared.ConstantsSharing;
|
|||
import org.gcube.portlets.admin.authportletmanager.shared.PolicyAuth;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.Quote;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.Service;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.exceptions.ContextException;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.exceptions.ServiceException;
|
||||
import org.gcube.portlets.admin.authportletmanager.shared.exceptions.TypeCallerException;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
|
@ -42,9 +47,12 @@ import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
|||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -81,24 +89,32 @@ implements AuthManagerService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load all list policy
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<PolicyAuth> loadListPolicy() throws ServiceException {
|
||||
public ArrayList<PolicyAuth> loadListPolicy(String context) throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ArrayList<PolicyAuth> policyList =new ArrayList<PolicyAuth>();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String scope=aslSession.getScope();
|
||||
String token =aslSession.getSecurityToken();
|
||||
String username = aslSession.getUsername();
|
||||
//String scope=aslSession.getScope();
|
||||
//String token =aslSession.getSecurityToken();
|
||||
if (context==null)
|
||||
context=aslSession.getScope();
|
||||
String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList<String>()), context);
|
||||
if (ConstantsSharing.DEBUG_MODE) {
|
||||
token=ConstantsSharing.DEBUG_TOKEN;
|
||||
scope="/gcube/devNext";
|
||||
logger.debug("load list policy in scope:"+scope);
|
||||
context="/gcube/devNext";
|
||||
logger.debug("load list policy in scope:"+context);
|
||||
}
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
List<Policy> policies = authorizationService().getPolicies(scope);
|
||||
List<Policy> policies = authorizationService().getPolicies(context);
|
||||
if (policies!=null){
|
||||
logger.info("Load List Policy Find:"+policies.size());
|
||||
if (policies.size()>0){
|
||||
|
@ -169,17 +185,25 @@ implements AuthManagerService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load all caller
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<Caller> loadListCaller() throws ServiceException {
|
||||
public ArrayList<Caller> loadListCaller(String context) throws ServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
@SuppressWarnings("unused")
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
ArrayList<Caller> callers =new ArrayList<Caller>();
|
||||
String token =aslSession.getSecurityToken();
|
||||
String username = aslSession.getUsername();
|
||||
//String scope=aslSession.getScope();
|
||||
//String token =aslSession.getSecurityToken();
|
||||
if (context==null)
|
||||
context=aslSession.getScope();
|
||||
String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList<String>()), context);
|
||||
if (ConstantsSharing.DEBUG_MODE) {
|
||||
token=ConstantsSharing.DEBUG_TOKEN;
|
||||
}
|
||||
|
@ -198,9 +222,9 @@ implements AuthManagerService {
|
|||
else{
|
||||
RoleManager roleManager = new LiferayRoleManager();
|
||||
UserManager userManager = new LiferayUserManager();
|
||||
String scope=SessionUtil.getASLSession(session).getScope();
|
||||
//String scope=SessionUtil.getASLSession(session).getScope();
|
||||
GroupManager groupManager= new LiferayGroupManager();
|
||||
Long groupId= groupManager.getGroupIdFromInfrastructureScope(scope);
|
||||
Long groupId= groupManager.getGroupIdFromInfrastructureScope(context);
|
||||
for (GCubeUser user :userManager.listUsersByGroup(groupId)){
|
||||
callers.add(new Caller(TypeCaller.user,user.getUsername()));
|
||||
}
|
||||
|
@ -236,11 +260,16 @@ implements AuthManagerService {
|
|||
* Load all service
|
||||
*/
|
||||
@Override
|
||||
public Map<String, List<String>> loadListService() throws ServiceException {
|
||||
public Map<String, List<String>> loadListService(String context) throws ServiceException {
|
||||
try {
|
||||
logger.debug("loadListService init with context:"+context);
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
@SuppressWarnings("unused")
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
if (context==null){
|
||||
context=aslSession.getScope();
|
||||
logger.debug("Context void,loadListService init with context:"+context);
|
||||
}
|
||||
Map<String, List<String>> services =new HashMap<String, List<String>>();
|
||||
if (ConstantsSharing.DEBUG_MODE) {
|
||||
String token=ConstantsSharing.DEBUG_TOKEN;
|
||||
|
@ -253,6 +282,10 @@ implements AuthManagerService {
|
|||
}
|
||||
else{
|
||||
//Get List service
|
||||
String username = aslSession.getUsername();
|
||||
String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList<String>()), context);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
|
||||
SimpleQuery query = queryFor(GCoreEndpoint.class);
|
||||
query.setResult("<Service><ServiceClass>{$resource/Profile/ServiceClass/text()}</ServiceClass>" +
|
||||
"<ServiceName>{$resource/Profile/ServiceName/text()}</ServiceName></Service>");
|
||||
|
@ -267,7 +300,7 @@ implements AuthManagerService {
|
|||
}
|
||||
return services;
|
||||
} catch (ServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
logger.error("service errore"+e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
|
@ -307,36 +340,96 @@ implements AuthManagerService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ArrayList<String> loadRetrieveListContexts() throws ServiceException {
|
||||
try {
|
||||
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token =aslSession.getSecurityToken();
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
ArrayList<String> toReturn = new ArrayList<String>();
|
||||
String currentContext = ScopeProvider.instance.get();
|
||||
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
long currentGroupId = gm.getGroupIdFromInfrastructureScope(currentContext);
|
||||
GCubeGroup currentGroup = gm.getGroup(currentGroupId);
|
||||
// three cases
|
||||
if(gm.isVRE(currentGroupId)){
|
||||
// do nothing
|
||||
}else if(gm.isVO(currentGroupId)){
|
||||
// iterate over its vres
|
||||
List<GCubeGroup> children = currentGroup.getChildren();
|
||||
for (GCubeGroup gCubeGroup : children) {
|
||||
logger.debug("loadListContext add: " + gm.getInfrastructureScope(gCubeGroup.getGroupId()));
|
||||
toReturn.add(gm.getInfrastructureScope(gCubeGroup.getGroupId()));
|
||||
}
|
||||
}else{
|
||||
// is root
|
||||
List<GCubeGroup> children = currentGroup.getChildren();
|
||||
for (GCubeGroup gCubeGroup : children) {
|
||||
toReturn.add(gm.getInfrastructureScope(gCubeGroup.getGroupId()));
|
||||
|
||||
// get the vo children
|
||||
List<GCubeGroup> childrenVO = gCubeGroup.getChildren();
|
||||
for (GCubeGroup voChildren : childrenVO) {
|
||||
logger.debug("loadListContext add: " + gm.getInfrastructureScope(voChildren.getGroupId()));
|
||||
toReturn.add(gm.getInfrastructureScope(voChildren.getGroupId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
toReturn.add(currentContext);
|
||||
// revert
|
||||
Collections.reverse(toReturn);
|
||||
return toReturn;
|
||||
} catch (ServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("loadRetrieveListContexts error: " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new List Policy
|
||||
* @return
|
||||
* @throws Throwable
|
||||
*/
|
||||
@Override
|
||||
public void addPolicies(List<PolicyAuth> policiesAuth) throws ServiceException {
|
||||
public void addPolicies(String context,List<PolicyAuth> policiesAuth) throws ServiceException {
|
||||
try {
|
||||
//Long identifier;
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
if (context==null)
|
||||
context=aslSession.getScope();
|
||||
List<Policy> policies = new ArrayList<Policy>();
|
||||
String token =aslSession.getSecurityToken();
|
||||
//String token =aslSession.getSecurityToken();
|
||||
String username = aslSession.getUsername();
|
||||
String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList<String>()), context);
|
||||
|
||||
if (ConstantsSharing.DEBUG_MODE) {
|
||||
token=ConstantsSharing.DEBUG_TOKEN;
|
||||
|
||||
}
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
String scope=SessionUtil.getASLSession(session).getScope();
|
||||
//String scope=SessionUtil.getASLSession(session).getScope();
|
||||
for (PolicyAuth policy: policiesAuth){
|
||||
ServiceAccess service=new ServiceAccess(policy.getService().getServiceName(), policy.getService().getServiceClass(), policy.getService().getServiceId());
|
||||
Action access =Action.valueOf(policy.getAccessString());
|
||||
logger.debug("policy translate:"+policy.getCallerTypeAsString());
|
||||
if (policy.getCallerTypeAsString().equalsIgnoreCase(TypeCaller.user.toString())){
|
||||
logger.debug("add policy with user");
|
||||
policies.add(new User2ServicePolicy(scope, service, Users.one(policy.getCallerAsString()), access ));
|
||||
policies.add(new User2ServicePolicy(context, service, Users.one(policy.getCallerAsString()), access ));
|
||||
}
|
||||
else if (policy.getCallerTypeAsString().equalsIgnoreCase(TypeCaller.role.toString())){
|
||||
logger.debug("add policy with role");
|
||||
policies.add(new User2ServicePolicy(scope, service, Roles.one(policy.getCallerAsString()), access ));
|
||||
policies.add(new User2ServicePolicy(context, service, Roles.one(policy.getCallerAsString()), access ));
|
||||
}
|
||||
else if (policy.getCallerTypeAsString().equalsIgnoreCase(TypeCaller.service.toString())){
|
||||
logger.debug("add policy with service");
|
||||
|
@ -347,18 +440,18 @@ implements AuthManagerService {
|
|||
if (policyService.length==3)
|
||||
serviceId=policy.getCallerAsString().split(":")[2];
|
||||
ServiceAccess serviceCaller =new ServiceAccess(serviceName, serviceClass, serviceId);
|
||||
policies.add(new Service2ServicePolicy(scope,service,Services.specialized(serviceCaller),access));
|
||||
policies.add(new Service2ServicePolicy(context,service,Services.specialized(serviceCaller),access));
|
||||
}
|
||||
else{
|
||||
String[] allExecpt=policy.getCallerTypeAsString().trim().split(" ");
|
||||
if (allExecpt.length>0){
|
||||
if (allExecpt[0].equalsIgnoreCase(TypeCaller.user.toString())){
|
||||
logger.debug("add policy with user execpt");
|
||||
policies.add(new User2ServicePolicy(scope, service, Users.allExcept(policy.getCallerExecptAsString()), access ));
|
||||
policies.add(new User2ServicePolicy(context, service, Users.allExcept(policy.getCallerExecptAsString()), access ));
|
||||
}
|
||||
else if (allExecpt[0].equalsIgnoreCase(TypeCaller.role.toString())){
|
||||
logger.debug("add policy with role execpt");
|
||||
policies.add(new User2ServicePolicy(scope, service, Roles.allExcept(policy.getCallerExecptAsString()), access ));
|
||||
policies.add(new User2ServicePolicy(context, service, Roles.allExcept(policy.getCallerExecptAsString()), access ));
|
||||
}
|
||||
else{
|
||||
logger.error("ERROR caller type not recognized"+allExecpt[0]);
|
||||
|
@ -389,12 +482,18 @@ implements AuthManagerService {
|
|||
* Update an existing policy
|
||||
*/
|
||||
@Override
|
||||
public void updatePolicy(PolicyAuth policy) throws ServiceException{
|
||||
public void updatePolicy(String context,PolicyAuth policy) throws ServiceException{
|
||||
try {
|
||||
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token =aslSession.getSecurityToken();
|
||||
if (context==null)
|
||||
context=aslSession.getScope();
|
||||
String username = aslSession.getUsername();
|
||||
String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList<String>()), context);
|
||||
|
||||
|
||||
//String token =aslSession.getSecurityToken();
|
||||
if (ConstantsSharing.DEBUG_MODE) {
|
||||
token=ConstantsSharing.DEBUG_TOKEN;
|
||||
}
|
||||
|
@ -403,11 +502,11 @@ implements AuthManagerService {
|
|||
authorizationService().removePolicies(policy.getIdpolicy());
|
||||
//add a new policy
|
||||
List<Policy> policies = new ArrayList<Policy>();
|
||||
String scope=SessionUtil.getASLSession(session).getScope();
|
||||
//String scope=SessionUtil.getASLSession(session).getScope();
|
||||
ServiceAccess service=new ServiceAccess(policy.getService().getServiceName(), policy.getService().getServiceClass(), policy.getService().getServiceId());
|
||||
logger.info("updatePolicy -policy.getCallerAsString()"+policy.getCallerAsString());
|
||||
Action access =Action.valueOf(policy.getAccessString());
|
||||
policies.add(new User2ServicePolicy(scope, service, Users.one(policy.getCallerAsString()), access ));
|
||||
policies.add(new User2ServicePolicy(context, service, Users.one(policy.getCallerAsString()), access ));
|
||||
authorizationService().addPolicies(policies);
|
||||
|
||||
} catch (ServiceException e) {
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.admin.authportletmanager.shared.exceptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ContextException extends Exception {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -2255657546267656458L;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ContextException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public ContextException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
public ContextException(String message,Throwable t) {
|
||||
super(message,t);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue