Salut,
je suis en train d'ecrire une classe qui devra etre apellé depuis un logiciel. Ce logiciel en question impose que les methodes qu'il va apeller soit déclaré static. Ici je vais devoir apellé la methode doTheChange donc je la declare static. Lorsqu'elle n'est pas declaré static, la classe se compile sans probleme mais elle ne peut pas etre apellé depuis le logiciel. Et lorsque je la declare static, alors je ne peux plus la compiler. J'ai l'erreur suivante :
crpsante/CacheAM.java [31:1] non-static variable this cannot be referenced from a static context
PostProcessingPrincipal ppp = new PostProcessingPrincipal(amAdminUID);
Est ce que qqun voit comment je pourrais contourner ce probleme?
Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 package crpsante; import com.iplanet.sso.*; import com.iplanet.am.util.Debug; import com.iplanet.am.sdk.*; import com.sun.identity.authentication.spi.AMPostAuthProcessInterface; import com.sun.identity.authentication.spi.AuthenticationException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.*; public class CacheAM { private static String amAdminUID = "uid=amAdmin,ou=People,dc=crp-sante,dc=healthnet,dc=lu"; public static void doTheChange() throws AuthenticationException { try { SSOTokenManager tokenManager = SSOTokenManager.getInstance(); PostProcessingPrincipal ppp = new PostProcessingPrincipal(amAdminUID); .................... .................... } catch (Exception ex) { System.out.println("Error in CacheAM.doTheChange : "+ex); } } class PostProcessingPrincipal implements java.security.Principal { private String name; public PostProcessingPrincipal(String name) { this.name = name; } public boolean equals(Object o) { return ( (o instanceof java.security.Principal) && ( ((java.security.Principal)o).getName().equals(name)) ); } public String getName() { return name; } public int hashCode() { return name.hashCode(); } public String toString() { return name; } } }
Partager