Example usage for javax.security.jacc PolicyContextException getMessage

List of usage examples for javax.security.jacc PolicyContextException getMessage

Introduction

In this page you can find the example usage for javax.security.jacc PolicyContextException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:be.fedict.eid.dss.sp.bean.SignatureRequestServiceBean.java

private static HttpServletRequest getHttpServletRequest() {
    HttpServletRequest httpServletRequest;
    try {//from   ww w  .  j  a va  2  s .c  o m
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    return httpServletRequest;
}

From source file:be.fedict.eid.applet.service.signer.HttpSessionTemporaryDataStorage.java

/**
 * Gives back the current HTTP session using JACC.
 * /*from   w w  w .  j a va  2  s .  c  o  m*/
 * @return
 */
public static HttpSession getHttpSession() {
    HttpServletRequest httpServletRequest;
    try {
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    HttpSession httpSession = httpServletRequest.getSession();
    return httpSession;
}

From source file:be.fedict.eid.applet.beta.IdentityIntegrityServiceBean.java

public void checkNationalRegistrationCertificate(List<X509Certificate> certificateChain)
        throws SecurityException {
    LOG.debug("checking national registry certificate...");

    HttpServletRequest httpServletRequest;
    try {/*from w  w  w  .  j  av a 2 s  . c  om*/
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    HttpSession httpSession = httpServletRequest.getSession();
    X509Certificate certificate = certificateChain.get(0);
    httpSession.setAttribute("nationalRegistryCertificate", certificate);
}

From source file:be.fedict.eid.applet.beta.AuthenticationServiceBean.java

public void validateCertificateChain(List<X509Certificate> certificateChain) throws SecurityException {
    LOG.debug("validate certificate chain: " + certificateChain);

    HttpServletRequest httpServletRequest;
    try {//from w  ww .  j  ava 2s. com
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    HttpSession httpSession = httpServletRequest.getSession();
    httpSession.setAttribute("authenticationCertificateChain", certificateChain);
}

From source file:be.fedict.eid.applet.beta.TestReportFactory.java

private HttpServletRequest getHttpServletRequest() {
    HttpServletRequest httpServletRequest;
    try {// w  ww . j  a  va2 s  .  c  om
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }
    return httpServletRequest;
}

From source file:be.fedict.hsm.model.security.SecurityAuditGeneratorBean.java

private String getHostIdentifier() {
    HttpServletRequest httpServletRequest;
    try {//  w w w .  j a  va  2  s  .c  o  m
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        LOG.debug("JACC error: " + e.getMessage());
        return null;
    }
    String hostIdentifier = httpServletRequest.getRemoteHost();
    return hostIdentifier;
}

From source file:be.fedict.eid.applet.beta.SessionContextManagerBean.java

public SessionContextEntity getSessionContext() {
    HttpServletRequest httpServletRequest;
    try {//w ww  . j av a  2  s .  com
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }
    HttpSession httpSession = httpServletRequest.getSession();
    String httpSessionId = httpSession.getId();
    SessionContextEntity sessionContextEntity = getSessionContextEntity(httpSessionId);
    return sessionContextEntity;
}

From source file:be.fedict.eid.applet.beta.SecureClientEnvironmentBean.java

public void checkSecureClientEnvironment(String javaVersion, String javaVendor, String osName, String osArch,
        String osVersion, String userAgent, String navigatorAppName, String navigatorAppVersion,
        String navigatorUserAgent, String remoteAddress, Integer sslKeySize, String sslCipherSuite,
        List<String> readerList) throws InsecureClientEnvironmentException {
    String clientEnviromentResult = "java version: " + javaVersion + "\n" + "java vendor: " + javaVendor + "\n"
            + "OS name: " + osName + "\n" + "OS arch: " + osArch + "\n" + "OS version: " + osVersion + "\n"
            + "user agent: " + userAgent + "\n" + "navigator app name: " + navigatorAppName + "\n"
            + "navigator app version: " + navigatorAppVersion + "\n" + "navigator user agent: "
            + navigatorUserAgent + "\n" + "remote address: " + remoteAddress + "\n" + "ssl key size: "
            + sslKeySize + "\n" + "ssl cipher suite: " + sslCipherSuite + "\n" + "readers: " + readerList;
    LOG.debug(clientEnviromentResult);//from  w w  w .j  a v a  2s .  c o m

    SessionContextEntity sessionContext = this.sessionContextManager.getSessionContext();
    TestResultEntity testResultEntity = new TestResultEntity("Client Environment", clientEnviromentResult,
            sessionContext);
    this.entityManager.persist(testResultEntity);

    HttpServletRequest httpServletRequest;
    try {
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    HttpSession httpSession = httpServletRequest.getSession();
    httpSession.setAttribute("clientJavaVersion", javaVersion);
    httpSession.setAttribute("clientJavaVendor", javaVendor);
    httpSession.setAttribute("clientOSName", osName);
    httpSession.setAttribute("clientOSArch", osArch);
    httpSession.setAttribute("clientOSVersion", osVersion);
    httpSession.setAttribute("clientReaders", readerList.toString());
    httpSession.setAttribute("clientUserAgent", userAgent);
    httpSession.setAttribute("clientSslCipherSuite", sslCipherSuite);
    httpSession.setAttribute("clientRemoteAddress", remoteAddress);
    httpSession.setAttribute("clientSslKeySize", sslKeySize);
    httpSession.setAttribute("clientNavigatorUserAgent", navigatorUserAgent);
    httpSession.setAttribute("clientNavigatorAppName", navigatorAppName);
    httpSession.setAttribute("clientNavigatorAppVersion", navigatorAppVersion);

    TestReportFactory testReportFactory = new TestReportFactory(this.entityManager);
    testReportFactory.startTestReport(javaVersion, javaVendor, osName, osArch, osVersion, userAgent,
            navigatorAppName, navigatorAppVersion, navigatorUserAgent);
}

From source file:be.fedict.eid.applet.beta.SessionContextManagerBean.java

@SuppressWarnings("unchecked")
public int getSessionContextId(String httpSessionId) {
    LOG.debug("get context Id for HTTP session Id: " + httpSessionId);

    Query query = this.entityManager
            .createQuery("FROM SessionContextEntity AS sc WHERE sc.httpSessionId = :httpSessionId");
    query.setParameter("httpSessionId", httpSessionId);
    List<SessionContextEntity> sessionContextList = query.getResultList();
    if (sessionContextList.isEmpty()) {
        HttpServletRequest httpServletRequest;
        try {//from  w  w  w.  j  a  va  2 s.  c om
            httpServletRequest = (HttpServletRequest) PolicyContext
                    .getContext("javax.servlet.http.HttpServletRequest");
        } catch (PolicyContextException e) {
            throw new RuntimeException("JACC error: " + e.getMessage());
        }
        String userAgent = httpServletRequest.getHeader("user-agent");
        LOG.debug("user agent: " + userAgent);
        SessionContextEntity sessionContextEntity = new SessionContextEntity(httpSessionId, userAgent);
        this.entityManager.persist(sessionContextEntity);
        int contextId = sessionContextEntity.getContextId();
        LOG.debug("new context Id: " + contextId);
        return contextId;
    }
    /*
     * An existing HTTP session will come from the same user agent.
     */
    SessionContextEntity sessionContextEntity = sessionContextList.get(0);
    int contextId = sessionContextEntity.getContextId();
    LOG.debug("existing context Id: " + contextId);
    return contextId;
}

From source file:be.fedict.eid.applet.beta.admin.AdministratorServiceBean.java

public void validateCertificateChain(List<X509Certificate> certificateChain) throws SecurityException {
    /*//from  ww w  .j a va 2s. co m
     * We're not using the entire PKI infrastructure here since we are in
     * control of the admin token ourselves.
     */
    X509Certificate adminCert = certificateChain.get(0);
    PublicKey adminPublicKey = adminCert.getPublicKey();
    String userId = getUserId(adminCert);
    if (isRegistered()) {
        LOG.debug("admin login");
    } else {
        LOG.debug("admin registration");
        register(adminPublicKey, userId);
    }

    String adminPassword = new String(Hex.encodeHex(adminPublicKey.getEncoded()));

    HttpServletRequest httpServletRequest;
    try {
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    HttpSession httpSession = httpServletRequest.getSession();
    Credentials credentials = (Credentials) httpSession.getAttribute("org.jboss.seam.security.credentials");

    LOG.debug("username: " + userId);
    /*
     * Pass the eID credentials to the JBoss Seam security framework.
     */
    credentials.setUsername(userId);
    credentials.setPassword(adminPassword);
}