You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by sm...@apache.org on 2014/11/11 21:38:46 UTC
[07/11] directory-fortress-enmasse git commit: change package
structure and names, pom improvements, license
http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/blob/99852b55/src/main/java/org/apache/directory/fortress/rest/PswdPolicyMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/rest/PswdPolicyMgrImpl.java b/src/main/java/org/apache/directory/fortress/rest/PswdPolicyMgrImpl.java
new file mode 100644
index 0000000..080fa2c
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/rest/PswdPolicyMgrImpl.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.fortress.rest;
+
+import org.apache.directory.fortress.core.PwPolicyMgr;
+import org.apache.directory.fortress.core.PwPolicyMgrFactory;
+import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.rbac.PwPolicy;
+import org.apache.directory.fortress.core.rest.FortRequest;
+import org.apache.directory.fortress.core.rest.FortResponse;
+import org.apache.log4j.Logger;
+
+import java.util.List;
+
+/**
+ * Utility for EnMasse Server. This class is thread safe.
+ *
+ * @author Shawn McKinney
+ */
+class PswdPolicyMgrImpl
+{
+ private static final String CLS_NM = PswdPolicyMgrImpl.class.getName();
+ private static final Logger log = Logger.getLogger(CLS_NM);
+
+ /**
+ * ************************************************************************************************************************************
+ * BEGIN PSWDPOLICYMGR
+ * **************************************************************************************************************************************
+ */
+ FortResponse addPolicy(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ PwPolicy inPolicy = (PwPolicy) request.getEntity();
+ PwPolicyMgr policyMgr = PwPolicyMgrFactory.createInstance(request.getContextId());
+ policyMgr.setAdmin(request.getSession());
+ policyMgr.add(inPolicy);
+ response.setEntity(inPolicy);
+ response.setErrorCode(0);
+ }
+ catch (org.apache.directory.fortress.core.SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse updatePolicy(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ PwPolicy inPolicy = (PwPolicy) request.getEntity();
+ PwPolicyMgr policyMgr = PwPolicyMgrFactory.createInstance(request.getContextId());
+ policyMgr.setAdmin(request.getSession());
+ policyMgr.update(inPolicy);
+ response.setEntity(inPolicy);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse deletePolicy(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ PwPolicy inPolicy = (PwPolicy) request.getEntity();
+ PwPolicyMgr policyMgr = PwPolicyMgrFactory.createInstance(request.getContextId());
+ policyMgr.setAdmin(request.getSession());
+ policyMgr.delete(inPolicy);
+ response.setEntity(inPolicy);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse readPolicy(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ PwPolicy outPolicy;
+ try
+ {
+ PwPolicy inPolicy = (PwPolicy) request.getEntity();
+ PwPolicyMgr policyMgr = PwPolicyMgrFactory.createInstance(request.getContextId());
+ policyMgr.setAdmin(request.getSession());
+ outPolicy = policyMgr.read(inPolicy.getName());
+ response.setEntity(outPolicy);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse searchPolicy(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ List<PwPolicy> policyList;
+ try
+ {
+ PwPolicy inPolicy = (PwPolicy) request.getEntity();
+ PwPolicyMgr policyMgr = PwPolicyMgrFactory.createInstance(request.getContextId());
+ policyMgr.setAdmin(request.getSession());
+ policyList = policyMgr.search(inPolicy.getName());
+ response.setEntities(policyList);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse updateUserPolicy(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ PwPolicy inPolicy = (PwPolicy) request.getEntity();
+ PwPolicyMgr policyMgr = PwPolicyMgrFactory.createInstance(request.getContextId());
+ policyMgr.setAdmin(request.getSession());
+ String userId = request.getValue();
+ policyMgr.updateUserPolicy(userId, inPolicy.getName());
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse deleteUserPolicy(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ PwPolicyMgr policyMgr = PwPolicyMgrFactory.createInstance(request.getContextId());
+ policyMgr.setAdmin(request.getSession());
+ String userId = request.getValue();
+ policyMgr.deletePasswordPolicy(userId);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/blob/99852b55/src/main/java/org/apache/directory/fortress/rest/ReviewMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/rest/ReviewMgrImpl.java b/src/main/java/org/apache/directory/fortress/rest/ReviewMgrImpl.java
new file mode 100644
index 0000000..8e53b9a
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/rest/ReviewMgrImpl.java
@@ -0,0 +1,679 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.fortress.rest;
+
+import org.apache.directory.fortress.core.ReviewMgr;
+import org.apache.directory.fortress.core.ReviewMgrFactory;
+import org.apache.directory.fortress.core.SecurityException;
+import org.apache.directory.fortress.core.rbac.OrgUnit;
+import org.apache.directory.fortress.core.rbac.PermObj;
+import org.apache.directory.fortress.core.rbac.Permission;
+import org.apache.directory.fortress.core.rbac.Role;
+import org.apache.directory.fortress.core.rbac.SDSet;
+import org.apache.directory.fortress.core.rbac.User;
+import org.apache.directory.fortress.core.rbac.UserRole;
+import org.apache.directory.fortress.core.rest.FortRequest;
+import org.apache.directory.fortress.core.rest.FortResponse;
+import org.apache.directory.fortress.core.util.attr.VUtil;
+import org.apache.log4j.Logger;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Utility for EnMasse Server. This class is thread safe.
+ *
+ * @author Shawn McKinney
+ */
+class ReviewMgrImpl
+{
+ private static final String CLS_NM = ReviewMgrImpl.class.getName();
+ private static final Logger log = Logger.getLogger(CLS_NM);
+
+ FortResponse readPermission(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ Permission inPerm = (Permission) request.getEntity();
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ Permission retPerm = reviewMgr.readPermission(inPerm);
+ response.setEntity(retPerm);
+ response.setErrorCode(0);
+ }
+ catch (org.apache.directory.fortress.core.SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse readPermObj(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ PermObj inObj = (PermObj) request.getEntity();
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ PermObj retObj = reviewMgr.readPermObj(inObj);
+ response.setEntity(retObj);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse findPermissions(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ Permission inPerm = (Permission) request.getEntity();
+ List<Permission> perms = reviewMgr.findPermissions(inPerm);
+ response.setEntities(perms);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse findPermObjs(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ PermObj inObj = (PermObj) request.getEntity();
+ List<PermObj> objs = null;
+ if (VUtil.isNotNullOrEmpty(inObj.getOu()))
+ {
+ objs = reviewMgr.findPermObjs(new OrgUnit(inObj.getOu(), OrgUnit.Type.PERM));
+ }
+ else
+ {
+ objs = reviewMgr.findPermObjs(inObj);
+ }
+ response.setEntities(objs);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse readRole(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ Role inRole = (Role) request.getEntity();
+ Role outRole = reviewMgr.readRole(inRole);
+ response.setEntity(outRole);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse findRoles(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ String searchValue = request.getValue();
+ if (request.getLimit() != null)
+ {
+ List<String> retRoles = reviewMgr.findRoles(searchValue, request.getLimit());
+ response.setValues(retRoles);
+ }
+ else
+ {
+ List<Role> roles = reviewMgr.findRoles(searchValue);
+ response.setEntities(roles);
+ }
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse readUserM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ User inUser = (User) request.getEntity();
+ User outUser = reviewMgr.readUser(inUser);
+ response.setEntity(outUser);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse findUsersM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ User inUser = (User) request.getEntity();
+ if (request.getLimit() != null)
+ {
+ List<String> retUsers = reviewMgr.findUsers(inUser, request.getLimit());
+ response.setValues(retUsers);
+ }
+ else
+ {
+ List<User> retUsers;
+ if (VUtil.isNotNullOrEmpty(inUser.getOu()))
+ {
+ retUsers = reviewMgr.findUsers(new OrgUnit(inUser.getOu(), OrgUnit.Type.USER));
+ }
+ else
+ {
+ retUsers = reviewMgr.findUsers(inUser);
+ }
+ response.setEntities(retUsers);
+ }
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse assignedUsersM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ Role inRole = (Role) request.getEntity();
+ if (request.getLimit() != null)
+ {
+ List<String> retUsers = reviewMgr.assignedUsers(inRole, request.getLimit());
+ response.setValues(retUsers);
+ }
+ else
+ {
+ List<User> users = reviewMgr.assignedUsers(inRole);
+ response.setEntities(users);
+ response.setEntities(users);
+ }
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse assignedRolesM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ if (VUtil.isNotNullOrEmpty(request.getValue()))
+ {
+ String userId = request.getValue();
+ List<String> retRoles = reviewMgr.assignedRoles(userId);
+ response.setValues(retRoles);
+ }
+ else
+ {
+ User inUser = (User) request.getEntity();
+ List<UserRole> uRoles = reviewMgr.assignedRoles(inUser);
+ response.setEntities(uRoles);
+ }
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse authorizedUsersM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ Role inRole = (Role) request.getEntity();
+ List<User> users = reviewMgr.authorizedUsers(inRole);
+ response.setEntities(users);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse authorizedRoleM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ User inUser = (User) request.getEntity();
+ Set<String> outSet = reviewMgr.authorizedRoles(inUser);
+ response.setValueSet(outSet);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse permissionRolesM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ Permission inPerm = (Permission) request.getEntity();
+ List<String> outList = reviewMgr.permissionRoles(inPerm);
+ response.setValues(outList);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse authorizedPermissionRolesM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ Permission inPerm = (Permission) request.getEntity();
+ Set<String> outSet = reviewMgr.authorizedPermissionRoles(inPerm);
+ response.setValueSet(outSet);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse permissionUsersM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ Permission inPerm = (Permission) request.getEntity();
+ List<String> outList = reviewMgr.permissionUsers(inPerm);
+ response.setValues(outList);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse authorizedPermissionUsersM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ Permission inPerm = (Permission) request.getEntity();
+ Set<String> outSet = reviewMgr.authorizedPermissionUsers(inPerm);
+ response.setValueSet(outSet);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse userPermissionsM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ User inUser = (User) request.getEntity();
+ List<Permission> perms = reviewMgr.userPermissions(inUser);
+ response.setEntities(perms);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse rolePermissionsM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ Role inRole = (Role) request.getEntity();
+ List<Permission> perms = reviewMgr.rolePermissions(inRole);
+ response.setEntities(perms);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse ssdRoleSetsM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ Role inRole = (Role) request.getEntity();
+ List<SDSet> outSets = reviewMgr.ssdRoleSets(inRole);
+ response.setEntities(outSets);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse ssdRoleSetM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ SDSet inSet = (SDSet) request.getEntity();
+ SDSet outSet = reviewMgr.ssdRoleSet(inSet);
+ response.setEntity(outSet);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse ssdRoleSetRolesM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ SDSet inSet = (SDSet) request.getEntity();
+ Set<String> outSet = reviewMgr.ssdRoleSetRoles(inSet);
+ response.setValueSet(outSet);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse ssdRoleSetCardinalityM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ SDSet inSet = (SDSet) request.getEntity();
+ int cardinality = reviewMgr.ssdRoleSetCardinality(inSet);
+ inSet.setCardinality(cardinality);
+ response.setEntity(inSet);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ }
+ return response;
+ }
+
+ FortResponse ssdSetsM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ SDSet inSdSet = (SDSet) request.getEntity();
+ List<SDSet> outSets = reviewMgr.ssdSets(inSdSet);
+ response.setEntities(outSets);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse dsdRoleSetsM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ Role inRole = (Role) request.getEntity();
+ List<SDSet> outSets = reviewMgr.dsdRoleSets(inRole);
+ response.setEntities(outSets);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse dsdRoleSetM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ SDSet inSet = (SDSet) request.getEntity();
+ SDSet outSet = reviewMgr.dsdRoleSet(inSet);
+ response.setEntity(outSet);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse dsdRoleSetRolesM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ SDSet inSet = (SDSet) request.getEntity();
+ Set<String> outSet = reviewMgr.dsdRoleSetRoles(inSet);
+ response.setValueSet(outSet);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+
+ FortResponse dsdRoleSetCardinalityM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ SDSet inSet = (SDSet) request.getEntity();
+ int cardinality = reviewMgr.dsdRoleSetCardinality(inSet);
+ inSet.setCardinality(cardinality);
+ response.setEntity(inSet);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ }
+ return response;
+ }
+
+ FortResponse dsdSetsM(FortRequest request)
+ {
+ FortResponse response = new FortResponse();
+ try
+ {
+ ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(request.getContextId());
+ reviewMgr.setAdmin(request.getSession());
+ SDSet inSdSet = (SDSet) request.getEntity();
+ List<SDSet> outSets = reviewMgr.dsdSets(inSdSet);
+ response.setEntities(outSets);
+ response.setErrorCode(0);
+ }
+ catch (SecurityException se)
+ {
+ log.info(CLS_NM + " caught " + se);
+ response.setErrorCode(se.getErrorId());
+ response.setErrorMessage(se.getMessage());
+ }
+ return response;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/blob/99852b55/src/main/java/org/apache/directory/fortress/rest/SecurityOutFaultInterceptor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/rest/SecurityOutFaultInterceptor.java b/src/main/java/org/apache/directory/fortress/rest/SecurityOutFaultInterceptor.java
new file mode 100644
index 0000000..4b29d34
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/rest/SecurityOutFaultInterceptor.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.fortress.rest;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.security.AccessDeniedException;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * Utility for EnMasse Server. This class is thread safe.
+ *
+ * @author Shawn McKinney
+ */
+
+public class SecurityOutFaultInterceptor extends AbstractPhaseInterceptor<Message>
+{
+ public SecurityOutFaultInterceptor()
+ {
+ super(Phase.PRE_STREAM);
+
+ }
+
+ public void handleMessage(Message message) throws Fault
+ {
+ Fault fault = (Fault) message.getContent(Exception.class);
+ Throwable ex = fault.getCause();
+ if (!(ex instanceof SecurityException))
+ {
+ throw new RuntimeException("Security Exception is expected:" + ex);
+ }
+
+ HttpServletResponse response = (HttpServletResponse) message.getExchange().getInMessage()
+ .get(AbstractHTTPDestination.HTTP_RESPONSE);
+ int status = ex instanceof AccessDeniedException ? 403 : 401;
+ response.setStatus(status);
+ try
+ {
+ response.getOutputStream().write(ex.getMessage().getBytes());
+ response.getOutputStream().flush();
+ }
+ catch (IOException iex)
+ {
+ // ignore
+ }
+
+ message.getInterceptorChain().abort();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/blob/99852b55/src/main/java/org/apache/directory/fortress/rest/fortress-javadoc.css
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/rest/fortress-javadoc.css b/src/main/java/org/apache/directory/fortress/rest/fortress-javadoc.css
new file mode 100755
index 0000000..8f2e4cc
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/rest/fortress-javadoc.css
@@ -0,0 +1,33 @@
+BODY { color: #000000;
+ background-color: #FFFFFF;
+ font-family: sans-serif }
+
+A:link { color: #0101DF;
+ text-decoration: underline }
+
+A:visited { color: #610B38;
+ text-decoration: underline }
+
+A:hover { color: #0B3B0B;
+ text-decoration: underline }
+
+PRE { background-color: #99CC66;
+ margin: 15px 30px;
+ padding: 10px 10px;
+ border: 1px solid #000000 }
+
+# the following will add space between list items:
+#LI { margin: 10px 0px }
+
+TH { background-color: #FFFFFF; color: #003300;
+ font-size: 125%;
+ font-weight: bold }
+
+
+# Classes defined specifically for Javadoc
+.TableHeadingColor { background-color: #D8D8D8 }
+
+.NavBarCell1 { background-color: #99CC66 }
+
+.FrameItemFont { font-size: 90% }
+
http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/blob/99852b55/src/main/java/org/apache/directory/fortress/rest/overview.html
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/rest/overview.html b/src/main/java/org/apache/directory/fortress/rest/overview.html
new file mode 100755
index 0000000..a7c3a3a
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/rest/overview.html
@@ -0,0 +1,97 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<html>
+ <head>
+ <title>Overview of the org.apache.directory.fortress.rest component</title>
+ </head>
+ <body>
+ Fortress Rest is a web application that implements <A HREF="http://en.wikipedia.org/wiki/Representational_state_transfer">RESTful</A> Web services to interface with
+ <A HREF="http://symas.com/javadocs/fortress/index.html?overview-summary.html">Fortress Core</A> and a directory server like <A HREF="http://www.openldap.org/">OpenLDAP</A>
+ or <A HREF="http://directory.apache.org/apacheds//">ApacheDS</A>.
+
+ <h2>What technologies are in use?</h2>
+
+ Fortress Rest was built using established <A HREF="http://www.opensource.org/">Open Source</A> technologies including
+ <A HREF="http://cxf.apache.org/">Apache CXF</A> (web services stack), <A HREF="http://www.springsource.org/">Spring Framework</A> (glue), <A HREF="http://maven.apache.org/">Maven</A> (dependencies)
+ and <A HREF="http://java.sun.com/xml/downloads/jaxb.html">JAXB</A> (data binding layer) and runs inside any reasonably compliant Java Servlets container.
+
+ <a href="org/apache/directory/fortress/rest/FortressService.html">Fortress Rest service</a> access control decisions are enforced using <A HREF="https://symas.com/javadocs/sentry/">Fortress Realm</A> which itself
+ uses declarative <A HREF="http://docs.oracle.com/javaee/5/tutorial/doc/bnbwk.html">Java EE Security</A> and <A HREF="http://static.springsource.org/spring-security/site/">Spring Security</A> policy hooks that are wired to
+ connect back to the <A HREF="org.apache.directory.fortress.core/rbac/package-summary.html">Fortress</A> <A HREF="http://en.wikipedia.org/wiki/Role-based_access_control">RBAC</A> component.
+
+ Fortress Rest is a <a href="http://java.sun.com/developer/technicalArticles/tools/webapps_1/">Java Web program</a> artifact and is wholly dependent on <A HREF="org.apache.directory.fortress.core/package-summary.html">Fortress</A>
+ but also needs a <A HREF="http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol">V3 compliant LDAP</A> server like OpenLDAP. For more information on installing and setting up OpenLDAP check out
+ <A HREF="http://directory.apache.org/fortress/quick-start/apacheds/apacheds.html">Fortress ApacheDS Quickstart</A>
+
+ <h2>What can Fortress Rest do?</h2>
+
+ Contained within this application are Web APIs to perform authentication, authorization, administration, audit and password policies.
+ The most important package in this system, <A HREF="org/apache/directory/fortress/rest/package-summary.html">org.apache.directory.fortress.rest</A>, contains the public Web APIs that are called by external systems.
+
+ There is a one-to-one correspondence between a Fortress Core API and a Fortress Rest service. The Fortress Core
+ APIs are organized into 'Managers' each implementing a specific area of functionality within the
+ Identity and Access Management lifecycle.
+ For a list of Fortress Rest services, see <a href="org/apache/directory/fortress/rest/FortressService.html">FortressService</a>.
+
+ <h3>Fortress Manager Overview</h3>
+ <ol>
+ <li><a href="http://symas.com/javadocs/fortress/org/openldap/fortress/AccessMgr.html">AccessMgr</a> - This object performs runtime access control operations on objects that are provisioned <a href="http://csrc.nist.gov/groups/SNS/rbac/documents/draft-rbac-implementation-std-v01.pdf">RBAC</a> entities that reside in LDAP directory.</li>
+ <li><a href="http://symas.com/javadocs/fortress/org/openldap/fortress/AdminMgr.html">AdminMgr</a> - This object performs administrative functions to provision Fortress <a href="http://csrc.nist.gov/groups/SNS/rbac/documents/draft-rbac-implementation-std-v01.pdf">RBAC</a> entities into the LDAP directory.</li>
+ <li><a href="http://symas.com/javadocs/fortress/org/openldap/fortress/AuditMgr.html">AuditMgr</a> - This interface prescribes methods used to search OpenLDAP's slapd access log.</li>
+ <li><a href="http://symas.com/javadocs/fortress/org/openldap/fortress/DelAccessMgr.html">DelegatedAccessMgr</a> - This interface prescribes the API for performing runtime delegated access control operations on objects that are provisioned Fortress <a href="http://profsandhu.com/journals/tissec/p113-oh.pdf">ARBAC02</a> entities that reside in LDAP directory.</li>
+ <li><a href="http://symas.com/javadocs/fortress/org/openldap/fortress/DelAdminMgr.html">DelegatedAdminMgr</a> - This class prescribes the <a href="http://profsandhu.com/journals/tissec/p113-oh.pdf">ARBAC02</a> DelegatedAdminMgr interface for performing policy administration of Fortress ARBAC entities that reside in LDAP directory.</li>
+ <li><a href="http://symas.com/javadocs/fortress/org/openldap/fortress/DelReviewMgr.html">DelegatedReviewMgr</a> - This class prescribes the <a href="http://profsandhu.com/journals/tissec/p113-oh.pdf">ARBAC02</a> DelegatedReviewMgr interface for performing policy interrogation of provisioned Fortress ARBAC02 entities that reside in LDAP directory.</li>
+ <li><a href="http://symas.com/javadocs/fortress/org/openldap/fortress/PwPolicyMgr.html">PswdPolicyMgr</a> - This object adheres to <a href="http://tools.ietf.org/html/draft-behera-ldap-password-policy-10">IETF PW policy draft</a> and is used to perform administrative and review functions on the <a href="http://symas.com/javadocs/fortress/org/openldap/fortress/rbac/PwPolicy.html">PWPOLICIES</a> and <a href="http://symas.com/javadocs/fortress/org/openldap/fortress/rbac/User.html">USERS</a> data sets within Fortress.</li>
+ <li><a href="http://symas.com/javadocs/fortress/org/openldap/fortress/ReviewMgr.html">ReviewMgr</a> - This interface prescribes the administrative review functions on already provisioned Fortress <a href="http://csrc.nist.gov/groups/SNS/rbac/documents/draft-rbac-implementation-std-v01.pdf">RBAC</a> entities that reside in LDAP directory.</li>
+ </ol>
+
+ <h2>How can I connect with Fortress Rest?</h2>
+
+ Clients have a choice in how to connect with the Fortress Rest services. Integration can occur using a
+ preferred Web service toolkit like <a href="http://axis.apache.org/axis/">AXIS 1</a>, <a href="http://axis.apache.org/axis2/java/core/">AXIS 2</a>,
+ <a href="http://metro.java.net/">Metro</a>, <a href="http://cxf.apache.org/">CXF</a>, <a href="http://static.springsource.org/spring-ws/sites/1.5/">Spring Web Services</a>,
+ <a href="http://wso2.com/products/web-services-framework/php">WSO2</a>, <a href="http://jquery.com/">JQuery</a>, etc, or by using the Fortress Core APIs
+ themselves which have built in support for calling Fortress Rest.
+
+ The Fortress Core APIs plugs into its backend data repository (LDAP) using a simple facade pattern that
+ shields its clients from downstream details. The behavior of the Fortress APIs does not change based
+ on the route it takes.
+
+ <h3>Options for Fortress Rest service Integration</h3>
+ <ol>
+ <li>Client uses Fortress Core to connect to LDAP via Fortress Rest:<br>
+ Client-->Fortress Core-->HTTP/S-->Fortress Rest</li>
+ <li>Client uses other Web frameworks to connect to Fortress Rest:<br>
+ Client[Axis, Metro, CXF, SpringWS,...]-->HTTP/S-->Fortress Rest</li>
+ </ol>
+ </p>
+ <h2>What are the conditions of use?</h2>
+ <p>
+ This software development kit is open source, thus free to use and distribute via the <a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a>.
+ It was developed and tested on open systems like <a href="http://www.ubuntu.com/">Ubuntu</a> and <a href="http://www.centos.org/">Centos</a> and was helped along
+ by the following open source products:
+ <ol>
+ <li><a href="http://www.openldap.org/project/">The OpenLDAP Project</a></li>
+ <li><a href="http://www.apache.org/">The Apache Software Foundation</a></li>
+ <li><a href="http://www.eigenbase.org/">The Eigenbase Project</a></li>
+ <li><a href="http://ehcache.org/">Ehcache</a></li>
+ </ol>
+ </p>
+ </body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/blob/99852b55/src/main/java/org/apache/directory/fortress/rest/package.html
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/rest/package.html b/src/main/java/org/apache/directory/fortress/rest/package.html
new file mode 100755
index 0000000..01c3b25
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/rest/package.html
@@ -0,0 +1,29 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<html>
+ <head>
+ <title>Package Documentation for {@link org.apache.directory.fortress.rest.FortressService}</title>
+ </head>
+ <body>
+ <p>
+ This package contains REST APIs that are used by HTTP programs to provide Identity and Access Management functionality.
+ The javadoc for the Fortress REST services: {@link org.apache.directory.fortress.rest.FortressService}
+ </p>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/directory-fortress-enmasse/blob/99852b55/src/main/java/org/openldap/enmasse/AccessMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/enmasse/AccessMgrImpl.java b/src/main/java/org/openldap/enmasse/AccessMgrImpl.java
deleted file mode 100644
index 0e9cf02..0000000
--- a/src/main/java/org/openldap/enmasse/AccessMgrImpl.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-package org.openldap.enmasse;
-
-import org.openldap.fortress.AccessMgr;
-import org.openldap.fortress.AccessMgrFactory;
-import org.openldap.fortress.SecurityException;
-import org.openldap.fortress.rbac.Permission;
-import org.openldap.fortress.rbac.Session;
-import org.openldap.fortress.rbac.User;
-import org.openldap.fortress.rbac.UserRole;
-import org.openldap.fortress.rest.FortRequest;
-import org.openldap.fortress.rest.FortResponse;
-import org.apache.log4j.Logger;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Utility for EnMasse Server. This class is thread safe.
- *
- * @author Shawn McKinney
- */
-class AccessMgrImpl
-{
- private static final String CLS_NM = AccessMgrImpl.class.getName();
- private static final Logger log = Logger.getLogger(CLS_NM);
-
- /**
- * ************************************************************************************************************************************
- * BEGIN ACCESSMGR
- * **************************************************************************************************************************************
- */
-
- FortResponse authenticate(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- User inUser = (User) request.getEntity();
- Session outSession = accessMgr.authenticate(inUser.getUserId(), inUser.getPassword());
- response.setSession(outSession);
- response.setErrorCode(0);
- }
- catch (org.openldap.fortress.SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-
- FortResponse createSession(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- User inUser = (User) request.getEntity();
- Session outSession = accessMgr.createSession(inUser, false);
- response.setSession(outSession);
- response.setErrorCode(0);
- }
- catch (SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-
- FortResponse createSessionTrusted(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- User inUser = (User) request.getEntity();
- Session outSession = accessMgr.createSession(inUser, true);
- response.setSession(outSession);
- response.setErrorCode(0);
- }
- catch (SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-
- FortResponse checkAccess(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- Permission perm = (Permission)request.getEntity();
- perm.setAdmin(false);
- Session session = request.getSession();
- boolean result = accessMgr.checkAccess(session, perm);
- response.setSession(session);
- response.setAuthorized(result);
- response.setErrorCode(0);
- }
- catch (SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-
- FortResponse sessionPermissions(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- Session session = request.getSession();
- List<Permission> perms = accessMgr.sessionPermissions(session);
- response.setSession(session);
- response.setEntities(perms);
- response.setErrorCode(0);
- }
- catch (SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-
- FortResponse sessionRoles(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- Session session = request.getSession();
- List<UserRole> roles = accessMgr.sessionRoles(session);
- response.setEntities(roles);
- response.setSession(session);
- response.setErrorCode(0);
- }
- catch (SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-
- FortResponse authorizedSessionRoles(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- Session session = request.getSession();
- Set<String> roles = accessMgr.authorizedRoles(session);
- response.setValueSet(roles);
- response.setSession(session);
- response.setErrorCode(0);
- }
- catch (SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-
- FortResponse addActiveRole(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- UserRole uRole = (UserRole)request.getEntity();
- Session session = request.getSession();
- accessMgr.addActiveRole(session, uRole);
- response.setSession(session);
- response.setErrorCode(0);
- }
- catch (SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-
- FortResponse dropActiveRole(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- UserRole uRole = (UserRole)request.getEntity();
- Session session = request.getSession();
- accessMgr.dropActiveRole(session, uRole);
- response.setSession(session);
- response.setErrorCode(0);
- }
- catch (SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-
- FortResponse getUserId(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- Session session = request.getSession();
- String userId = accessMgr.getUserId(session);
- User outUser = new User(userId);
- response.setSession(session);
- response.setEntity(outUser);
- response.setErrorCode(0);
- }
- catch (SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-
- FortResponse getUser(FortRequest request)
- {
- FortResponse response = new FortResponse();
- try
- {
- AccessMgr accessMgr = AccessMgrFactory.createInstance(request.getContextId());
- Session session = request.getSession();
- User outUser = accessMgr.getUser(session);
- response.setSession(session);
- response.setEntity(outUser);
- response.setErrorCode(0);
- }
- catch (SecurityException se)
- {
- log.info(CLS_NM + " caught " + se);
- response.setErrorCode(se.getErrorId());
- response.setErrorMessage(se.getMessage());
- }
- return response;
- }
-}
\ No newline at end of file