View Javadoc
1   package fr.paris.lutece.plugins.appcenter.modules.openam.service.client.rest;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import fr.paris.lutece.plugins.appcenter.business.Environment;
7   import fr.paris.lutece.plugins.appcenter.modules.openam.business.OpenamAgentData;
8   import fr.paris.lutece.plugins.appcenter.modules.openam.business.OpenamDemand;
9   import fr.paris.lutece.portal.service.util.AppPropertiesService;
10  
11  public class OpenamAgentDTO extends OpenamAgentData{
12  	
13  	//OPENAM PARAMETERS AUTHENTIFICATION
14  	public static final String X_OPENAM_USERNAME= "X-OpenAM-Username";
15  	public static final String X_OPENAM_PASSWORD=  "X-OpenAM-Password";
16  	public static final String ACCEPT_API_VERSION= "Accept-API-Version";
17  	public static final String COOKIE_IPLANETDIRECTOTYPRO= "iplanetDirectoryPro";
18  	public static final String COOKIE_MCPAUTH= "mcpAuth";
19  	public static final String PROD_URL_OPENAM="https://moncompte.paris.fr:443/v69";
20      
21  	
22  	
23  	
24  	public static final  String USERNAEM = "username";
25      public static final String CONFIG_FQDN_DEFAULT = "com.sun.identity.agents.config.fqdn.default";
26      public static final String CONFIG_REPOSITORY_LOCATION = "com.sun.identity.agents.config.repository.location";
27      public static final String AGENTTYPE= "agenttype";
28      public static final String SERVERURL= "serverurl";
29      public static final String AGENTURL= "agenturl";
30      public static final String USERPASSWORD= "userpassword";
31      public static final String CONFIG_LOGIN_URL ="com.sun.identity.agents.config.login.url";
32      public static final String CONFIG_LOGOUT_URL = "com.sun.identity.agents.config.logout.url";
33      public static final String SUNIDENTITYSERVERDEVICESSTATUS="sunidentityserverdevicestatus";
34  	
35  	
36      public static final String CONFIG_NOTENFORCED_URI_INVERT= "com.sun.identity.agents.config.notenforced.uri.invert";
37      public static final String CONFIG_PROFILE_ATTRIBUTE_MAPPING ="com.sun.identity.agents.config.profile.attribute.mapping";
38      public static final String CONFIG_LOGIN_URL_PRIORITIZED="com.sun.identity.agents.config.login.url.prioritized";
39      public static final String CONFIG_LOGIN_URL_PROBE_ENABLED="com.sun.identity.agents.config.login.url.probe.enabled";
40      public static final String CONFIG_FILTER_MODE="com.sun.identity.agents.config.filter.mode";
41      public static final String CONFIG_PROFILE_ATTRIBUTE_FETCH_MODE="com.sun.identity.agents.config.profile.attribute.fetch.mode";
42      public static final String CONFIG_FDQN_CHECK_ENABLE="com.sun.identity.agents.config.fqdn.check.enable";
43      public static final String CONFIG_LOGOUT_URL_PRIORITIZED="com.sun.identity.agents.config.logout.url.prioritized";
44      public static final String CONFIG_NOTENFORCED_URI="com.sun.identity.agents.config.notenforced.uri";
45      public static final String CONFIG_LOGOUT_URL_PROBE_ENABLED="com.sun.identity.agents.config.logout.url.probe.enabled";
46      public static final String CONFIG_HTTPSESSION_BINDING="com.sun.identity.agents.config.httpsession.binding";
47      public static final String AM_COOKIE_NAME="com.iplanet.am.cookie.name";
48      
49  
50  	private static final String PROPERTY_OPENAM_USERNAME = "appcenter-openam.username";
51  	private static final String PROPERTY_OPENAM_USERPASSWORD = "appcenter-openam.userpassword";
52  	private static final String PROPERTY_PROD_OPENAM_USERNAME = "appcenter-openam.prod.username";
53  	private static final String PROPERTY_PROD_OPENAM_USERPASSWORD = "appcenter-openam.prod.userpassword";
54  
55      
56      private String _strTokenId;
57      private String _strOpenamUserName;
58      private String _strOpenamPassword;
59      private String _strLoginUrl;
60      private String _strLogoutUrl;
61      private List<String> _notenforcedUri;
62      private String _strCookiename;
63  
64      /**
65       * buid Agent DTO Object  
66       * @param agentData 
67       * 			The agentData Object
68       * @param demand
69       * 			Demand Openam Object
70       * @return Agent DTO Object 
71       */
72      public static OpenamAgentDTO buildAgentDto(OpenamAgentData agentData, OpenamDemand demand ,boolean bProd) {
73          
74     	 OpenamAgentDTOins/appcenter/modules/openam/service/client/rest/OpenamAgentDTO.html#OpenamAgentDTO">OpenamAgentDTO  agentDto= new OpenamAgentDTO();
75     	 agentDto.setAgentUrl(agentData.getAgentUrl());
76     	 agentDto.setName(agentData.getName());
77     	 agentDto.setPassword(agentData.getPassword());
78     	 agentDto.setServerUrl(agentData.getServerUrl());
79     	 agentDto.setEnvironment(agentData.getEnvironment());
80     	 
81     	 if(!bProd){
82        	 
83     		 String strUsername = AppPropertiesService.getProperty( PROPERTY_OPENAM_USERNAME, "");
84           String strUserPassword = AppPropertiesService.getProperty( PROPERTY_OPENAM_USERPASSWORD, "");
85           agentDto.setOpenamUserName(strUsername);
86           agentDto.setOpenamPassword(strUserPassword);
87    
88       }else {
89        	 
90           String strUsername = AppPropertiesService.getProperty( PROPERTY_PROD_OPENAM_USERNAME, "");
91           String strUserPassword = AppPropertiesService.getProperty( PROPERTY_PROD_OPENAM_USERPASSWORD, "");
92           agentDto.setOpenamUserName(strUsername);
93           agentDto.setOpenamPassword(strUserPassword);
94         }
95         
96     	 agentDto.setLoginUrl((bProd?PROD_URL_OPENAM:agentDto.getServerUrl()) +"/UI/Login");
97       agentDto.setLogoutUrl((bProd?PROD_URL_OPENAM:agentDto.getServerUrl()) +"/UI/Logout");
98       agentDto.setCookiename( bProd?COOKIE_MCPAUTH:COOKIE_IPLANETDIRECTOTYPRO );
99       
100      List<String> notenforcedUri= new ArrayList<String>();
101      notenforcedUri.add("/"+demand.getWebappName()+"/jsp/site/plugins/mylutece/DoMyLuteceLogin.jsp?auth_provider=mylutece-openam");
102      notenforcedUri.add("/"+demand.getWebappName()+"/jsp/site/plugins/mylutece/DoMyLuteceLogin.jsp");
103      agentDto.setNotenforcedUri(notenforcedUri);
104         
105      return agentDto;
106    }
107    
108     
109     /**
110     * Returns the tokenId.
111     *
112     * @return The tokenId
113     */
114    public String getTokenId( )
115    {
116        return _strTokenId;
117    }
118 
119    /**
120     * Sets the tokenId.
121     *
122     * @param strTokenId
123     *            The TokenId
124     */
125    public void setTockenId( String strTokenId )
126    {
127        _strTokenId = strTokenId;
128    }
129    
130    /**
131     * Returns the openamUserName.
132     *
133     * @return The openamUserName
134     */
135    public String getOpenamUserName( )
136    {
137        return _strOpenamUserName;
138    }
139 
140    /**
141     * Sets the openamUserName.
142     *
143     * @param strOpenamUserName
144     *            The OpenamUserName
145     */
146    public void setOpenamUserName( String strOpenamUserName )
147    {
148 	   _strOpenamUserName = strOpenamUserName;
149    }
150    
151    /**
152     * Returns the openamPassword.
153     *
154     * @return The openamPassword
155     */
156    public String getOpenamPassword( )
157    {
158        return _strOpenamPassword;
159    }
160 
161    /**
162     * Sets the openamPassword.
163     *
164     * @param stropenamPassword
165     *            The Openam Password API
166     */
167    public void setOpenamPassword( String strOpenamPassword )
168    {
169        _strOpenamPassword = strOpenamPassword;
170    }
171    
172    /**
173     * Returns the LoginUrl.
174     *
175     * @return The LoginUrl
176     */
177    public String getLoginUrl( )
178    {
179        return _strLoginUrl;
180    }
181 
182    /**
183     * Sets the loginUrl.
184     *
185     * @param strLoginUrl
186     *            The LoginUrl
187     */
188    public void setLoginUrl( String strLoginUrl )
189    {
190 	   _strLoginUrl = strLoginUrl;
191    }
192 
193    /**
194     * Returns the LogoutUrl.
195     *
196     * @return The LogoutUrl
197     */
198    public String getLogoutUrl( )
199    {
200        return _strLogoutUrl;
201    }
202 
203    /**
204     * Sets the LogoutUrl.
205     *
206     * @param strLogoutUrl
207     *            The LogoutUrl
208     */
209    public void setLogoutUrl( String strLogoutUrl )
210    {
211 	   _strLogoutUrl = strLogoutUrl;
212    }
213    
214    /**
215     * Returns the notenforcedUri.
216     *
217     * @return The notenforcedUri
218     */
219    public List<String> getNotenforcedUri( )
220    {
221        return _notenforcedUri;
222    }
223 
224    /**
225     * Sets the notenforcedUri.
226     *
227     * @param notenforcedUri
228     *            The notenforcedUri
229     */
230    public void setNotenforcedUri( List<String> notenforcedUri )
231    {
232 	   _notenforcedUri = notenforcedUri;
233    }
234 
235 
236 public String getCookiename( )
237 {
238     return _strCookiename;
239 }
240 
241 
242 public void setCookiename( String _strCookiename )
243 {
244     this._strCookiename = _strCookiename;
245 }
246    
247 }