Changeset 2455

Show
Ignore:
Timestamp:
09/17/08 13:07:31 (4 months ago)
Author:
dbuss
Message:

#642 added remote provision/deprovision

Location:
trunk/otis
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/otis/config/otis-config.server.xml

    r2452 r2455  
    7171                                        <Setting Name="Noun5" Type="xsd:string">AuthenticatedSession/*/AssumableRoles</Setting> 
    7272                                        <Setting Name="Noun6" Type="xsd:string">AssumableRoles</Setting> 
     73                                        <Setting Name="Noun7" Type="xsd:string">AuthenticatedSession/*/ProvisionRole/*/*</Setting> 
     74                                        <Setting Name="Noun8" Type="xsd:string">ProvisionRole/*</Setting> 
     75                                        <Setting Name="Noun9" Type="xsd:string">AuthenticatedSession/*/DeprovisionRole/*/*</Setting> 
     76                                        <Setting Name="Noun10" Type="xsd:string">DeprovisionRole/*</Setting> 
    7377                                </Setting> 
    7478                                <Setting Name="GET_TemplateFile" Type="xsd:string">GET_RoleResponse.xml</Setting> 
  • trunk/otis/src/org/bandit/otis/impl/RemoteAuthSession.java

    r2447 r2455  
    715715                         
    716716                        String []                       nouns = {noun, entityId, roleId}; 
    717                         IEndPointResponse       response = m_endPoint.send( Constants.RESOURCE_READ, this.getSessionSecret(), this.getSessionURL(), nouns, null); 
     717                        IEndPointResponse       response = m_endPoint.send( Constants.RESOURCE_UPDATE, this.getSessionSecret(), this.getSessionURL(), nouns, null); 
    718718                         
    719719                        if (response.getStatus() != HttpServletResponse.SC_OK) 
     
    723723                         
    724724                        // Parse the Obligation 
    725                          
    726725                        Document        responseDoc = response.getResponseBodyDoc(); 
    727726                        if (responseDoc != null) 
  • trunk/otis/src/org/bandit/otis/server/RoleHandler.java

    r2433 r2455  
    1919import java.util.Iterator; 
    2020 
     21import org.bandit.otis.api.IObligation; 
    2122import org.bandit.otis.api.IRole; 
    2223import org.bandit.otis.impl.LocalAuthSession; 
     
    7475        { 
    7576                OtisServlet.throwException( m_log, errMsg, e, iHttpResponseCode, responseMap); 
     77        } 
     78         
     79        private void provisionRole( 
     80                LocalAuthSession        localAuthSession, 
     81                String                          strSessionID, 
     82                String                          strEntityID, 
     83                String                          strRoleID, 
     84                Map                                     responseMap) throws OtisException 
     85        { 
     86                try 
     87                { 
     88                        IObligation ob = localAuthSession.provisionEntityInRole(strEntityID, strRoleID); 
     89                } 
     90                catch (AuthSessionException e) 
     91                { 
     92                        throwException( new OtisErrMsg( "RoleHandler(PUT): Exception " + e.getClass().getName() + " calling activateRole", 
     93                                OtisErrMsg.OPTIONAL_STR( "('" + strRoleID + "')"), 
     94                                " for session", 
     95                                OtisErrMsg.OPTIONAL_STR( " '" + strSessionID + "': " + e.getMessage())), 
     96                                e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, responseMap); 
     97                } 
     98        } 
     99        private void deprovisionRole( 
     100                LocalAuthSession        localAuthSession, 
     101                String                          strSessionID, 
     102                String                          strEntityID, 
     103                String                          strRoleID, 
     104                Map                                     responseMap) throws OtisException 
     105        { 
     106                try 
     107                { 
     108                        IObligation ob = localAuthSession.deProvisionEntityInRole(strEntityID, strRoleID); 
     109                } 
     110                catch (AuthSessionException e) 
     111                { 
     112                        throwException( new OtisErrMsg( "RoleHandler(PUT): Exception " + e.getClass().getName() + " calling activateRole", 
     113                                OtisErrMsg.OPTIONAL_STR( "('" + strRoleID + "')"), 
     114                                " for session", 
     115                                OtisErrMsg.OPTIONAL_STR( " '" + strSessionID + "': " + e.getMessage())), 
     116                                e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, responseMap); 
     117                } 
    76118        } 
    77119         
     
    540582                                        } 
    541583                                        strRoleType = (String)nounList.get( iMainNounPos); 
    542                                         if (!strRoleType.equals( Constants.NOUN_ACTIVE_ROLES)) 
     584                                        if ( strRoleType.equals( Constants.NOUN_ACTIVE_ROLES)) 
     585                                        { 
     586                                                if (nounList.size() > iMainNounPos + 1) 
     587                                                { 
     588                                                        throwException( new OtisErrMsg( "RoleHandler(PUT): Cannot PUT on noun specified in URL", 
     589                                                                OtisErrMsg.OPTIONAL_STR( " '" + request.getRequestURL().toString() + "'")), 
     590                                                                null, HttpServletResponse.SC_METHOD_NOT_ALLOWED, responseMap); 
     591                                                } 
     592                                                activateRole( localAuthSession, strSessionID, requestDoc, responseMap);                                  
     593                                        } 
     594                                        else if ( strRoleType.equals( Constants.NOUN_DEPROVISION_ROLE)) 
     595                                        { 
     596                                                if (nounList.size() < iMainNounPos + 3) 
     597                                                { 
     598                                                        throwException( new OtisErrMsg( "RoleHandler(PUT): No role subnoun specified after the session ID in URL", 
     599                                                                OtisErrMsg.OPTIONAL_STR( " '" + request.getRequestURL().toString() + "'")), 
     600                                                                null, HttpServletResponse.SC_NOT_FOUND, responseMap); 
     601                                                } 
     602                                                String entityId = (String)nounList.get( iMainNounPos+1); 
     603                                                String roleId = (String)nounList.get( iMainNounPos+2); 
     604                                                deprovisionRole(localAuthSession, strSessionID, entityId, roleId, responseMap); 
     605                                        } 
     606                                        else if ( strRoleType.equals( Constants.NOUN_PROVISION_ROLE)) 
     607                                        { 
     608                                                if (nounList.size() < iMainNounPos + 3) 
     609                                                { 
     610                                                        throwException( new OtisErrMsg( "RoleHandler(PUT): No role subnoun specified after the session ID in URL", 
     611                                                                OtisErrMsg.OPTIONAL_STR( " '" + request.getRequestURL().toString() + "'")), 
     612                                                                null, HttpServletResponse.SC_NOT_FOUND, responseMap); 
     613                                                } 
     614                                                String entityId = (String)nounList.get( iMainNounPos+1); 
     615                                                String roleId = (String)nounList.get( iMainNounPos+2); 
     616                                                provisionRole(localAuthSession, strSessionID, entityId, roleId, responseMap); 
     617                                        } 
     618                                        else 
    543619                                        { 
    544620                                                throwException( new OtisErrMsg( "RoleHandler(PUT): Can only PUT on subnoun '" + Constants.NOUN_ACTIVE_ROLES + "' after the session ID in URL", 
    545621                                                        OtisErrMsg.OPTIONAL_STR( " '" + request.getRequestURL().toString() + "'")), 
    546                                                         null, HttpServletResponse.SC_METHOD_NOT_ALLOWED, responseMap); 
    547                                         } 
    548                                         if (nounList.size() > iMainNounPos + 1) 
    549                                         { 
    550                                                 throwException( new OtisErrMsg( "RoleHandler(PUT): Cannot PUT on noun specified in URL", 
    551                                                         OtisErrMsg.OPTIONAL_STR( " '" + request.getRequestURL().toString() + "'")), 
    552                                                         null, HttpServletResponse.SC_METHOD_NOT_ALLOWED, responseMap); 
    553                                         } 
    554                                         activateRole( localAuthSession, strSessionID, requestDoc, responseMap); 
     622                                                        null, HttpServletResponse.SC_METHOD_NOT_ALLOWED, responseMap);   
     623                                        } 
     624 
    555625                                        strTemplateFile = null; 
    556626                                        break;