directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject [3/3] directory-fortress-core git commit: FC-188 - add the paset and role constraint services
Date Fri, 07 Oct 2016 06:25:14 GMT
 FC-188 - add the paset and role constraint services


Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/9eea703a
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/9eea703a
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/9eea703a

Branch: refs/heads/master
Commit: 9eea703a44651fdd8f403b12d2b1334374074eff
Parents: f443a65
Author: Shawn McKinney <smckinney@apache.org>
Authored: Fri Oct 7 01:25:03 2016 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Fri Oct 7 01:25:03 2016 -0500

----------------------------------------------------------------------
 .../directory/fortress/core/GlobalErrIds.java   |  11 +
 .../fortress/core/impl/AdminMgrImpl.java        |   4 +-
 .../fortress/core/model/RoleConstraint.java     |   2 +-
 .../core/model/RoleConstraintTypeX.java         |  31 ---
 .../fortress/core/rest/AdminMgrRestImpl.java    | 206 ++++++++++++++++---
 5 files changed, 192 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/9eea703a/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java b/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
index 64b77cd..6d73d29 100755
--- a/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
+++ b/src/main/java/org/apache/directory/fortress/core/GlobalErrIds.java
@@ -1710,4 +1710,15 @@ public final class GlobalErrIds
      */
     public static final int GROUP_TYPE_INVLD = 10314;
 
+
+    /**
+     * 10400's - ROLE CONSTRAINT Error Ids
+     */
+
+    /**
+     * The RoleConstraint entity was not supplied but is required.
+     */
+    public static final int RCON_NULL = 10401;
+
+
 }

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/9eea703a/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
index 5256857..2258419 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AdminMgrImpl.java
@@ -357,6 +357,7 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr,
Serializ
         //TODO: need new arbac perm and/or add security check
     	String methodName = "assignUser";
         assertContext( CLS_NM, methodName, uRole, GlobalErrIds.URLE_NULL );
+        // todo assert roleconstraint here
         
         userP.assign( uRole, roleConstraint );
         
@@ -373,7 +374,8 @@ public final class AdminMgrImpl extends Manageable implements AdminMgr,
Serializ
         //TODO: need new arbac perm and/or add security check
     	String methodName = "assignUser";
         assertContext( CLS_NM, methodName, uRole, GlobalErrIds.URLE_NULL );
-        
+        // todo assert roleconstraint here
+
         userP.deassign( uRole, roleConstraint );    	
     }
     

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/9eea703a/src/main/java/org/apache/directory/fortress/core/model/RoleConstraint.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/RoleConstraint.java b/src/main/java/org/apache/directory/fortress/core/model/RoleConstraint.java
index 2649fa8..cdc83d8 100644
--- a/src/main/java/org/apache/directory/fortress/core/model/RoleConstraint.java
+++ b/src/main/java/org/apache/directory/fortress/core/model/RoleConstraint.java
@@ -42,7 +42,7 @@ import javax.xml.bind.annotation.XmlType;
         "value",
         "type"
     })
-public class RoleConstraint implements Serializable {
+public class RoleConstraint  extends FortEntity implements Serializable {
 
     private static final long serialVersionUID = 1L;
 

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/9eea703a/src/main/java/org/apache/directory/fortress/core/model/RoleConstraintTypeX.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/model/RoleConstraintTypeX.java
b/src/main/java/org/apache/directory/fortress/core/model/RoleConstraintTypeX.java
deleted file mode 100644
index 95fa877..0000000
--- a/src/main/java/org/apache/directory/fortress/core/model/RoleConstraintTypeX.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *  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.core.model;
-
-/**
- * The type of role constraint.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public enum RoleConstraintTypeX
-{
-    FILTER,
-    OTHER
-}

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/9eea703a/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java b/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
index a1fef3f..eff4f1a 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/AdminMgrRestImpl.java
@@ -1244,59 +1244,207 @@ public final class AdminMgrRestImpl extends Manageable implements
AdminMgr
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
 	@Override
-	public RoleConstraint addRoleConstraint(UserRole uRole,
-			RoleConstraint roleConstraint) throws SecurityException {
-		// TODO Auto-generated method stub
-		return null;
+	public RoleConstraint addRoleConstraint(UserRole uRole, RoleConstraint roleConstraint)
+        throws SecurityException
+    {
+        VUtil.assertNotNull( uRole, GlobalErrIds.URLE_NULL, CLS_NM + ".addRoleConstraint"
);
+        VUtil.assertNotNull( roleConstraint, GlobalErrIds.RCON_NULL, CLS_NM + ".addRoleConstraint"
);
+        RoleConstraint retCnst;
+        FortRequest request = new FortRequest();
+        request.setContextId( this.contextId );
+        request.setEntity( uRole );
+        request.setEntity2( roleConstraint );
+        if ( this.adminSess != null )
+        {
+            request.setSession( adminSess );
+        }
+        String szRequest = RestUtils.marshal( request );
+        String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_ADD_CONSTRAINT
);
+        FortResponse response = RestUtils.unmarshall( szResponse );
+        if ( response.getErrorCode() == 0 )
+        {
+            retCnst = ( RoleConstraint ) response.getEntity();
+        }
+        else
+        {
+            throw new SecurityException( response.getErrorCode(), response.getErrorMessage()
);
+        }
+        return retCnst;
 	}
 
 
+    /**
+     * {@inheritDoc}
+     */
 	@Override
-	public void removeRoleConstraint(UserRole uRole,
-			RoleConstraint roleConstraint) throws SecurityException {
-		// TODO Auto-generated method stub
-		
+	public void removeRoleConstraint( UserRole uRole, RoleConstraint roleConstraint ) throws
SecurityException
+    {
+        VUtil.assertNotNull( uRole, GlobalErrIds.URLE_NULL, CLS_NM + ".removeRoleConstraint"
);
+        VUtil.assertNotNull( roleConstraint, GlobalErrIds.RCON_NULL, CLS_NM + ".removeRoleConstraint"
);
+        FortRequest request = new FortRequest();
+        request.setContextId( this.contextId );
+        request.setEntity( uRole );
+        request.setEntity2( roleConstraint );
+        if ( this.adminSess != null )
+        {
+            request.setSession( adminSess );
+        }
+        String szRequest = RestUtils.marshal( request );
+        String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.ROLE_DELETE_CONSTRAINT
);
+        FortResponse response = RestUtils.unmarshall( szResponse );
+        if ( response.getErrorCode() != 0 )
+        {
+            throw new SecurityException( response.getErrorCode(), response.getErrorMessage()
);
+        }
 	}
 
 
+    /**
+     * {@inheritDoc}
+     */
 	@Override
-	public PermissionAttributeSet addPermissionAttributeSet(
-			PermissionAttributeSet permAttributeSet) throws SecurityException {
-		// TODO Auto-generated method stub
-		return null;
+	public PermissionAttributeSet addPermissionAttributeSet( PermissionAttributeSet permAttributeSet
)
+        throws SecurityException
+    {
+        VUtil.assertNotNull( permAttributeSet, GlobalErrIds.PERM_ATTRIBUTE_SET_NULL, CLS_NM
+ ".addPermissionAttributeSet" );
+        PermissionAttributeSet retSet;
+        FortRequest request = new FortRequest();
+        request.setContextId( this.contextId );
+        request.setEntity( permAttributeSet );
+        if ( this.adminSess != null )
+        {
+            request.setSession( adminSess );
+        }
+        String szRequest = RestUtils.marshal( request );
+        String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PERM_ADD_ATTRIBUTE_SET
);
+        FortResponse response = RestUtils.unmarshall( szResponse );
+        if ( response.getErrorCode() == 0 )
+        {
+            retSet = ( PermissionAttributeSet ) response.getEntity();
+        }
+        else
+        {
+            throw new SecurityException( response.getErrorCode(), response.getErrorMessage()
);
+        }
+        return retSet;
 	}
 
 
+    /**
+     * {@inheritDoc}
+     */
 	@Override
 	public void deletePermissionAttributeSet(
-			PermissionAttributeSet permAttributeSet) throws SecurityException {
-		// TODO Auto-generated method stub
-		
+			PermissionAttributeSet permAttributeSet) throws SecurityException
+    {
+        VUtil.assertNotNull( permAttributeSet, GlobalErrIds.PERM_ATTRIBUTE_SET_NULL, CLS_NM
+ ".deletePermissionAttributeSet" );
+        FortRequest request = new FortRequest();
+        request.setContextId( this.contextId );
+        request.setEntity( permAttributeSet );
+        if ( this.adminSess != null )
+        {
+            request.setSession( adminSess );
+        }
+        String szRequest = RestUtils.marshal( request );
+        String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PERM_DELETE_ATTRIBUTE_SET
);
+        FortResponse response = RestUtils.unmarshall( szResponse );
+        if ( response.getErrorCode() != 0 )
+        {
+            throw new SecurityException( response.getErrorCode(), response.getErrorMessage()
);
+        }
 	}
 
 
+    /**
+     * {@inheritDoc}
+     */
 	@Override
-	public PermissionAttribute addPermissionAttributeToSet(
-			PermissionAttribute permAttribute, String attributeSetName)
-			throws SecurityException {
-		// TODO Auto-generated method stub
-		return null;
+	public PermissionAttribute addPermissionAttributeToSet( PermissionAttribute permAttribute,
String attributeSetName )
+			throws SecurityException
+    {
+        VUtil.assertNotNull( permAttribute, GlobalErrIds.PERM_ATTRIBUTE_SET_NULL, CLS_NM
+ ".addPermissionAttributeToSet" );
+        VUtil.assertNotNull( attributeSetName, GlobalErrIds.PERM_ATTRIBUTE_SET_NM_NULL, CLS_NM
+ ".addPermissionAttributeToSet" );
+        PermissionAttribute retAttr;
+        FortRequest request = new FortRequest();
+        request.setContextId( this.contextId );
+        request.setEntity( permAttribute );
+        request.setValue( attributeSetName );
+        if ( this.adminSess != null )
+        {
+            request.setSession( adminSess );
+        }
+        String szRequest = RestUtils.marshal( request );
+        String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PERM_ADD_PERM_ATTRIBUTE_TO_SET
);
+        FortResponse response = RestUtils.unmarshall( szResponse );
+        if ( response.getErrorCode() == 0 )
+        {
+            retAttr = ( PermissionAttribute ) response.getEntity();
+        }
+        else
+        {
+            throw new SecurityException( response.getErrorCode(), response.getErrorMessage()
);
+        }
+        return retAttr;
 	}
 
 
+    /**
+     * {@inheritDoc}
+     */
 	@Override
-	public void removePermissionAttributeFromSet(
-			PermissionAttribute permAttribute, String attributeSetName)
-			throws SecurityException {
-		// TODO Auto-generated method stub
-		
+	public void removePermissionAttributeFromSet( PermissionAttribute permAttribute, String
attributeSetName )
+			throws SecurityException
+    {
+        VUtil.assertNotNull( permAttribute, GlobalErrIds.PERM_ATTRIBUTE_SET_NULL, CLS_NM
+ ".removePermissionAttributeFromSet" );
+        VUtil.assertNotNull( attributeSetName, GlobalErrIds.PERM_ATTRIBUTE_SET_NM_NULL, CLS_NM
+ ".removePermissionAttributeFromSet" );
+        PermissionAttribute retAttr;
+        FortRequest request = new FortRequest();
+        request.setContextId( this.contextId );
+        request.setEntity( permAttribute );
+        request.setValue( attributeSetName );
+        if ( this.adminSess != null )
+        {
+            request.setSession( adminSess );
+        }
+        String szRequest = RestUtils.marshal( request );
+        String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PERM_DELETE_PERM_ATTRIBUTE_TO_SET
);
+        FortResponse response = RestUtils.unmarshall( szResponse );
+        if ( response.getErrorCode() != 0 )
+        {
+            throw new SecurityException( response.getErrorCode(), response.getErrorMessage()
);
+        }
 	}
 
+
+    /**
+     * {@inheritDoc}
+     */
 	@Override
-	public void updatePermissionAttributeInSet(PermissionAttribute permAttribute, String attributeSetName,
-			boolean replaceValidValues) throws SecurityException {
-		// TODO Auto-generated method stub
-		
+	public void updatePermissionAttributeInSet(PermissionAttribute permAttribute, String attributeSetName,
boolean replaceValidValues)
+        throws SecurityException
+    {
+        VUtil.assertNotNull( permAttribute, GlobalErrIds.PERM_ATTRIBUTE_SET_NULL, CLS_NM
+ ".updatePermissionAttributeInSet" );
+        VUtil.assertNotNull( attributeSetName, GlobalErrIds.PERM_ATTRIBUTE_SET_NM_NULL, CLS_NM
+ ".updatePermissionAttributeInSet" );
+        PermissionAttribute retAttr;
+        FortRequest request = new FortRequest();
+        request.setContextId( this.contextId );
+        request.setEntity( permAttribute );
+        request.setValue( attributeSetName );
+        request.setIsReplace( replaceValidValues );
+        if ( this.adminSess != null )
+        {
+            request.setSession( adminSess );
+        }
+        String szRequest = RestUtils.marshal( request );
+        String szResponse = RestUtils.getInstance().post( szRequest, HttpIds.PERM_UPDATE_PERM_ATTRIBUTE_IN_SET
);
+        FortResponse response = RestUtils.unmarshall( szResponse );
+        if ( response.getErrorCode() != 0 )
+        {
+            throw new SecurityException( response.getErrorCode(), response.getErrorMessage()
);
+        }
 	}
 }
\ No newline at end of file


Mime
View raw message