1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.grukeydiversification.web.rs.dto;
35
36 import java.util.Map;
37
38 import org.apache.commons.lang.StringUtils;
39
40 import fr.paris.lutece.plugins.identitystore.web.rs.dto.AttributeDto;
41 import fr.paris.lutece.plugins.identitystore.web.rs.dto.IdentityDto;
42 import fr.paris.lutece.portal.service.util.AppException;
43 import fr.paris.lutece.portal.service.util.AppLogService;
44 import fr.paris.lutece.util.keydiversification.DiversificationService;
45 import fr.paris.lutece.util.keydiversification.KeyDiversificationException;
46
47
48
49
50
51
52
53
54
55
56
57
58
59 public class EncryptedIdentityDto extends IdentityDto
60 {
61
62
63
64
65 private static final long serialVersionUID = -8236870738465724413L;
66
67 private final IdentityDto _identityDto;
68 private String _strCustomerId;
69
70
71
72
73
74
75
76
77
78
79
80 public EncryptedIdentityDto( IdentityDto identityDto, String strEncryptionKey )
81 {
82 super( );
83 _identityDto = identityDto;
84
85 if ( StringUtils.isBlank( strEncryptionKey ) )
86 {
87 throw new AppException( "Encrytion on Identity is enabled but the encryption key is blank!" );
88 }
89
90 if ( _identityDto.getCustomerId( ) != null )
91 {
92 try
93 {
94 _strCustomerId = DiversificationService.getSPKey( _identityDto.getCustomerId( ), strEncryptionKey );
95 }
96 catch( KeyDiversificationException e )
97 {
98 String strMessage = "Error during encryption of Identity";
99 StringBuilder stringBuilder = new StringBuilder( strMessage ).append( " : connectionId = " ).append( _identityDto.getConnectionId( ) )
100 .append( ", customerId = " ).append( _identityDto.getCustomerId( ) );
101 AppLogService.error( stringBuilder.toString( ), e );
102
103 throw new AppException( strMessage );
104 }
105 }
106 }
107
108
109
110
111 @Override
112 public Map<String, AttributeDto> getAttributes( )
113 {
114 return _identityDto.getAttributes( );
115 }
116
117
118
119
120 @Override
121 public void setAttributes( Map<String, AttributeDto> mapAttributes )
122 {
123 _identityDto.setAttributes( mapAttributes );
124 }
125
126
127
128
129 @Override
130 public String getConnectionId( )
131 {
132 return _identityDto.getConnectionId( );
133 }
134
135
136
137
138 @Override
139 public void setConnectionId( String connectionId )
140 {
141 _identityDto.setConnectionId( connectionId );
142 }
143
144
145
146
147 @Override
148 public String getCustomerId( )
149 {
150 return _strCustomerId;
151 }
152
153
154
155
156 @Override
157 public void setCustomerId( String strCustomerId )
158 {
159 _strCustomerId = strCustomerId;
160 }
161
162 }