1 31 32 package com.opencms.legacy; 33 34 import org.opencms.i18n.CmsMessageContainer; 35 import org.opencms.main.CmsException; 36 import org.opencms.security.CmsSecurityException; 37 38 import java.util.Locale ; 39 40 49 public class CmsLegacySecurityException extends CmsSecurityException { 50 51 52 private static final long serialVersionUID = -5680076356022909019L; 53 54 58 private static class CmsLegacyMessageContainer extends CmsMessageContainer { 59 60 65 public CmsLegacyMessageContainer(String message) { 66 67 super(Messages.get(), message); 68 } 69 70 75 public String key() { 76 77 return getKey(); 78 } 79 80 87 public String key(Locale locale) { 88 89 return getKey(); 90 } 91 92 } 93 94 95 protected int m_type; 96 97 98 public static final int C_SECURITY_NO_PERMISSIONS = 303; 99 100 101 public static final int C_SECURITY_INVALID_PASSWORD = 305; 102 103 109 public CmsLegacySecurityException(CmsMessageContainer message, Throwable cause) { 110 111 super(message); 112 initCause(cause); 113 } 114 115 116 122 public CmsLegacySecurityException(String message, int type) { 123 124 super(new CmsLegacyMessageContainer(message)); 125 m_type = type; 126 } 127 128 136 public CmsException createException(CmsMessageContainer container, Throwable cause) { 137 138 return new CmsLegacySecurityException(container, cause); 139 } 140 141 146 public int getType() { 147 148 return m_type; 149 } 150 151 157 protected String getErrorDescription(int type) { 158 switch (type) { 159 case C_SECURITY_NO_PERMISSIONS: 160 return "No permissions to perform this operation"; 161 case C_SECURITY_INVALID_PASSWORD: 162 return "Invalid password"; 163 default: 164 return this.getClass().getName(); 165 } 166 } 167 } 168
| Popular Tags
|